Re: enable thready safety on Mac OS X 10.3.4

From: <wespvp(at)syntegra(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Keary Suska <hierophant(at)pcisys(dot)net>, Postgres General <pgsql-general(at)postgresql(dot)org>, Aaron Burghardt <aburgh(at)mac(dot)com>
Subject: Re: enable thready safety on Mac OS X 10.3.4
Date: 2004-07-08 05:07:44
Message-ID: BD1240D0.EFB3%wespvp@syntegra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/5/04 11:06 PM, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:

> The thread testing in 7.5 is dramatically different from 7.4 and can't
> be backpatched. What should I add to template/darwin for 7.4.4?

> I added these two lines:
>
> THREAD_SUPPORT=yes
> NEED_REENTRANT_FUNCS=no

I don't think this is safe. What I've been using since 7.4.1/Mac OS X 10.3
is:

# Apple's cpp-precomp seems a tad broken, so don't use it
# (Note: on OS X before 10.2, you might need -traditional-cpp instead)
CC="$CC -no-cpp-precomp"

# Select appropriate semaphore support
USE_NAMED_POSIX_SEMAPHORES=1

# tools/thread/thread_test must be run
THREAD_SUPPORT=yes
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"

NEED_REENTRANT_FUNCS=yes

It appears with OS X 10.3.4, the THREAD_LIBS="-lpthread" is no longer
necessary (or is it due to PostgreSQL 7.3.4?). Previously it would not
build without this. With 7.3.4 and OS X 10.3.4, it will build with or
without it. I think -lpthread was required with OS X 10.2 (Jaguar).

I don't recall why -D_POSIX_PTHREAD_SEMANTICS was needed.

If I run thread_test many times, I get inconsistent results. I get both:

All your non-*_r functions are thread-safe.
Add this to your template/$port file:

NEED_REENTRANT_FUNCS=no

and:

Your gethostbyname() is _not_ thread-safe
Not all non-*_r functions are thread-safe.
Add this to your template/$port file:

NEED_REENTRANT_FUNCS=yes

Thus, to be safe I believe 'NEED_REENTRANT_FUNCS=yes' should be specified.
If I remember right from earlier discussions, the '-D_REENTRANT' *is*
required to insure errno is handled properly in a threaded environment.

See also the thread 'thread_test.c problems' back in of April. This was the
last entry from you on the subject:

> OK, CVS is ready. I unconditionally defined:
>
> -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS
>
> for all ports. It can't hurt if they are not supported, but it makes
> our job easier for porting. It allowed me to remove almost all the
> port-specific thread stuff. The other tests are done by configure and
> thread_test.
>
> Should fix Darwin compile and other platforms without mucking with the
> thread detection code.

Wes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alberto Cabello Sanchez 2004-07-08 06:23:26 Re: Column name 'user' not allowed?
Previous Message Reuben D. Budiardja 2004-07-08 03:58:15 Client lib compatibility v. 7.2, 7.3 and 7.4