Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jun 2013 20:42:24 +0200
From:      Tijl Coosemans <tijl@coosemans.org>
To:        Ed Schouten <ed@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r252411 - head/sys/sys
Message-ID:  <51D07C10.2000509@coosemans.org>
In-Reply-To: <201306300854.r5U8sfYS018720@svn.freebsd.org>
References:  <201306300854.r5U8sfYS018720@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
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.


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iF4EAREIAAYFAlHQfBQACgkQfoCS2CCgtiva1gD/e65/WqdD1WKrF0cKgoPZD8sx
O7SuZ5m9QhfKSsGlvHYA/0RK+GIOHckP5uxeamAzkbQzBXDbxHTb8GpPgHS0kzOQ
=LVim
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51D07C10.2000509>