The Big Online Book of Linux Ada Programming
An online documentation project over 27,000 lines long.
Last Updated: July 22, 2002
Copyright © 1999-2002, Ken O. Burtch. All Rights Reserved. Permission given
to copy (including photocopying) this document for education purposes provided
this notice is kept intact.
Do you want to develop Linux applications twice as
fast as the C language? Read
on! |
Special Thanks To
Jean-Marc Bourguet (C++ exceptions)
Mike Brenner (Pure)
Jeff Creem
(user stack and errno clarifications)
Warren W. Gay (Ada Streams)
Bernhard Gubanka (Debugging Pools clarifications)
Eric L. Schott, Warren
W. Gay, Jean-Marc Bourguet (Adjust vs. C++ Copy Constructors)
Rush Kesler
(PDF version)
Jürgen Pfeifer (Multithreading information)
Karl Ranseier
(audio bug)
Duncan Sands (Fortran, Elaborate_All)
Erik Sigra (Automake)
Wilhelm Spickermann (CVS)
Leonid A. Timochouk (Florist clarifications)
Michael Uplawski (typing mistake)
Talk with the author at ken-nospam@pegasoft.ca (remove the "-nospam"). Hosted
by PegaSoft Canada. Special thanks to
the Ada Linux Team.
Table of Contents
i. Preface
1
Introduction
1.1 A Brief History of
Linux
1.2
1995: The Year of Ada and Gnat
1.3 Why use
Ada?
1.4 Why
Ada and Linux?
1.5 Linux Ada
Resources
2 Installing Gnat on
Linux
2.1 Installing the ALT
RPMs
2.2
Installing the ACT Binaries
2.3 Compiling Gnat from
its Sources
2.4 Case Study:
Installing Gnat 3.11 on over an old Linux Distribution
3
The Integrated Development Environments
3.1 TIA: The Console
IDE
3.1.1 Quick Start
3.1.2 TIA Keyboard Legend
3.1.3 The File
Menu
3.1.4 The Edit Menu
3.1.5 The Find Menu
3.1.6 The Misc
Menu
3.1.7 The Project Menu
3.1.8 The ? Menu
3.2 GRASP-the X windows
IDE
3.2.1 Installation
3.2.2 QuickStart
3.2.3 The Project
Window
3.2.4 The Source File Window
3.2.5 The Button Bar
3.3 Other Tools and
IDEs
3.3.1 VAD
3.3.2 Jessie
3.3.3 RAPID
3.3.3 VIDE
3.3.5
GLIDE
4 From Source Code to
Executable
4.1 Gnat Filename
Conventions
4.2 Writing Your First
Ada Program
4.2.1 Writing a
Program with an IDE
4.2.2 Writing a
Program without an IDE
4.2.3 After
Building
4.3
The Three Step Process
4.4 Gnat Compiling
Options
4.4.1 Run-time Error
Checking
4.4.2 Checking without
Compiling
4.4.3 When you have
Too Many Errors
4.5 Gnat Binding
Options
4.6
Gnat Linking Options
4.7 Gnatmake
Options
4.7.1 So you changed
the comments ?
4.7.2 Gnatbl: Bind and
Link
5 Building Large
Projects
5.1 Make: the
Traditional Project Builder
5.1.1 A Simple Ada
Makefile
5.2
Cook: A Parallel Make
5.2.1 Cooking in Parallel
5.2.2 A Simple Ada
Cookbook
5.3
Automake and Autoconf: UNIX Portability
6 Development
Utilities
6.1 Saving Time with
Gnatstub
6.2
Crossreferencing with Gnatxref
6.3 Eliminating Dead
Code with Gnatelim
6.4 Execution Stack
& Memory Leak Detection
6.5 Conditional
Compiling with Gnatprep
6.6 Profiling with
gprof
6.7
Shared Libraries Using GnatDLL
6.8 Source as Web Pages
Using GnatHTML
6.9
GnatFIND
7 Optimizing Your
Project
7.1 Compiler
Optimization Options
7.2 Gnat Source
Optimization Options
7.3 CPU Optimization
Options
7.4
What Differnece Does Optimization Make?
7.5 Working with the
Assmebly Source
8 Debugging Your
Project
8.1 Limit and the Heap
Size
8.2 The
Debugging Pragmas
8.3 Identifying
Files
8.4
Compiler Info with -gnatG
8.5 Floating Point
Numbers
8.6
Gdb: The GNU Debugger
8.7 Code
Restrictions
9 Team
Development
9.1 Change
Logs
9.2 RCS:
Revision Control System
9.3 CVS: Concurrent
Versions System
9.4 Creating Transcripts
with Script
9.5 Timing Execution
with Time
10 An Introduction to
Ada
10.1 Your Main
Program
10.2
Text_IO
10.3
Fundamental Data Types
10.4 Type
Attributes
10.5 Operatiors and
Expressions
10.6 Variable
Declarations
10.7 New
Types
10.7.1 Modular Types
10.7.2 Text_IO and New Types
10.8 Aggregate
Types
10.9
Enumerated Types
10.10 Procedures and
Function
10.11 Flow of
Control
11 Advanced Ada
Programming
11.1
Packages
11.2 Controlling
Elaboration
11.2.1 First line of defense: Pure, Preelaborate and
No_Elaboration_Code
11.2.2 Second line of defense: Elaborate, Elaborate_Body,
Elaborate_All
11.2.3 Other Elaboration Pragmas
11.3 Objects
11.4 Objects with
Automatic Initialization/Finalization
11.5 Multiple
Inheritance
11.6 Private
Objects
11.7
Generics
11.8
Exceptions
11.9 Dynamic
Allocation
11.10
Callbacks
11.10.1 Storage Pools
11.10.2 Access
Parameters
11.11
Multithreading
11.11.1 FSU vs. Native Threads
11.11.2 Tasks
11.11.3
Task Types
11.11.4 Protected Items/Types
11.12 Ada Text
Streams
11.13
Pragmas
11.14 Low-Level
Ada
12 Standard Gnat
Packages
12.1 Standard String
and Character Packages
12.2 Advanced
Input/Output
12.2.1
GNAT.IO
12.2.2
GNAT.IO_Aux
12.3
Sequential_IO
12.4
Direct_IO
12.5 Formatted
Output
12.6
Calendar Package
12.7 Tags
Package
12.8
Tables
12.8.1 Dynamic
Tables [Not Yet Written]
12.9 Hash
Tables
12.10 Bubble and Heap
Sorts
12.11
Regular Expressions
12.12 Advanced String
Processing
12.13 GLADE
Distributed Processing [not finished]
12.14 Basic Math
Packages
12.15 Exception
Handling and Traceback Packages
12.16
GNAT.Most_Recent_Exception [Not Yet Written]
12.17
GNAT.Exception_Traces Package [Not Yet Written]
12.18 GNAT.CGI
[Not Yet Written]
12.19
GNAT.CGI.Cookies [Not Yet Written]
12.20 GNAT.AWK
[Not Yet Written]
12.21
GNAT.Threads [Not Yet Written]
12.22 GNAT.Expect
[Not Yet Written]
13 Linux
Introduction
13.1 Introduction to
Processes
13.1.1 Parents,
Children and Families
13.1.2 Ownership and
Permissions
13.2 Using System and
OsLib.Spawn
13.3 The Linux
Environment
13.4 Standard C
Libraries
13.5 The Linux
Kernel
13.5.1 Kernel
Calls
13.5.2
Devices
13.5.3 Proc File
System
13.5.4 AudioCD: An
Example Program
13.6 Standard
Input/Output/Error
13.8 Linux Binary
Formats
13.9
Linux Libraries
13.10 Libc5, Libc6
and Upward Compatibility
13.11 Linux
Basics
14 Linux
Programming
14.1 Gnat OS
Library
14.2
Installing Binding Packages
14.3 Catching Linux
Signals
14.3.1
Ada.Interrupts.Signals [Not Yet Written]
14.4 Working with the
Command Line
14.4 Linux Environment
Variables
14.6
GNAT.Directory_Operations Package
14.7 GNAT.Lock_Files
Package
14.8
GNAT.Sockets [Not Yet Written]
15 Free Ada
Bindings
15.1 Using Florist, a
POSIX binding
15.2 Using
Texttools
15.2.1 Installation
15.2.2 Introduction
15.2.3 Package
Overview
15.2.4 Window Overview
15.2.5 Other Useful Window Manager
Subprograms
15.2.6 Alerts
15.2.7 Other Predefined Windows
15.2.8
Control Overview
15.2.9 OS Package
15.2.10 UserIO Overview
15.2.11
Appearance and Keys
15.3 Using Ncurses
[not finished]
15.4 Using GTK+
Widgets [not finished]
15.5 Using Motif
Widgets [not finished]
15.6 Using the TASH
TCL Binding [not finished
15.7 Using the
Mesa/OpenGL Binding [not finished]
15.8 Engine_3D [not
finished]
16 Advanced Linux
Programming
16.1 Writing Your Own
Bindings
16.2 Linux Errors and
Errno
16.3
The Linux Clock
16.3.1 Basic time
functions
16.3.2 Timeval Calls
- Microsecond Accuracy
16.3.3 Functions
Using the tm Record
16.3.4 Time as a
String
16.3.5 Timer
Functions
16.4 Process
Information
16.4.1
Ownership
16.4.2 Other
Functions
16.5 Environment
Variables
16.6
Multitasking
16.7 Linux File
Operations
16.8 Opening and
Closing Files
16.9
Directories
16.10 Stdio
Files
16.11
Stdio Pipes
16.12 Memory
Management
16.13 The Virtual
Consoles
16.14 Making Database
Queries
16.14.1 mySQL [not finished]
16.14.2 PostgreSQL [not
finished]
16.15
Dynamic Loading [not finished]
16.16 A Word on
Device Drivers
16.17 Linux
Sound
16.17.1 Detecting a Sound Card
16.17.2 Playing Sound
Samples
16.17.3 Using the Mixer
16.17.4 Recording Sound Samples [not
finished]
16.18
Audio CDs
16.19 Kernel Pipes
[not finished]
16.20 Shared Memory
[not finished]
16.21 Message Queues
[not finished]
16.22 Semaphores [not
finished]
16.23
Sockets
16.24 Memory
Management
16.25 Exit
Procedures
17 Moving C Programs To
Ada
17.1 c2ada:
Translating Your Programs
17.2 Interfaces.C
package
17.3
Interfaces.C.Pointers package
17.4
Interfaces.C_Streams package
17.5 Ada and C
Files
17.6 A
Word on Interfaces.Fortran
18 Data
Structures
18.1 Using the Booch
Components
18.1.1
Containers
18.1.2
Iterators
18.1.3 Single linked
Lists
18.1.4 Double linked
Lists
18.1.5
Bags
18.1.6
Sets
18.1.7
Collections
18.1.8
Queues
18.1.9
Stacks
18.1.10
Deques
18.1.11
Rings
18.1.12
Maps
18.1.13 Binary
Trees
18.1.14 AVL
Trees
18.1.15 Multiway
Trees
18.1.16
Graphs
18.1.17 Smart
Pointers
18.1.18 Booch
Multithreading
19 Java Byte Code and
Mixing Languages
19.1 Ada Meets
Java
19.1.1 The Java
Virtual Machine
19.1.2 JGNAT
[unfinished]
19.2 ASIS
19.3 Assembly
Language
19.3.1 Pentium
Family Processors
19.3.2 Instruction
Set
19.3.3
Operands
19.3.4
System.Machine_Code.Asm
19.3.5 Other Asm
Flags
19.3.6 A Complete
Example
19.4
Calling Ada from C
19.5 Calling C++ from
Ada
19.6
Calling Ada from C++
19.7 Calling Ada from
Java
20 Developing Your
Project
20.1 The Project
Proposal
20.2 The Design
Phase
20.3
The Development Phase
20.4 The Alpha/Beta
Release
20.5
Releasing Your Software
20.5.1 A Third Party Library
20.6 Distribution
Formats
20.6.1 RPM: Red Hat Package Manager [not finished]
20.6.2 TGZ
Packages
20.6.3 TAR.BZ2 Packages
20.6.4 Other Formats
20.7 Man
Pages
20.8
Linux Software Map Entry
20.9 Licensing
Options
Appendices
Appendix A: The Linux
Shell
Appendix B: Linux Error
Codes
Appendix C: Linux Kernel
Calls
Appendix D:
Signals
Appendix E: Ioctl
parameters
Appendix F: Overview of
Gnat Packages
Glossary