[llvm-commits] [PATCH] Detect GCC atomic builtins in configure

Owen Anderson resistor at mac.com
Mon May 18 01:50:48 PDT 2009


On May 17, 2009, at 10:33 PM, Eric Christopher wrote:

> a) the idea of testing host configuration (which may not work) for  
> something target specific seems a bit problematic.

I don't really have a better idea.

> c)
>
> AC_RUN_IFELSE(AC_LANG_SOURCE([[int main() {
> +                 volatile unsigned long val = 1;
> +                 __sync_synchronize();
> +                 if (__sync_val_compare_and_swap(&val, 1, 0) != 1 ||
> +                     val != 0)
> +                   return 1;
> +                 return 0; }]]),
>
> Do you care if it runs or if it links? I'd have thought the latter,  
> but it's up to you.

Probably just links, I guess.

> d)
>
> +                AC_DEFINE(ENABLE_THREADS, [0])
>
> You can do this using something like:
>
> AC_DEFINE(ENABLE_THREADS, 0,
>        Define if gcc atomic builtins work on your system.)

What does this achieve?

> e) ENABLE_THREADS seems like a really bad name :)

I didn't choose it.  It's already part of LLVM's configure.ac.

> f) It seems like you want to do a configure time flag? I'm not  
> positive though. If you did then something like this may work better:
>
> AC_ARG_ENABLE(enable-gcc-atomics,
> [  --enable-gcc-atomics   gcc atomic functions],,
> enable_gcc_atomics=no)
>
> (or yes, depending on what you want it to default to) and then  
> something like:
>
> if test x$enable_gcc_atomics = xyes ; then
>  AC_DEFINE(ENABLE_THREADS, 1,
>        Define if gcc atomic builtins work on your system.)
> fi

There's already a --enable-threads configure thread, that defaults to  
true.

> g)
>
> +                AC_SUBST(ENABLE_THREADS, [0])
>
> You probably don't mean to SUBST and DEFINE this. Is it for the  
> environment or the compiled C/C++ files?

I'm somewhat confused on this one myself.  Early parts of the  
configure.ac use AC_SUBST, but there is a #define for it in config.h,  
which doesn't get changed if I just use AC_SUBST, hence whey I added  
the AC_DEFINE.  Perhaps it's a bug in the rest of configure.ac?

> Sorry to seemingly pick it apart so much, but you did ask :)

Much appreciated!

--Owen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090518/447527d4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090518/447527d4/attachment.bin>


More information about the llvm-commits mailing list