Re: [HACKERS] New s_lock.h fails on HPUX with gcc

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] New s_lock.h fails on HPUX with gcc
Date: 1998-07-18 14:50:54
Message-ID: 199807181450.KAA09151@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> ... because the conditional structure assumes that pgsql will only be
> built with non-gcc compilers on HPUX.
>
> This is an entirely bogus assumption not only for HPUX, but for any
> other architecture that has gcc available.
>
> To be able to compile, I just duplicated the "#if defined(__hpux)"
> block into the "#if defined(__GNUC__)" part of the file, but that's
> a pretty grotty hack. I think that the right way to structure the
> file is just this:
>
>
> #if defined(HAS_TEST_AND_SET)
>
> #if defined(somearchitecture)
>
> #if defined(__GNUC__)
> // inline definition of tas here
> #else
> // non-inline definition of tas here, if default isn't adequate
> #endif
>
> // machine-dependent-but-compiler-independent definitions here
>
> #endif /* somearchitecture */
>
> // ... repeat above structure for each architecture supported ...
>
>
> #if !defined(S_LOCK)
> // default definition of S_LOCK
> #endif
>
> // default definitions of other macros done in the same way
>
> #endif /* HAS_TEST_AND_SET */
>
>
> On architectures where we don't have any special inline code for GCC,
> the inner "#if defined(__GNUC__)" can just be omitted in that
> architecture's block.
>
> The existing arrangement with an outer "#if defined(__GNUC__)" doesn't
> have any obvious benefit, and it encourages missed cases like this one.
>
>
> BTW, I'd suggest making the definition of clear_lock for HPUX be
>
> static const slock_t clear_lock =
> {{-1, -1, -1, -1}};
>
> The extra braces are needed to suppress warnings from gcc, and declaring
> it const just seems like good practice.
>
> regards, tom lane
>
>

Patch applied. I just moved hpux out of the gcc/nogcc ifdef, so it
always gets hit. Also changed the clear_lock stuff.

--
Bruce Momjian | 830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-07-18 14:59:10 Re: [HACKERS] New s_lock.h fails on HPUX with gcc
Previous Message Bruce Momjian 1998-07-18 14:44:29 Rel structure renamed