Re: What's the effect of #define _REENTRANT



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



Relevant Pages

  • Re: Make problem Building 64 bit Perl 5.8.8 from source on Solaris 10 with gcc 3.4.6
    ... my other email saying that an update to GCC was not crucial. ... Built under solaris ... The Perl configured above failed 4 tests, ... compiler or make any changes to the system directories. ...
    (perl.dbi.users)
  • Re: stdout not open?
    ... Or at least a sun directory. ... > and we're using solaris 2.8. ... because the Solaris 8 libraries have the exact same APIs ... Also, you mentioned that you're using gcc, and I ...
    (comp.lang.c)
  • Re: which libc used by gcc (and matlab)
    ... > normally use the libc built into Solaris. ... for any unix-based gcc? ... GNU CPP version 3.2.1 ...
    (comp.unix.solaris)
  • Re: which libc used by gcc (and matlab)
    ... > normally use the libc built into Solaris. ... for any unix-based gcc? ... GNU CPP version 3.2.1 ...
    (comp.unix.programmer)
  • Compile OpenSSL/GCC with -fomit-frame-pointer ?
    ... Solaris 8 64bit UltraSparc with gcc 3.2.2 ... I'm only surprised because I interpret the '27' as the version of gcc - ... Don't keep the frame pointer in a register for functions that don't need ... It also makes debugging impossible on some machines. ...
    (comp.unix.solaris)