public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please
       [not found] <616BE6A276E3714788D2AC35C40CD18D29DBAD@whale.softwire.co.uk>
@ 2001-12-18 23:44 ` Rupert Wood
  2001-12-19 18:38   ` PeterPan
  0 siblings, 1 reply; 3+ messages in thread
From: Rupert Wood @ 2001-12-18 23:44 UTC (permalink / raw)
  To: 'PeterPan'; +Cc: gcc-help

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please
  2001-12-18 23:44 ` HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please Rupert Wood
@ 2001-12-19 18:38   ` PeterPan
  0 siblings, 0 replies; 3+ messages in thread
From: PeterPan @ 2001-12-19 18:38 UTC (permalink / raw)
  To: Rupert Wood; +Cc: gcc-help

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please
@ 2001-12-18 19:27 PeterPan
  0 siblings, 0 replies; 3+ messages in thread
From: PeterPan @ 2001-12-18 19:27 UTC (permalink / raw)
  To: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1475 bytes --]

I'm totally puzzled with gcc-3.0.x.

what is the real meaning of --enable-threads=LIB ?
do gcc/g++ use the correct FLAGS and/or link the correct library
automatically ? it should, why not?
but i didn't see gcc define the correct FLAGS, for example stl_config.h say:
// User-settable macros that control compilation:
...
// * _PTHREADS: if defined, use Posix threads for multithreading support.
// * _UITHREADS:if defined, use SCO/Solaris/UI threads for multithreading
...

but when I use a g++ configured with --enable-threads=solaris to compile a
test program, it result
that none of _PTHREADS or _UITHREADS defined .

THEN WHAT DOES --enable-threads=LIB MEAN ?? SHOULD I DEFINE ANY FLAGS MYSELF
IN ORDER
TO USE THREADS CORRECTLY, IF I SHOULD, WHICH FLAGS ?? HOW ??

this is the first question, the second one:

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

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. the only feedback i got is from poor
Pavel Ganelin <pganelin@marketswitch.com>. he said: "I saw you post in
USENET. Did you get any answer.
I have the same problem."

ANSWER ME!! HELP ME!!! THANK YOU!!!

---------------------------------------------------------
¹ùÑ©ËÉ
Guo Xuesong
ËѺü¹«Ë¾
Sohu-inc


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-12-20  2:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <616BE6A276E3714788D2AC35C40CD18D29DBAD@whale.softwire.co.uk>
2001-12-18 23:44 ` HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please Rupert Wood
2001-12-19 18:38   ` PeterPan
2001-12-18 19:27 PeterPan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).