User-Level Native Thread Primitives (GThread) Library White Paper (G06.27+, H06.03+, J06.03+)

User-Level Native Thread Primitives (GThread Library) 02/15/2012
540065-004 Page 10 of 44
expands to the text of the first parameter in TNS compilations, the second parameter in TNS/R native
compilations, and the third parameter in TNS/E native compilations. For short sequences, the macro
may offer more readable source code than equivalent use of the following directives or their C
equivalents:
IFNOT PTAL
TNS_code
?ENDIF PTAL
?IF PTAL
?IF RISC1
MIPS native_code
?ENDIF RISC1
?IF _TNS_E_TARGET
IPF native_code
?ENDIF _TNS_E_TARGET
?ENDIF PTAL
GTHREAD_BYTES(TSize,NSize) evaluates to an INT(32) stack length in bytes. This macro might
help to deal with stack alignment and length architecture requirements: TNS, TNS/R, and TNS/E
stacks differ in terms of stack requirements for the same processing.
INT TSize specifies the TNS stack length in 16-bit words.
INT(32) NSize specifies the native stack length in bytes; it is rounded up to a multiple of 8 for TNS/R
and 16 for TNS/E.
Compile-time selection uses one parameter or the other to compute the length or alignment appropriate
for the current architecture; it is a compile-time constant if TSize and NSize are constant expressions.
GTHREAD_VERSION indicates the version of the GTHREAD_CB_TEMPLATE structures being
used; it must match those with which the GTHREAD procedures were compiled. The first three bytes
are ASCII "GTh".
GTHREAD_CB(id) is a TAL define that declares or specifies
INT .EXT id (GThread_CB_Template)
(In C/C++, GThread_CB_Template is a typedef for a GThread Control Block;
GThread_CB is a typedef for pointer to GThread_CB_Template.)
The following literals define error return values:
GT_OK = 0: All GTHREAD functions that report an error code return 0 upon successful completion.
GT_BAD_VERSION: The client program was compiled with a different data-structure version than
the GThread primitive procedures.
GT_BAD_ORIGIN: GTHREAD_ORIGIN_SET_ or GTHREAD_ORIGIN_SET_MOD_ found
MainCB.StackOrigin not at its initial value. When the swapped master protocol is coded as
sketched in Section 3.2
this error indicates that the unthreaded master stack is now deeper
than initially.