ebook img

SPARCompiler Ada Programmer's Guide PDF

260 Pages·1999·0.42 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview SPARCompiler Ada Programmer's Guide

SPARCompiler Ada Programmer’s Guide A Sun Microsystems, Inc. Business 2550 Garcia Avenue Mountain View, CA 94043 U.S.A. Part No.: 801-4862-11 Revision B, August 1994 (cid:211) 1994 Sun Microsystems, Inc. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A. All rights reserved. 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, Sun Microsystems Computer Corporation, Solaris, are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and certain other countries. UNIX is a registered trademark of Novell, Inc., in the United States and other countries; X/Open Company, Ltd., is the exclusive licensor of such trademark. 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. VADS, VADScross, and Verdix are registered trademarks of Rational Software Corporation (formerly Verdix). 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 product of the Massachusetts Institute of Technology. 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 Invokinga.pr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 1.2 Default Format Specifications. . . . . . . . . . . . . . . . . . . . . . . 1-2 1.3 Fixed-format Specifications. . . . . . . . . . . . . . . . . . . . . . . . . 1-2 1.4 Error and Warning Messages . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.5 .prrc Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.6 Command-line Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.7 a.pr Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.7.1 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1.7.2 Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1.7.3 Splitting Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 1.7.4 Line Length Specification. . . . . . . . . . . . . . . . . . . . . . 1-6 1.7.5 Tabs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 1.8 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1.8.1 Unformatted Source File . . . . . . . . . . . . . . . . . . . . . . 1-7 iii 1.8.2 .prrc File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1.8.3 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 1.8.4 Command-line Options . . . . . . . . . . . . . . . . . . . . . . . 1-9 2. Ada Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 2.1 Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 2.2 Chapter Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 2.2.1 Lexical Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 2.2.2 Program Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 2.2.3 Declarations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 2.2.4 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 2.2.5 Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14 2.2.6 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 2.2.7 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 2.2.8 Conditional Processing. . . . . . . . . . . . . . . . . . . . . . . . 2-23 2.2.9 Declare Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 2.2.10 Visibility Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 2.2.11 Pragmas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 2.2.12 Macro Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33 2.3 Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-35 3. Statistical Profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 3.1 Linking and Running Profiled Programs . . . . . . . . . . . . . 3-7 3.2 Profiling, How To Do It . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 3.3 profile_conf Directory. . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 4. Machine Code Insertions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 iv SPARCompiler Ada Programmer’s Guide 4.1 Machine Code Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4.2 Code statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 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-8 4.4 Subprogram Call. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 4.5 Parameter Passing in Machine Code Subprograms. . . . . 4-11 4.6 Local Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 4.6.1 Jump Table via Absolute Addresses. . . . . . . . . . . . . 4-12 4.7 Pragmas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 4.7.1 pragmaINLINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 4.7.2 pragmaSUPPRESS. . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 4.7.3 pragmaIMPLICIT_CODE. . . . . . . . . . . . . . . . . . . . . 4-14 4.7.4 x pragmaOPTIMIZE_CODE. . . . . . . . . . . . . . . . . . . 4-15 4.8 Debugging Machine Code. . . . . . . . . . . . . . . . . . . . . . . . . . 4-15 4.9 Pseudo Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15 4.10 packageMACHINE_CODE. . . . . . . . . . . . . . . . . . . . . . . . . . 4-17 5. Interface Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1 5.1 Ada Interface tocurses. . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1 5.1.1 Create Parallel Data Types. . . . . . . . . . . . . . . . . . . . . 5-2 5.1.2 Declare External Subprograms . . . . . . . . . . . . . . . . . 5-8 5.1.3 Access Global Variables . . . . . . . . . . . . . . . . . . . . . . . 5-13 5.1.4 Map to Parallel Data Structures . . . . . . . . . . . . . . . . 5-14 Contents v 5.1.5 Reduce the Overhead. . . . . . . . . . . . . . . . . . . . . . . . . 5-19 5.2 Program Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-19 5.3 Calling Ada From Other Languages . . . . . . . . . . . . . . . . . 5-22 5.3.1 pragmaEXTERNAL andpragmaEXTERNAL_NAME 5-22 5.3.2 Finding the Right Object . . . . . . . . . . . . . . . . . . . . . . 5-23 5.3.3 Avoiding Elaboration. . . . . . . . . . . . . . . . . . . . . . . . . 5-24 5.3.4 Linking a Non-Ada Main Program. . . . . . . . . . . . . . 5-25 5.3.5 Runtime Considerations . . . . . . . . . . . . . . . . . . . . . . 5-25 A. User Library Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 A.1 Steps to Configure the User Library. . . . . . . . . . . . . . . . . . A-1 A.1.1 Build the User Library . . . . . . . . . . . . . . . . . . . . . . . . A-2 A.1.2 Create an Ada Library . . . . . . . . . . . . . . . . . . . . . . . . A-2 A.1.3 Copy the Configuration Files . . . . . . . . . . . . . . . . . . A-3 A.1.4 Edit the User Configuration Package. . . . . . . . . . . . A-4 A.1.5 Compile All Ada Files . . . . . . . . . . . . . . . . . . . . . . . . A-4 A.1.6 Change theada.lib File . . . . . . . . . . . . . . . . . . . . . A-4 A.1.7 Build a Test Library. . . . . . . . . . . . . . . . . . . . . . . . . . . A-5 A.1.8 Edit, Compile, and Link Your Test Program . . . . . . A-5 A.1.9 Run Your Test Program . . . . . . . . . . . . . . . . . . . . . . . A-5 A.2 User Library Configuration Files . . . . . . . . . . . . . . . . . . . . A-6 A.3 V_USR_CONF Configuration Components . . . . . . . . . . . . A-7 A.3.1 #c1:FAT_MALLOCSMALL_BLOCK_SIZES_TABLE Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-8 A.3.2 #c2: Memory Allocation Parameters specific to SLIM_MALLOC, FAT MALLOC and DBG_MALLOC A-9 vi SPARCompiler Ada Programmer’s Guide A.3.3 #c3:CONFIGURATION_TABLE Structure . . . . . . . A-11 A.3.4 #c3a: Stack Configuration Parameters. . . . . . . . . . A-14 A.3.5 #c3b:FLOATING_POINT Configuration Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-16 A.3.6 #c3c: Heap Memory Callout Configuration Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-16 A.3.7 #c3d: Memory Allocation Configuration Table. . . . A-17 A.3.8 #c3e: Solaris Signal Configuration Parameters. . . A-18 A.3.9 #c3f: Time Slice Configuration Parameters - VADS Threaded Area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-19 A.3.10 #c3f: Solaris MT Ada Configuration Parameters - MT Ada. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-19 A.3.11 #c3g: Attributes Configuration Parameters . . . . . . A-21 A.3.12 #c3h: Miscellaneous Configuration Parameters. . A-26 A.3.13 #c4:V_GET_HEAP_MEMORY Routine . . . . . . . . . . . A-27 A.3.14 #c5:V_PASSIVE_ISR Routine. . . . . . . . . . . . . . . . A-27 A.3.15 #c6:V_SIGNAL_ISR Routine . . . . . . . . . . . . . . . . . A-28 A.3.16 #c8:V_PENDING_OVERFLOW_CALLOUT Routine. . A-30 A.3.17 #c9:V_KRN_ALLOC_CALLOUT Routine . . . . . . . . . . A-31 A.3.18 #c10:V_START_PROGRAM and V_START_PROGRAM_CONTINUE Routines . . . . . . . A-31 B. XView Interface and Runtime System . . . . . . . . . . . . . . . . . . . B-1 B.1 Product Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1 B.2 How To Use SCAda With XView. . . . . . . . . . . . . . . . . . . . B-2 B.2.1 XView Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2 B.2.2 XView Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2 Contents vii B.2.3 Compiling and Linking Programs . . . . . . . . . . . . . . B-3 B.2.4 Interface Limitations. . . . . . . . . . . . . . . . . . . . . . . . . . B-4 B.2.5 Notifier Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . B-5 B.3 The SCAda XView Interface. . . . . . . . . . . . . . . . . . . . . . . . B-6 B.3.1 Interface Package Structure. . . . . . . . . . . . . . . . . . . . B-7 B.3.2 Data Type Naming Conventions. . . . . . . . . . . . . . . . B-8 B.3.3 Differences In This Implementation. . . . . . . . . . . . . B-8 B.4 The SCAda Kernel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-16 B.4.1 Integrating the XView Notifier With Ada Tasking . B-16 B.4.2 Serializing Access to The Notifier. . . . . . . . . . . . . . . B-17 B.4.3 packageXVI_NOTIFY . . . . . . . . . . . . . . . . . . . . . . . B-18 C. POSIX Conformance Document. . . . . . . . . . . . . . . . . . . . . . . . . C-1 C.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1 C.1.1 Release Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1 C.2 Terminology and General Requirements. . . . . . . . . . . . . . C-3 C.2.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-3 C.2.2 General Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4 C.2.3 package POSIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-5 C.3 Process Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-13 C.3.1 package POSIX_PROCESS_PRIMITIVES. . . . . . . . . C-13 C.3.2 package POSIX_UNSAFE_PROCESS_PRIMITIVES C-13 C.3.3 package POSIX_SIGNALS. . . . . . . . . . . . . . . . . . . . . C-14 C.4 Process Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-19 C.4.1 package POSIX_PROCESS_IDENTIFICATION . . . C-19 viii SPARCompiler Ada Programmer’s Guide C.4.2 package POSIX_PROCESS_TIMES. . . . . . . . . . . . . . C-20 C.4.3 package POSIX_PROCESS_ENVIRONMENT. . . . . C-21 C.4.4 package POSIX_CALENDAR . . . . . . . . . . . . . . . . . . C-21 C.5 Files and Directories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-22 C.5.1 package POSIX_PERMISSIONS . . . . . . . . . . . . . . . . C-22 C.5.2 package POSIX_FILES . . . . . . . . . . . . . . . . . . . . . . . . C-22 C.5.3 package POSIX_FILE_STATUS . . . . . . . . . . . . . . . . . C-23 C.5.4 package POSIX_CONFIGURABLE_FILE_LIMITS. C-23 C.6 Input and Output Primitives . . . . . . . . . . . . . . . . . . . . . . . C-24 C.6.1 package POSIX_IO . . . . . . . . . . . . . . . . . . . . . . . . . . . C-24 C.7 Device- and Class-Specific Functions. . . . . . . . . . . . . . . . . C-25 C.7.1 General Terminal Interface . . . . . . . . . . . . . . . . . . . . C-25 C.7.2 package POSIX_TERMINAL_FUNCTIONS . . . . . . C-25 C.8 Language Specific Services for the C Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-25 C.8.1 Interoperable Ada I/O Services . . . . . . . . . . . . . . . . C-25 C.8.2 package POSIX_SUPPLEMENT_TO_ADA_IO. . . . C-25 C.9 System Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-25 C.9.1 package POSIX_USER_DATABASE. . . . . . . . . . . . . C-25 C.9.2 package POSIX_GROUP_DATABASE. . . . . . . . . . . C-25 D. Implementation-Dependent Characteristics . . . . . . . . . . . . . . F-1 F.1 Pragmas and Their Effects. . . . . . . . . . . . . . . . . . . . . . . . . . F-2 F.2 Predefined Packages and Generics. . . . . . . . . . . . . . . . . . . F-12 F.2.1 Specification ofpackageSYSTEM . . . . . . . . . . . . . . F-13 Contents ix F.2.2 packageCALENDAR. . . . . . . . . . . . . . . . . . . . . . . . . . F-14 F.2.3 packageMACHINE_CODE. . . . . . . . . . . . . . . . . . . . . F-15 F.2.4 packageSEQUENTIAL_IO. . . . . . . . . . . . . . . . . . . . F-17 F.2.5 packageUNSIGNED_TYPES. . . . . . . . . . . . . . . . . . . F-17 F.2.6 Specification ofpackageUNSIGNED_TYPES. . . . . F-18 F.3 Slices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-20 F.4 Implementation-defined Attributes. . . . . . . . . . . . . . . . . . F-20 F.4.1 ’REF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-20 F.4.2 X’REF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-20 F.4.3 SYSTEM.ADDRESS’REF(N) . . . . . . . . . . . . . . . . . . . F-21 F.4.4 X’TASK_ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-22 F.5 Restrictions on Main Programs. . . . . . . . . . . . . . . . . . . . . . F-22 F.6 Generic Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-22 F.7 Shared Object Code for Generic Subprograms. . . . . . . . . F-22 F.8 Representation Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-24 F.9 Parameter Passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-30 F.10 Conversion and Deallocation . . . . . . . . . . . . . . . . . . . . . . . F-32 F.11 Process Stack Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-33 F.12 Types, Ranges, and Attributes . . . . . . . . . . . . . . . . . . . . . . F-33 F.13 Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-35 x SPARCompiler Ada Programmer’s Guide

Description:
Figure 4-6. Example of Jump Table via Absolute Address References a.error and a.list, SPARCompiler Ada Reference Guide in thrifty mind.".
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.