Sparcompiler Ada Programmer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
SPARCompiler Ada Programmer’s Guide A Sun Microsystems, Inc. Business 2550 Garcia Avenue Mountain View, CA 94043 U.S.A. Part No.: 802-3641-10 Revision A November, 1995 1995 Sun Microsystems, Inc. All rights reserved. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A. This product and related documentation are protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or related documentation may be reproduced in any form by any means without prior written authorization of Sun and its licensors, if any. Portions of this product may be derived from the UNIX® and Berkeley 4.3 BSD systems, licensed from UNIX System Laboratories, Inc., a wholly owned subsidiary of Novell, Inc., and the University of California, respectively. Third-party font software in this product is protected by copyright and licensed from Sun’s font suppliers. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and FAR 52.227-19. The product described in this manual may be protected by one or more U.S. patents, foreign patents, or pending applications. TRADEMARKS Sun, the Sun logo, Sun Microsystems, Solaris, are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and certain other countries. UNIX is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. OPEN LOOK is a registered trademark of Novell, Inc. PostScript and Display PostScript are trademarks of Adobe Systems, Inc. All other product names mentioned herein are the trademarks of their respective owners. All SPARC trademarks, including the SCD Compliant Logo, are trademarks or registered trademarks of SPARC International, Inc. SPARCstation, SPARCserver, SPARCengine, SPARCstorage, SPARCware, SPARCcenter, SPARCclassic, SPARCcluster, SPARCdesign, SPARC811, SPARCprinter, UltraSPARC, microSPARC, SPARCworks, and SPARCompiler are licensed exclusively to Sun Microsystems, Inc. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. The OPEN LOOK® and Sun™ Graphical User Interfaces were developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface, which license also covers Sun’s licensees who implement OPEN LOOK GUIs and otherwise comply with Sun’s written license agreements. X Window System is a trademark of the X Consortium. THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME. Please Recycle Contents 1. Ada Formatter . 1-1 1.1 Invocation . 1-2 1.2 Default Format Specifications . 1-2 1.3 Fixed Format Specifications . 1-3 1.4 Error and Warning Messages . 1-3 1.5 Configuration File. 1-3 1.6 Command-line Options . 1-4 1.7 Output . 1-4 1.7.1 Comments . 1-4 1.7.2 Pagination. 1-5 1.7.3 Splitting Lines . 1-5 1.7.4 Line Length Specification . 1-6 1.7.5 Tabs . 1-7 1.8 Examples . 1-7 1.8.1 Unformatted Source File. 1-8 iii 1.8.2 The .prrc File . 1-9 1.8.3 Output. 1-10 1.8.4 Command-line Options . 1-11 2. Ada Preprocessor. 2-1 2.1 Invocation . 2-2 2.2 Chapter Conventions . 2-3 2.2.1 Lexical Elements . 2-3 2.2.2 Program Structure . 2-6 2.2.3 Declarations . 2-8 2.2.4 Types . 2-12 2.2.5 Names . 2-15 2.2.6 Expressions. 2-19 2.2.7 Assignment . 2-24 2.2.8 Conditional Processing . 2-24 2.2.9 Declare Statement . 2-29 2.2.10 Visibility Rules. 2-29 2.2.11 Pragmas . 2-32 2.2.12 Macro Substitution . 2-34 2.3 Example . 2-36 3. Statistical Profiler. 3-1 3.1 Linking and Running Profiled Programs . 3-6 3.2 Profiling, How to do it . 3-7 3.3 profile_conf Directory . 3-8 3.4 Profiling After Reconfiguration . 3-8 iv SPARCompiler Ada Programmer’s Guide 4. Machine Code Insertions. 4-1 4.1 Machine Code Procedures. 4-2 4.2 Code-statements . 4-3 4.2.1 Opcodes . 4-3 4.2.2 Operands . 4-3 4.2.3 Ada Entities as Operands . 4-6 4.3 Program Control . 4-9 4.4 Subprogram Call. 4-11 4.5 Parameter Passing in Machine Code Subprograms . 4-12 4.6 Local Data . 4-13 4.6.1 Jump Table via Absolute Addresses . 4-14 4.7 Pragmas . 4-15 4.7.1 pragma INLINE. 4-15 4.7.2 pragma SUPPRESS . 4-15 4.7.3 pragma IMPLICIT_CODE . 4-16 4.7.4 pragma OPTIMIZE_CODE. 4-16 4.8 Debugging Machine Code. 4-16 4.9 Pseudo Instructions . 4-17 4.10 package MACHINE_CODE . 4-19 5. Interface Programming . 5-1 5.1 Ada Interface to curses . 5-2 5.1.1 Create Parallel Data Types . 5-2 5.1.2 Declare External Subprograms . 5-9 5.1.3 Access Global Variables . 5-13 v 5.1.4 Map To Parallel Data Structures . 5-15 5.1.5 Reduce the Overhead . 5-20 5.2 Program Conversion . 5-20 5.3 Calling Ada From Other Languages . 5-24 5.3.1 pragma EXTERNAL and pragma EXTERNAL_NAME 5-24 5.3.2 Finding the Right Object. 5-25 5.3.3 Avoiding Elaboration . 5-26 5.3.4 Linking a Non-Ada Main Program . 5-26 5.3.5 Runtime Considerations. 5-27 5.3.6 Additional Considerations . 5-27 A. User Library Configuration . A-1 A.1 Steps to Configure the User Library. A-2 A.1.1 Build the User Library . A-2 A.1.2 Create an Ada Library . A-3 A.1.3 Copy the Configuration Files. A-4 A.1.4 Edit the User Configuration Package . A-5 A.1.5 Compile all Ada Files . A-5 A.1.6 Change the ada.libADA.LIB File . A-6 A.1.7 Build a Test Library. A-6 A.1.8 Edit, Compile, and Link Your Test Program . A-7 A.1.9 Run Your Test Program. A-7 A.2 User Library Configuration Files . A-8 A.3 V_USR_CONF Configuration Components . A-9 vi SPARCompiler Ada Programmer’s Guide A.3.1 #c1: FAT_MALLOC’s SMALL_BLOCK_SIZES_TABLE structure . A-10 A.3.2 #c2: MEM_ALLOC_CONF_TABLE Structure. A-11 A.3.3 #c3: TASKDEB CONFIGURATION structure . A-13 A.3.4 #c3a: INITIALIZATION PROCEDURE ADDRESS A-14 A.3.5 #3b: SIGNAL NUMBER CONFIGURATION. A-14 A.3.6 #c3c: TRAP INSTRUCTION CONFIGURATION A-14 A.3.7 #c3d: DEBUG and CALL TASK CONFIGURATION A-15 A.3.8 #c4: ADAPATH Reference . A-16 A.3.9 #c5: CONFIGURATION_TABLE structure. A-16 A.3.10 #c5a: Stack Configuration Parameters . A-20 A.3.11 #c5b: FLOATING_POINT Configuration Parameters A-22 A.3.12 #c5c:Heap Memory Callout Configuration Parameters A-23 A.3.13 #c5d: Memory Allocation Configuration Table . A-23 A.3.14 #c5e: TASKDEB CONFIGURATION Structure . A-24 A.3.15 #c5f: Host OS Signal Configuration Parameters . A-24 A.3.16 #c5g: Time Slice Configuration Parameters - VADS Threaded Ada . A-25 A.3.17 #c5h: Attributes Configuration Parameters . A-26 A.3.18 #c5i: Miscellaneous Configuration Parameters . A-30 A.3.19 #c6: V_GET_HEAP_MEMORY routine. A-32 A.3.20 #c7: V_PASSIVE_ISR Routine . A-33 A.3.21 #c8: V_SIGNAL_ISR Routine . A-34 A.3.22 #c9: V_CIFO_ISR Routine. A-35 vii A.3.23 #c10: V_PENDING_OVERFLOW_CALLOUT Routine A-36 A.3.24 #c11: V_KRN_ALLOC_CALLOUT Routine . A-37 A.3.25 #c12: V_START_PROGRAM and V_START_PROGRAM_CONTINUE Routines A-38 B. Posix Conformance Document . B-1 B.1 Release Structure . B-2 B.2 Terminology and General Requirements. B-3 B.3 Process Primitives. B-12 B.4 Process Environment . B-17 B.5 Files and Directories. B-21 B.6 Input and Output Primitives. B-23 B.7 Device- and Class-Specific Functions. B-25 B.8 Language.