History log of /freebsd-10.0-release/sys/sys/stdatomic.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 254497 18-Aug-2013 tijl

Change the return type of the fallback implementation of the
atomic_compare_exchange_* macros in stdatomic.h to _Bool.


# 254465 17-Aug-2013 emaste

Correct implementation of atomic_flag_test_and_set

The function sets the flag and returns the previous value (7.17.8.1).


# 252413 30-Jun-2013 ed

Make atomic_fetch_add() and atomic_fetch_sub() work for pointers with GCC 4.2.

According to the standard, atomic_fetch_*() has to behave identical to
regular arithmetic. This means that for pointer types, we have to apply
the stride when doing addition/subtraction.

The GCC documentation seems to imply this is done for __sync_*() as
well. Unfortunately, both tests and Googling seems to reveal this is not
really the case. Fix this by performing the multiplication with the
stride manually.


# 252411 30-Jun-2013 ed

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.


# 251804 16-Jun-2013 ed

Move _Atomic() into <sys/cdefs.h>.

That way _Atomic() is defined next to all the other C11 keywords for
which we provide compatibility for pre-C11 compilers. While there, fix
the definition to place "volatile" at the end. Otherwise pointer types
will become "volatile T *" instead of "T * volatile".


# 251694 13-Jun-2013 ed

Minor improvements to <stdatomic.h>.

- Define __SYNC_ATOMICS in case we're using the __sync_*() API. This is
not used by <stdatomic.h> itself, but may be useful for some of the
intrinsics code to determine whether it should build the
machine-dependent intrinsic functions.

- Make is_lock_free() work in kernelspace. For now, assume atomics in
kernelspace are always lock free. This is a quite reasonable
assumption, as we surely shouldn't implement the atomic fallbacks for
arbitrary sizes.


# 251566 09-Jun-2013 ed

Fix the way atomic_is_lock_free() is defined for Clang.

When using Clang atomics, atomic types are not placed in a structure.
There is thus no reason why we should get the __val member.


# 251347 03-Jun-2013 ed

Add ATOMIC_*_LOCK_FREE constants.

These constants are part of the C standard. Both Clang and GCC seem to
export these constants under the name __GCC_ATOMIC_*_LOCK_FREE.


# 251230 01-Jun-2013 ed

Move <stdatomic.h> into sys/sys/.

This will allow us to use C11 atomics in kernelspace, although it will
need to be included as <sys/stdatomic.h>.


# 251192 31-May-2013 ed

Fix misspelling of structure field name.


# 250883 21-May-2013 ed

Add <uchar.h>.

The <uchar.h> header, part of C11, adds a small number of utility
functions for 16/32-bit "universal" characters, which may or may not be
UTF-16/32. As our wchar_t is already ISO 10646, simply add light-weight
wrappers around wcrtomb() and mbrtowc().

While there, also add (non-yet-standard) _l functions, similar to the
ones we already have for the other locale-dependent functions.

Reviewed by: theraven


# 241077 30-Sep-2012 tijl

- Simplify the implementation of atomic_compare_exchange_strong_explicit.
- Evaluate the memory order argument in atomic_fetch_*_explicit macros.
- Implement atomic_store_explicit using atomic_exchange_explicit instead
of a plain assignment.

Reviewed by: theraven
MFC after: 2 weeks


# 240970 26-Sep-2012 tijl

- Make C11 atomic macros usable in expressions:
- Replace do-while statements with void expressions.
- Wrap __asm statements in statement expressions.
- Make the macros function-like:
- Evaluate all arguments exactly once.
- Make sure there's a sequence point between evaluation of the arguments
and the function body. Arguments should be evaluated before any memory
barriers.
- Fix use of __atomic_is_lock_free built-in. It requires the address of
an atomic variable as second argument. Use this built-in on clang as
well because clang's __c11_atomic_is_lock_free only takes the size of the
variable into account.
- In atomic_exchange_explicit put the barrier before instead of after the
__sync_lock_test_and_set call.

Reviewed by: theraven


# 239960 31-Aug-2012 ed

Properly enable Clang-style atomics when available.

In addition to testing against cxx_atomic, we must check c_atomic. The
former is only set when building C++ code. Also use __has_extension
instead of __has_feature. This allows us to use the atomics outside of
C11.

Reported by: Ariane van der Steldt <ariane stack nl>
PR: threads/170073


# 234958 03-May-2012 theraven

Fix <stdatomic.h> after clang decided to rename all of its builtins to include
a c11 prefix to disambiguate them from the one provided by GCC.

Note: Clang 3.1 also supports the GCC builtins for libstdc++ 4.7 compatibility,
but I don't recommend using them because they are very poorly designed.

MFC after: 2 weeks


# 230267 17-Jan-2012 theraven

Fix clang atomic to use for atomic_is_lock_free().

Reviewed by: ed
Approved by: dim (mentor)


# 230225 16-Jan-2012 theraven

Use the signal fence builtin in stdatomic.h when using the clang atomic
builtins, rather than the __asm hack. Somehow I missed the existence of this
builtin originally and only noticed that it was there when I went to implement
it...

Note: Trunk clang now has support for (most of) the C[++]11 atomics stuff.
Please test!

Approved by: brooks (mentor)


# 230062 13-Jan-2012 ed

Correct mistake in atomic_flag macros.

The _explicit versions only have two parameters, namely the object and
the order. There is no need to pass the values of the atomic variable.


# 229332 02-Jan-2012 ed

Remove extraneous semicolons.

These macros are supposed to be invoked as regular functions, so remove
them.


# 228977 29-Dec-2011 ed

Extend <stdatomic.h> to support GCC 4.7's __atomic.

The development version of GCC also supports an atomics interface
similar to Clang's. Change the header file to work as follows:

- __CLANG_ATOMICS: Use Clang's new atomics interface,
- __GNUC_ATOMICS: Use GCC's new atomics interface,
- else: fall back to GCC's __sync interface.


# 228906 26-Dec-2011 ed

Fix some bugs in <stdatomic.h>.

- Make atomic_init() work for GCC, as assigning to structs doesn't work.
- Fix misplaced parenthesis in atomic_is_lock_free() for GCC.
- Make atomic_compare_exchange_strong() for GCC return the proper
boolean value, whether object == expected.
- Fix argument passing in atomic_exchange_explicit() for GCC.


# 228882 25-Dec-2011 ed

Make white space in this file a bit more consistent.

Remove trailing whitespace and place all macro definitions at the same
column.


# 228880 25-Dec-2011 ed

Fix field name.

The value field in the atomic structure is called __val; not value.


# 228862 24-Dec-2011 theraven

Initial implementation of stdatomic.h. Works (at least in the parts that were
tested) with clang and gcc, and more efficiently with clang+a big out-of-tree
diff that I need to commit soon (once it's been tidied and reviewed a bit).

Large portions by: ed
Reviewed by: ed
Approved by: dim (mentor)