From owner-freebsd-hackers Thu Jul 2 00:32:38 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id AAA22779 for freebsd-hackers-outgoing; Thu, 2 Jul 1998 00:32:38 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from oslo.geco-prakla.slb.com (geos01.oslo.geco-prakla.slb.com [134.32.44.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA22771 for ; Thu, 2 Jul 1998 00:32:35 -0700 (PDT) (envelope-from smoergrd@geos01.oslo.geco-prakla.slb.com) Received: from sunw132.geco-prakla.slb.com (sunw132 [134.32.45.120]) by oslo.geco-prakla.slb.com (8.8.8/8.6.9) with SMTP id JAA14034 ; Thu, 2 Jul 1998 09:32:04 +0200 (MET DST) Received: by sunw132.geco-prakla.slb.com (SMI-8.6/SMI-SVR4) id JAA07482; Thu, 2 Jul 1998 09:32:03 +0200 To: Joe Abley Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: pthreads References: Organization: Schlumberger Geco-Prakla X-Disclaimer: I speak only for myself. From: smoergrd@oslo.geco-prakla.slb.com (Dag-Erling Coidan Smørgrav) Date: 02 Jul 1998 09:32:01 +0200 In-Reply-To: Joe Abley's message of Thu, 2 Jul 1998 08:09:39 +1200 (NZST) Message-ID: Lines: 45 X-Mailer: Gnus v5.3/Emacs 19.34 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Joe Abley writes: > 1. On Solaris, to compile a pthreaded program, I stick a > > #define _REENTRANT > #include > > at the top of the source files, and link with -lpthread. Oh no you don't, unless you have an old Solaris or an old compiler. I know the man pages tell you to do this, but the man pages are wrong... You should just #include #include /* if you want to use Solaris threads */ and compile with -mt. The compiler will define _REENTRANT itself, and pass the correct arguments to ld. A very good reason *not* to define _REENTRANT yourself is that you can catch incorrect compilation: #ifndef _REENTRANT #error "This program needs to be compiled with the -mt option" #endif or even write your application in such a manner that it works without threads, using #ifdef _REENTRANT / #else / #endif For the record, I use the WorkShop Compilers 4.2 cc, dated 30 Oct 1996, on Solaris 2.5 and 2.6. BTW, the Solaris thread implementation has a very nice feature which POSIX threads lack: the ability to wait on all threads in one call, like this: while(thr_join(NULL, NULL, NULL) == 0) /* nothing */ ; This will block until all other threads terminate. Could there be some loophole in the POSIX spec which would allow us to implement something similar? DES -- Dag-Erling Smørgrav - smoergrd@oslo.geco-prakla.slb.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message