C/C++ Programmer's Guide (G06.25+)
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
7-27
Extended Data Segments
/* a parameter to TAL_PROC */
}
When you pass a large-memory-model TNS C routine as a parameter, the compiler
passes a 32-bit address that contains PEP and map information in the high-order word
and a zero in the low-order word. When you pass a small-memory-model TNS C
routine as a parameter, the compiler passes a 16-bit address that contains PEP and
map information.
Extended Data Segments
In addition to the user data segment, you can store data in:
•
The automatic extended data segment
•
One or more explicit extended data segments
You should use only the automatic extended data segment if possible. You should not
mix the two approaches. If you must use explicit segments and the automatic segment,
however, follow guidelines 4 and 11 in Explicit Extended Data Segments on page 7-27.
Automatic Extended Data Segment
The TAL compiler allocates the automatic extended data segment when a TAL
program declares arrays or structures that have extended indirection.
The TNS C compiler allocates the automatic extended data segment for all large-
memory-model modules.
Explicit Extended Data Segments
TAL modules and large-memory-model TNS C modules can allocate and deallocate
extended data segments explicitly. Since the advent of the automatic extended data
segment, however, programs usually need not use explicit extended data segments.
The information in this subsection is provided to support existing programs.
To create and use an explicit extended segment, you call system procedures. You can
allocate and manage as many explicit extended segments as you need, but you can
use only one explicit extended segment at a time. You can access data in an explicit
extended segment only by using extended pointers. The compiler allocates memory
space for the extended pointers you declare. You must manage allocation of the data
yourself.
Note. There are two types of extended data segments: flat segments and selectable
segments. This section uses the term “extended data segment” to refer to a selectable
segment. It does not describe flat segments, although much of the information is the same for
flat segments. Flat segments provide many benefits over selectable segments. Flat segments
are easier to program, provide better performance, and allow access to more virtual memory
than selectable segments. For information on using flat segments, see the Guardian
Programmer’s Guide.