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-28
Extended Data Segments
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 these 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.
In this example, a large-memory-model TNS C routine calls a TAL routine that
manipulates data in an explicit extended data segment and then restores the automatic