Open System Services Programmer's Guide

Preprocessor Directives Automatically Map Standard System Calls to Thread-Aware
or Nonblocking Thread-Aware System Calls
When you use preprocessor directives when compiling the application, standard system calls are
automatically mapped to the appropriate Standard POSIX Thread system call, eliminating the need
to explicitly call spt_*(), spt_*x(), or spt_*z() functions. Using preprocessor directives is
preferred to using explicit calls to thread-aware or nonblocking thread-aware functions.
HP highly recommends using only one of these preprocessor directive sets in an application:
#define SPT_THREAD_AWARE
#define SPT_THREAD_AWARE_PRAGMA
#define SPT_THREAD_AWARE_NONBLOCK
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK
#define SPT_THREAD_AWARE_XNONBLOCK
#define SPT_THREAD_AWARE_PRAGMA_XNONBLOCK
Mixing modules compiled with different preprocessor directive sets or compiled without preprocessor
directives related to thread-aware behavior in an application might cause unexpected results. For
more information, see “The spt_*z() Set of Functions Must Be Used Together” (page 348).
This table summarizes the behaviors for each of these preprocessor directives for non-regular and
for regular files:
Behavior for Regular File
Descriptors
Behavior for Non-Regular File
Descriptors
Preprocessor Directive
Process-blocking operations
for all file descriptors
Thread-aware operations for
nonblocking file descriptors
#define SPT_THREAD_AWARE or
#define SPT_THREAD_AWARE_PRAGMA
Process-blocking operations
for blocking file descriptors
Process-blocking operations
for all file descriptors
Nonblocking thread-aware
operations for nonblocking
file descriptors
#define SPT_THREAD_AWARE_NONBLOCK or
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK
Thread-aware operations for
all file descriptors
Thread-aware operations for
blocking file descriptors
#define SPT_THREAD_AWARE_XNONBLOCK or
#define SPT_THREAD_AWARE_PRAGMA_XNONBLOCK
Defining Thread-Aware Functions for Non-Regular Files
For C applications, a macro to map interface() to spt_interface() is available when you
use the #define SPT_THREAD_AWARE preprocessor directive before including spthread.h
or when you use an equivalent compiler command option to compile the application.
For C++ applications, an alias to map interface() to spt_interface() is available when
you use the #define SPT_THREAD_AWARE_PRAGMA preprocessor directive before including
spthread.h or when you use an equivalent compiler command option to compile the application.
The following example illustrates using the SPT_THREAD_AWARE_PRAGMA define:
#define SPT_THREAD_AWARE_PRAGMA
#include <iostream.h> nolist
#include <spthread.h> nolist
int main()
...
For information about including a preprocessor directive in an application by specifying the directive
in a compiler command option, see the c89(1) or the c99(1) reference page online or in the
Open System Services Shell and Utilities Reference Manual.
Applications can explicitly call the functions listed in the Thread-Aware Functions (Non-Regular
Files Only) column of Table 59 (page 344) without setting any defines before including the
spthread.h header file.
346 Using the Standard POSIX Threads Library