aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/stdatomic.h
Commit message (Collapse)AuthorAgeFilesLines
* sys: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-1/+0
| | | | Notes: svn path=/head/; revision=365223
* Make the system C11 atomics headers fully compatible with external GCC.John Baldwin2018-08-061-14/+11
| | | | | | | | | | | | | | | | | | | | | | | The <sys/cdefs.h> and <stdatomic.h> headers already included support for C11 atomics via intrinsincs in modern versions of GCC, but these versions tried to "hide" atomic variables inside a wrapper structure. This wrapper is not compatible with GCC's internal <stdatomic.h> header, so that if GCC's <stdatomic.h> was used together with <sys/cdefs.h>, use of C11 atomics would fail to compile. Fix this by not hiding atomic variables in a structure for modern versions of GCC. The headers already avoid using a wrapper structure on clang. Note that this wrapper was only used if C11 was not enabled (e.g. via -std=c99), so this also fixes compile failures if a modern version of GCC was used with -std=c11 but with FreeBSD's <stdatomic.h> instead of GCC's <stdatomic.h> and this change fixes that case as well. Reported by: Mark Millard Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D16585 Notes: svn path=/head/; revision=337399
* sys/sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326256
* Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4Tijl Coosemans2014-04-011-1/+1
| | | | | | | | | -fms-extensions. MFC after: 2 weeks Notes: svn path=/head/; revision=263998
* Change the return type of the fallback implementation of theTijl Coosemans2013-08-181-2/+2
| | | | | | | atomic_compare_exchange_* macros in stdatomic.h to _Bool. Notes: svn path=/head/; revision=254497
* Correct implementation of atomic_flag_test_and_setEd Maste2013-08-171-5/+1
| | | | | | | The function sets the flag and returns the previous value (7.17.8.1). Notes: svn path=/head/; revision=254465
* Make atomic_fetch_add() and atomic_fetch_sub() work for pointers with GCC 4.2.Ed Schouten2013-06-301-2/+6
| | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=252413
* Make various fixes to <stdatomic.h>.Ed Schouten2013-06-301-22/+68
| | | | | | | | | | | | | | - 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. Notes: svn path=/head/; revision=252411
* Move _Atomic() into <sys/cdefs.h>.Ed Schouten2013-06-161-4/+0
| | | | | | | | | | 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". Notes: svn path=/head/; revision=251804
* Minor improvements to <stdatomic.h>.Ed Schouten2013-06-131-2/+8
| | | | | | | | | | | | | | | - 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. Notes: svn path=/head/; revision=251694
* Fix the way atomic_is_lock_free() is defined for Clang.Ed Schouten2013-06-091-1/+4
| | | | | | | | When using Clang atomics, atomic types are not placed in a structure. There is thus no reason why we should get the __val member. Notes: svn path=/head/; revision=251566
* Add ATOMIC_*_LOCK_FREE constants.Ed Schouten2013-06-031-0/+35
| | | | | | | | These constants are part of the C standard. Both Clang and GCC seem to export these constants under the name __GCC_ATOMIC_*_LOCK_FREE. Notes: svn path=/head/; revision=251347
* Move <stdatomic.h> into sys/sys/.Ed Schouten2013-06-011-0/+325
This will allow us to use C11 atomics in kernelspace, although it will need to be included as <sys/stdatomic.h>. Notes: svn path=/head/; revision=251230