Re: [PATCHES] Reorganization of spinlock defines

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Reorganization of spinlock defines
Date: 2003-09-12 15:28:48
Message-ID: 200309121528.h8CFSmN22002@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > He is uncomfortable with the port/*.h changes at this point, so it seems
> > I am going to have to add Itanium/Opteron tests to most of those files.
>
> Why don't you try to put together a proposed patch of that kind, and
> then we can look to see how big and ugly it is compared to the other?
> If the alternative is shown to be really messy, that would sway my
> opinion, maybe Marc's too.

OK, here is an Opteron/Itanium patch that might work. I say "might"
because I don't have a lot of confidence in the current spinlock
detection code. There is an uncoupling between the definition of
HAS_TEST_AND_SET, the data type used by slock_t, and the assembler code.

For example, here is darwin.h:

#if defined(__ppc__)
#define HAS_TEST_AND_SET
#endif

#if defined(__ppc__)
typedef unsigned int slock_t;

#else
typedef unsigned char slock_t;

#endif

Does this say that Darwin on something other than PPC doesn't have
spinlocks? Is that going to hit a spinlock define, or fall through?

Also, look at NEED_I386_TAS_ASM: It is used only by SCO compilers,
though it is defined for all Intel platforms. The s_lock.h gcc test
already tests __i386__. It really doesn't do anything on non-SCO
compilers, and non-SCO compilers are better testing for i386 anyway.

Also, Solaris has just this:

#define HAS_TEST_AND_SET
typedef unsigned char slock_t;

How do they know what CPU is being used? Both Sparc and i386 use
"unsigned char", so I guess it is OK, but I think you can see what I
mean when I say I don't have a lot of confidence in what we have now.

Let me also add that some slock_t typedef's didn't match the assembly
code. For example, __alpha_ on netbsd.h had slock_t defined as
"unsigned long", while in linux.h it was "long int". I assumed the
alpha was the correct one, but clearly they should be the same because
they use the same assembly code.

See what I mean.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 4.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-09-12 15:33:30 Re: massive quotes?
Previous Message Tom Lane 2003-09-12 15:20:44 Re: massive quotes?

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2003-09-12 15:38:31 Re: [PATCHES] Reorganization of spinlock defines
Previous Message Bruce Momjian 2003-09-12 14:59:31 Re: __cpu__ defines