C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
7-9
Memory Models
For more details on TNS C and TAL data types, see Variables and Parameters on
page 7-17.
Memory Models
A TNS C program can use the small-memory model or the large-memory model,
depending on the amount of data storage required. The large-memory model is
recommended and is the default setting. All examples in this subsection illustrate the
large-memory model unless otherwise noted.
A TAL program can use any of these memory combinations, depending on the
application’s needs:
The user data segment
The user data segment and the automatic extended data segment
The user data segment and one or more explicit extended data segments
The user data segment, the automatic extended data segment, and one or more
explicit extended data segments
This table describes some aspects of memory usage by C and TAL programs. The far
right column refers to the upper 32K-word area of the user data segment.
Any TAL module that uses the upper 32K-word area of the user data segment cannot
run within a TNS C object file that contains the main routine.
Data Model
The size of the C data type int is 16 bits in the 16-bit data model and 32 bits in the
32-bit data model. (The 32-bit data model is also called the wide-data model.) If you
specify the 32-bit data model, the C data type int is 32 bits and the TAL data type INT
corresponds to the C data type short.
Any interface to a TAL routine must be specified in such a way that there is no
possibility for a data-length mismatch. Therefore, in your C program, use short for a
16-bit integer and long for a 32-bit integer and avoid the use of int. Using short in
your C program enables you to use the same declarations regardless of the data
model your program uses. The type short is always a 16-bit integer in the C compiler.
Language
Memory
Model Addressing Data Storage
Upper 32K-Word
Area
TNS C Small 16-bit 32K words Reserved
TNS C Large 32-bit 127.5 MB Reserved
TAL Not
applicable
16-bit or 32-bit 64K words (without the
CRE), plus 127.5 MB in
each extended data
segment that is allocated
Reserved only if
you use the CRE