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-28
Extended Data Segments
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_.
4. If the automatic extended data segment is already in place, SEGMENT_USE_
returns the automatic extended data segment’s number. Save this number so you
can later access the automatic extended data segment again.
5. C requires special treatment for SEGMENT_USE_, which returns a value and sets
the condition code.
6. You must keep track of addresses stored in extended pointers. When storing
addresses into subsequent pointers, you must allow space for preceding data
items.
7. To refer to data in the current segment, call READX or WRITEX.
8. To move data between explicit extended data segments, call MOVEX.
9. To manage large blocks of memory, call DEFINEPOOL, GETPOOL, and
PUTPOOL.
10. To determine the size of a segment, call SEGMENT_GETINFO_.
11. To access data in the automatic extended data segment, call SEGMENT_USE_
and restore the segment number that you saved at step 4.
12. To delete an explicit extended data segment that you no longer need, call
SEGMENT_DEALLOCATE_.
For information on using these system procedures, see the Guardian Programmer's
Guide and the Guardian Procedure Calls Reference Manual.
If you do not restore the automatic extended data segment before you manipulate data
in it, any of the following actions can result:
•
An assignment statement is beyond the segment’s memory limit and causes a trap.
•
All assignments within range occur in the hardware base and limit registers of the
automatic extended segment. Data in the currently active extended data segment
is overwritten. The error is undetected until you discover the discrepancy at a later
time.
•
The TNS C code runs until it accesses an invalid address or accesses an
inaccessible library routine.
•
You get the wrong data from valid addresses in the explicit extended data
segment.