On December 30, 2016 4:48:22 PM GMT+01:00, Tom Lane <t...@sss.pgh.pa.us> wrote: >Andres Freund <and...@anarazel.de> writes: >> On 2016-12-30 00:44:33 -0500, Tom Lane wrote: >>> Perhaps it could be argued that there's a FreeBSD compiler bug here, >>> but what I'm wondering is why configure believes that this: >>> >>> [char lock = 0; >>> __sync_lock_test_and_set(&lock, 1); >>> __sync_lock_release(&lock);])], >>> >>> is going to draw a hard error on platforms without byte-wide >atomics. >>> My sense of C semantics is that the best you could hope for is a >>> warning > >> Well, in theory these aren't actual functions but intrinsics with >> special behaviour ("by being overloaded so that they work on multiple >> types."). The compiler is supposed to warn and link to an external >> function if a certain operation is not available: > >Yeah, I read that. But configure tests don't normally notice warnings.
IIRC those functions are *not* supposed to be provided, I.e. they should result in a linker error. BTW, it's unclear why there's no 1 byte atomics support in that compiler, isn't it? On a ll/sc arch like ppc it should (and IIRC is) be supported efficiently. As you suggest, using a lwarx should just work. > I'm not very good at reading PPC assembler, but I think what is happening in the "char" case is that gcc is trying to emulate a byte-wide operation using a word-wide one, ie an lwarx/stwcx. loop. Even if that works (and apparently it does not), we would not want to use it since it implies contention between adjacent atomic flags. That's the case as long as they're on a single cache line. Whether it's the same word, double/half word shouldn't matter. Andres -- Sent from my Android device with K-9 Mail. Please excuse my brevity.