Re: -D_REENTRANT



Hi,

> > I noticed that only glib and atk are compiled with -D_REENTRANT. Pango
> > and GTK+ lack this compiler flag and thus do the wrong thing in 
> > threaded environments. This doesn't seem to be a problem with glibc
> > which redefines some symbols if an application is linked against 
> > libpthread but it leads to strange errors with libc implementations
> > that don't have this behaviour.

This definatly has to happen. I wonder, when that disappeared.

> I do not know what compiler you use but the compiler I use do not like
> threading options set by the user. To be threadsafe one should use either
> special compiler version or an appropriate threading switich

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?

> 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`
        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`

Ans both all four GTK+ libs have to be compiled with `pkg-config
--cflags gthread-2.0`. So if it doesn't work for you, we have to fix
GLibs configure.in to find the right flags for doing so. If that however
means using another compiler, we are screwed AFAICT (or rather the use
is screwed)

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi





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