svn commit: r252411 - head/sys/sys

Tijl Coosemans tijl at coosemans.org
Sun Jun 30 18:42:40 UTC 2013


On 2013-06-30 10:54, Ed Schouten wrote:
> Author: ed
> Date: Sun Jun 30 08:54:41 2013
> New Revision: 252411
> URL: http://svnweb.freebsd.org/changeset/base/252411
> 
> Log:
>   Make various fixes to <stdatomic.h>.
>   
>   - According to the standard, memory_order is a type. Use a typedef.
>   
>   - atomic_*_fence() and atomic_flag_*() are described by the standard as
>     functions. Use inline functions to implement them.
>   
>   - Only expose the atomic_*_explicit() functions in kernel space. We
>     should not use the short-hand functions, as they will always use
>     memory_order_seq_cst.
> 
> Modified:
>   head/sys/sys/stdatomic.h
> 
> Modified: head/sys/sys/stdatomic.h
> ==============================================================================
> --- head/sys/sys/stdatomic.h	Sun Jun 30 08:36:19 2013	(r252410)
> +++ head/sys/sys/stdatomic.h	Sun Jun 30 08:54:41 2013	(r252411)
> @@ -122,33 +122,44 @@
>   * atomic operations.
>   */
>  
> -enum memory_order {
> +typedef enum {
>  	memory_order_relaxed = __ATOMIC_RELAXED,
>  	memory_order_consume = __ATOMIC_CONSUME,
>  	memory_order_acquire = __ATOMIC_ACQUIRE,
>  	memory_order_release = __ATOMIC_RELEASE,
>  	memory_order_acq_rel = __ATOMIC_ACQ_REL,
>  	memory_order_seq_cst = __ATOMIC_SEQ_CST
> -};
> +} memory_order;
>  
>  /*
>   * 7.17.4 Fences.
>   */
>  
> +static __inline void
> +atomic_thread_fence(memory_order __order __unused)

I don't think you can use static inline. Standard library functions need
to have external linkage, which means you have to implement them in libc.
What you can do is declare the function in the header and then define a
macro implementation of it.

>   * 7.17.8 Atomic flag type and operations.
> + *
> + * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some
> + * kind of compiler built-in type we could use?

I think you can just use unsigned char. Only the test-and-set and clear
operations need to be atomic. Anything else (like copy-assignment)
doesn't have to be atomic. Both clang and gcc have __atomic_test_and_set
and __atomic_clear built-ins.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20130630/1cd98051/attachment.sig>


More information about the svn-src-all mailing list