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-27
Extended Data Segments
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.
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.
Here are guidelines for using explicit extended data segments:
1. Declare an extended pointer for the base address of the explicit extended
segment.
2. To allocate an explicit extended data segment and obtain the segment base
address, call SEGMENT_ALLOCATE_.
3. To make the explicit extended segment the current segment, call
SEGMENT_USE_.
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
Programmers Guide.