From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/atomic%2Fatomic_is_lock_free.html | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 devdocs/c/atomic%2Fatomic_is_lock_free.html (limited to 'devdocs/c/atomic%2Fatomic_is_lock_free.html') diff --git a/devdocs/c/atomic%2Fatomic_is_lock_free.html b/devdocs/c/atomic%2Fatomic_is_lock_free.html new file mode 100644 index 00000000..373ff242 --- /dev/null +++ b/devdocs/c/atomic%2Fatomic_is_lock_free.html @@ -0,0 +1,39 @@ +

atomic_is_lock_free

Defined in header <stdatomic.h>
_Bool atomic_is_lock_free( const volatile A* obj );
+
(since C11)

Determines if the atomic operations on all objects of the type A (the type of the object pointed to by obj) are lock-free. In any given program execution, the result of calling atomic_is_lock_free is the same for all pointers of the same type.

+

This is a generic function defined for all atomic object types A. The argument is pointer to a volatile atomic type to accept addresses of both non-volatile and volatile (e.g. memory-mapped I/O) atomic objects, and volatile semantic is preserved when applying this operation to volatile atomic objects.

+

It is unspecified whether the name of a generic function is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual function (e.g. parenthesized like (atomic_is_lock_free)(...)), or a program defines an external identifier with the name of a generic function, the behavior is undefined.

+

Parameters

+ +
obj - pointer to the atomic object to inspect

Return value

true if the operations on all objects of the type A are lock-free, false otherwise.

+

Example

#include <stdio.h>
+#include <stdatomic.h>
+ 
+_Atomic struct A { int a[100]; } a;
+_Atomic struct B { int x, y; } b;
+int main(void)
+{
+    printf("_Atomic struct A is lock free? %s\n", 
+            atomic_is_lock_free(&a) ? "true" : "false");
+    printf("_Atomic struct B is lock free? %s\n", 
+            atomic_is_lock_free(&b) ? "true" : "false");
+}

Possible output:

+
_Atomic struct A is lock free? false
+_Atomic struct B is lock free? true

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C standards.

+ + + +
DR Applied to Behavior as published Correct behavior
+DR 465 C11 this function was per-object this functions is per-type

References

See also

+ +
+
(C11)
indicates that the given atomic type is lock-free
(macro constant)
C++ documentation for atomic_is_lock_free
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/atomic/atomic_is_lock_free +

+
-- cgit v1.2.3