[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] gpsd fails to build on mac 10.7
From: |
Eric S. Raymond |
Subject: |
Re: [gpsd-dev] gpsd fails to build on mac 10.7 |
Date: |
Tue, 5 Nov 2013 21:02:34 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Greg Troxel <address@hidden>:
> So it seems the immediate fix is that barrier() should just be defined
> as a no-op if there isn't compiler-specific fix.
Current code could certainly stand to be cleaned up a little:
#ifndef S_SPLINT_S
#if defined(NTPSHM_ENABLE) || defined(SHM_EXPORT_ENABLE)
/* memory barriers */
static /address@hidden@*/ inline void barrier(void) {
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
__atomic_thread_fence(__ATOMIC_SEQ_CST);
#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
__sync_synchronize();
#else
# error Memory barriers are not supported. Disable NTPSHM and SHM export.
#endif /* defined(NTPSHM_ENABLE) || defined(SHM_EXPORT_ENABLE) */
#endif /* defined(NTPSHM_ENABLE) || defined(SHM_EXPORT_ENABLE) */
#else
#define barrier()
#endif /* S_SPLINT_S */
Maybe this would be better?
/* memory barriers */
static /address@hidden@*/ inline void barrier(void)
{
#ifndef S_SPLINT_S
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
__atomic_thread_fence(__ATOMIC_SEQ_CST);
#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
__sync_synchronize();
#endif
#endif /* S_SPLINT_S */
}
> Has anyone actually seen a bug due to missing barriers? (I get the
> theory.)
I haven't. But I don't view that as determinative; they could show up
as data corruption subtle enough to be hard to detect.
> What is one supposed to do while complying with C99 and POSIX? Relying
> on gcc extensions is very 00s.
I know, but I think it's better to quietly use these if present than
to ignore them.
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
signature.asc
Description: Digital signature