Re: -D_REENTRANT



On Thu, Mar 14, 2002 at 03:45:47PM +0100, Sebastian Wilhelmi wrote:
> You have to compile libraries with some special options (either
> -D_REENTRANT or -DTHREAD_SAFE or sometimes -pthread) to make it use a
> thread safe errno (as the most important difference), the library still
> can be used singlethreaded at the users wish.
> 
> > gcc: -pthread option
> > Sun Forte: -mt option
> > DEC C/CXX:
> > 	- dce threads: use -threads option
> > 	- posix (d7) threads: use -pthread option
> > IBM xlc/xlC family
> > 	- no threads: use xlc or xlC compiler
> > 	- dce threads: use xlc_r4 or xlC_r4
> > 	- posix (d7) threads: use xlc_r or / xlC_r
> 
> So how do you compile thread safe libraries there (not link), which can
> be used single and multithreaded?
with the options -pthread/-mt or xlc_r for the four compiler above.
no -Dsomething no -lsomelib

mixing DCE and not DCE code can cause strange results (DCE changes semantic of
many system calls)

> > After Sun Forte / IBM xlc / DEC Manuals threading is the busines of the
> > compiler. So dirctly defining threading features as _REENTRANT or linking thread
> > or c libraries like -lc_r or -lpthread is not allowed and can cause serioius
> > problems.
> 
> As said, there are two distinct problems:
> 
>         1. Compile code, which can be potentially linked against
>            multithreaded code, the flags for that have to be returned by
>            `pkg-config --cflags gthread-2.0`
yes
>         2. Link code to the multithread libc (if different from the
>            singlethreaded one) and to the native thread librray, the
>            flags for that have to be returned by `pkg-config --libs
>            gthread-2.0`
your right

Regards
-- 
Miroslaw Dobrzanski-Neumann

MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]