User-Level Native Thread Primitives (GThread) Library White Paper (G06.26+)

User-Level Native Thread Primitives (GThread Library) 03/31/2005
Hewlett-Packard Company--540065-001 Page 10 of 46
The standard dynamic memory-allocation functions on each platform, such as malloc() and
POOL_GETSPACE_(), provide memory blocks suitably aligned for static threads. However, a statically
allocated global stack area requires care to achieve proper alignment:
The alignment of a static stack area, such as an array or structure, is the largest alignment of its
elements. Consequently, on TNS/R native, an array or structure must contain an 8-byte element to
force alignment on an 8-byte boundary. On TNS/E native, a 16-byte fundamental type does not exist
for alignment purposes. Instead, a pragma has been added to C/C++ which indicates maximum
alignment of 16 bytes for the objects to which it refers. For EpTAL a structure attribute has been
added to effect proper alignment. Both the C/C++ pragma and the EpTAL attribute are called
MAXALIGN and are not backwards compatible with TNS/R.
Note that all TNS/E native thread control blocks must be 16-byte aligned. No such requirement exists for
TNS/R.
2.5. Literals and Defines
IF_TNS__(TNS_code, MIPS or IPF native_code)
expands to the text of the first parameter in TNS compilations and the second parameter in 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
native_code
?ENDIF PTAL
IF_TNS_MIPS_IPF__(TNS_code,Mips native_code, IPF native code)
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