Fix atomic builtins detection
Ralph Boehme
slow at samba.org
Mon Apr 25 18:21:19 UTC 2016
On Mon, Apr 25, 2016 at 11:15:42AM -0700, Jeremy Allison wrote:
> On Mon, Apr 25, 2016 at 04:24:28PM +0200, Jeremie Courreges-Anglas wrote:
> >
> > Hi,
> >
> > lib/replace/wscript has this bunch of code:
> >
> > # Check for atomic builtins. */
> > conf.CHECK_CODE('''
> > int main(void) {
> > int i;
> > (void)__sync_fetch_and_add(&i, 1);
> > return 0;
> > }
> > ''',
> > 'HAVE___SYNC_FETCH_AND_ADD',
> > msg='Checking for __sync_fetch_and_add compiler builtin')
> >
> >
> > It is incorrect, since CHECK_CODE already wraps the code fragment in
> > main(). Here's what gets compiled:
> >
> >
> > [includes]
> > int main(void) {
> > int main(void) {
> > int i;
> > (void)__sync_fetch_and_add(&i, 1);
> > return 0;
> > }
> > ; return 0; }
> >
> >
> > Now the funny part is when you run this where __sync_fetch_and_add is
> > actually not available. The inner main() function isn't called
> > anywhere, and at cc -O2 it is simply optimized out, thus the compile
> > test wrongly succeeds. This can be seen for example on OpenBSD/hppa
> > (gcc-4.2.1).
> >
> > Please find attached a patch to fix this issue for __sync_fetch_and_add
> > and atomic_add_32.
>
> Looks good to me. Can I get a second Team reviewer ?
lgtm. Can you push? Thanks!
Cheerio!
-slow
More information about the samba-technical
mailing list