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

Bruce Momjian <maillist@candle.pha.pa.us>

From: Bruce Momjian <maillist@candle.pha.pa.us>
To: tgl@sss.pgh.pa.us (Tom Lane)
Cc: pgsql-hackers@postgreSQL.org
Date: 1998-07-18T14:50:54Z
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@candle.pha.pa.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)