DCE for the HP e3000 (B3821-90003)

72 Chapter7
Programming with RPC 1.2.1 on MPE/iX
Compiling Multithreaded Application
Compiling Multithreaded Application
There are some new preprocessing directives that has been introduced
to compile with latest Pthread implementation.
_POSIX_SOURCE: This needs to be used when compiling any DCE
application. It is not necessary when compiling threads-only
application.
_MPE_THREADS: This is used when compiling any DCE or
multithreaded application. This directive is used to set the thread
specific errno.
Applications should ensure that they link /lib/libpthread.sl before
/lib/libc.sl to ensure that they invoke the thread-safe versions of
these C runtime. Applications should not use the c89 linking feature
directly since it binds the C routines to /lib/libc.a before
/lib/libpthread.sl. Since we are binding to /lib/libc.sl, we need
to explicitly link the program object file(s) with the loader “start”
routine.
The following makefile will provide an example of the linking process.
DEBUG = -gINCENV = -I. -I/usr/include
ANSI_FLAGS = -D_POSIX_SOURCE -D_POSIX_D10_THREADS
MPE_FLAGS = -D_MPEXL_SOURCE -D_MPE_THREADS -DMPEXL
CFLAGS = ${ANSI_FLAGS} ${DEBUG} ${MPE_FLAGS} ${INCENV}
#LIBS = -lsocket -lsvipc -lm
XL = /lib/libdce.sl, /lib/libpthread.sl, /lib/libc.sl
PROGRAMS = server client
server_OFILES = manager.o server.o sleeper_sstub.o
client_OFILES = sleeper_cstub.o client.o
IDLFLAGS = -keep c_source ${INCENV}
IDLFILES = sleeper.idl