This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please


thank you very much,
would you please explain the following flags for me ?

_THREAD_SAFE
_SGI_MP_SOURCE
_IO_MTSAFE_IO
_GNU_SOURCE
_POSIX_SOURCE
_SOCKET_SOURCE

i saw them in Berkeley Db's configure.in the context is:

case "$host_os" in
aix4.*)    optimize_def="-O2"
           CC=${CC-"xlc_r"}
           CPPFLAGS="-D_THREAD_SAFE $CPPFLAGS"
           LIBTSO_LIBS="\$(LIBS)";;
bsdi3*)    CC=${CC-"shlicc2"}
           optimize_def="-O2"
           LIBS="-lipc $LIBS";;
bsdi*)     optimize_def="-O2";;
freebsd*)  optimize_def="-O2"
           CPPFLAGS="-D_THREAD_SAFE $CPPFLAGS"
           LIBS="-pthread";;
hpux*)     CPPFLAGS="-D_REENTRANT $CPPFLAGS";;
irix*)     optimize_def="-O2"
           CPPFLAGS="-D_SGI_MP_SOURCE $CPPFLAGS";;
linux*)    optimize_def="-O2"
           CFLAGS="-D_GNU_SOURCE"
           CPPFLAGS="-D_IO_MTSAFE_IO -D_REENTRANT $CPPFLAGS";;
mpeix*)    CPPFLAGS="-D_POSIX_SOURCE -D_SOCKET_SOURCE $CPPFLAGS"
           LIBS="-lsocket -lsvipc $LIBS";;
osf*)      CPPFLAGS="-D_REENTRANT $CPPFLAGS";;
# *qnx)    AC_DEFINE(HAVE_QNX);;
sco3.2v4*) CC=${CC-"cc -belf"}
           LIBS="-lsocket -lnsl_s $LIBS";;
sco*)      CC=${CC-"cc -belf"}
           LIBS="-lsocket -lnsl $LIBS";;
solaris*)  CPPFLAGS="-D_REENTRANT -D_PTHREADS $CPPFLAGS";;
esac

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Rupert Wood
Sent: Wednesday, December 19, 2001 3:44 PM
To: 'PeterPan'
Cc: gcc-help@gcc.gnu.org
Subject: RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith
pthread, please


PeterPan wrote:

> what is the real meaning of --enable-threads=LIB ?

It specifies which threading model should be used by the threading
abstraction in <bits/gthr.h>. This is used by two of GCC's support
libraries. I'm not sure if it's intended for general use - I don't think
it's documented in the manual.

> SHOULD I DEFINE ANY FLAGS MYSELF IN ORDER TO USE THREADS CORRECTLY,
> IF I SHOULD, WHICH FLAGS ?? HOW ??

I think so. If you're using pthreads, you'll need to define '_REENTRANT'
to get thread safe versions of errno, etc., and presumably '_PTHREADS'
(although I haven't seen that one before). You'll also need to link
against libpthread or you'll get the stubbed out versions from the
Solaris libc that just return failure.

To do this, e.g.

    gcc -D_PTHREADS -D_REENTRANT source.c -lpthread

See 'man threads' on Solaris. The Sun compiler switch '-mt', however, is
not supported by GCC: this causes the Sun compiler to define
'_REENTRANT' and enable (AFAIK) Solaris threads support.

> On a solaris x86, using POSIX pthreads (not Solaris threads),
> which LIB should I use? "--enable-threads=solaris"
> or "--enable-threads=posix", and any extra FLAGS??

For pthreads, "--enable-threads=posix" or "--enable-threads=pthreads".
No extra flags at compiler configure/build.

> thirdly, how about AIX ?? I have written a email ( using my old
> email address peterpan@chinaren-inc.com) to say can't configure
> correct thread mode on AIX, u guys  simply ignored me.

It happens. The serious developers don't have time to answer questions
on this list so it's left to we less knowledgeable few. I've never
touched AIX.

If you're really stuck you could try writing to the development list,
gcc@gcc.gnu.org. Keep it short and to the point and mention that you've
had no luck on gcc-help. You might still get ignored, though.

Hope this helps,
Rup.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]