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/includeANSI_FLAGS = -D_POSIX_SOURCE -D_POSIX_D10_THREADSMPE_FLAGS = -D_MPEXL_SOURCE -D_MPE_THREADS -DMPEXLCFLAGS = ${ANSI_FLAGS} ${DEBUG} ${MPE_FLAGS} ${INCENV}#LIBS = -lsocket -lsvipc -lmXL = /lib/libdce.sl, /lib/libpthread.sl, /lib/libc.slPROGRAMS = server clientserver_OFILES = manager.o server.o sleeper_sstub.oclient_OFILES = sleeper_cstub.o client.oIDLFLAGS = -keep c_source ${INCENV}IDLFILES = sleeper.idlIDLGEN = sleeper.h sleeper_*stub.cIDL = /SYS/HPBIN/SH /usr/bin/idl#IDL = /SYS/PUB/IDLall: objects ${PROGRAMS} |
 |
 |
 |
 |
objects: ${server_OFILES} ${client_OFILES}fresh: clean allclean: @-rm $(IDLGEN) $(server_OFILES) $(client_OFILES) $(PROGRAMS)server: ${server_OFILES} ar -rc server.obj ${server_OFILES} callci linkedit \" 'link from=/SYS/PUB/STARTO, /Speedware/sleeper/server.obj;\ to=/Speedware/sleeper/server;xl=${XL};posix;share'\"client: ${client_OFILES} ar -rc client.obj ${client_OFILES} callci linkedit \" 'link from=/SYS/PUB/STARTO, /Speedware/sleeper/client.obj;\ to=/Speedware/sleeper/client;xl=${XL};posix;share'\"sleeper.h: ${IDLFILES} $(IDL) ${IDLFLAGS} ${IDLFILES}sleeper_cstub.o sleeper_sstub.o manager.o server.o client.o: sleeper.h |