Date: 02 Jul 1998 09:32:01 +0200 From: smoergrd@oslo.geco-prakla.slb.com (Dag-Erling Coidan Smørgrav) To: Joe Abley <jabley@clear.co.nz> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: pthreads Message-ID: <rx4g1gk4sjy.fsf@oslo.geco-prakla.slb.com> In-Reply-To: Joe Abley's message of Thu, 2 Jul 1998 08:09:39 %2B1200 (NZST) References: <Pine.BSF.3.96.980702080311.2083A-100000@buddha.clear.net.nz>
next in thread | previous in thread | raw e-mail | index | archive | help
Joe Abley <jabley@clear.co.nz> writes: > 1. On Solaris, to compile a pthreaded program, I stick a > > #define _REENTRANT > #include <pthread.h> > > 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 <pthread.h> #include <thread.h> /* 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?rx4g1gk4sjy.fsf>