Re: What's the effect of #define _REENTRANT
- From: David Hopwood <david.nospam.hopwood@xxxxxxxxxxxxxxxx>
- Date: Sat, 02 Sep 2006 16:23:40 GMT
Mark wrote:
I was reading this tutorial at
http://vergil.chemistry.gatech.edu/resources/programming/threads.html
and the author writes that posix thread coding requires you must
set:
"1. add #include <pthread.h> in your .c or .h header file(s)
2. define the #define _REENTRANT macro somewhere in a common .h or .c file
3. In your Makefile make sure gcc links against -lpthread
4. Optional: add -D_POSIX_PTHREAD_SEMANTICS to your Makefile (gcc flag) for
certain function calls like sigwait()"
I've read many statements on the internet and many are
conflicting about whether _REENTRANT is needed or what.
I'm using solaris 9 X86 with GCC 3.3
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20705>
As the bug report says, -pthread (and #include <pthread.h>) *should* be
sufficient to portably enable pthreads when using gcc, but it isn't. If
you're using autoconf, the macro linked to from the report can be used as
a workaround. Otherwise you have to know the particular incantation for
your platform, and every platform is different.
For Solaris, see also
<http://gcc.gnu.org/ml/gcc/2001-06/msg01589.html> and
<http://archives.postgresql.org/pgsql-general/2004-03/msg01094.php>.
I was curious as to what the symptoms are of posix threaded
code not using reentrant functions when it should.
Undefined behaviour.
--
David Hopwood <david.nospam.hopwood@xxxxxxxxxxxxxxxx>
.
- References:
- What's the effect of #define _REENTRANT
- From: Mark
- What's the effect of #define _REENTRANT
- Prev by Date: Re: How to gracefully (programmatically) kill an app?
- Next by Date: Re: Help me regarding hybrid threads
- Previous by thread: Re: What's the effect of #define _REENTRANT
- Next by thread: Re: What's the effect of #define _REENTRANT
- Index(es):
Relevant Pages
|