Guardian Procedure Calls Reference Manual

Condition Code Settings
indicates that segment-id is not allocated, or that the segment cannot be used by a nonprivileged
caller.
< (CCL)
indicates that the operation is successful.= (CCE)
does not return from USESEGMENT.> (CCG)
Returned Value
INT
Segment ID of the previously used selectable segment, if any; otherwise, -1.
If segment-id specifies a flat segment, old-segment-id returns the segment ID of the current
in-use selectable segment. The flat segment and the selectable segment remain addressable by the
calling process.
Considerations
Because segment relocation is done, the first byte of any selectable extended data segment
has the address %2000000D (%H00080000).
Selectable segments and performance
If you have more than one selectable segment, you might face performance degradation,
because time is wasted when switching between the selectable segments. This is because only
one selectable segment is visible at a time. Instead, use flat segments, which are always visible.
See the ALLOCATESEGMENT procedure Considerations (page 62) .
Example
INT seg^id1 := 0;
INT seg^id2 := 1;
INT old^seg^id;
INT status;
INT(32) seg^len := %177777D; ! 64K - 1 bytes
status := ALLOCATESEGMENT ( seg^id1, seg^len );
IF status <> 0 THEN ...
status := ALLOCATESEGMENT ( seg^id2, seg^len );
IF status <> 0 THEN ...
old^seg^id := USESEGMENT ( seg^id1 ); ! use first segment
IF <> THEN ...
old^seg^id := USESEGMENT ( seg^id2 ); ! change segments
IF <> THEN ...
USESEGMENT Procedure (Superseded by SEGMENT_USE_ Procedure) 1481