plibsys 0.0.5
patomic.h
Go to the documentation of this file.
1/*
2 * The MIT License
3 *
4 * Copyright (C) 2010-2016 Alexander Saprykin <saprykin.spb@gmail.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * 'Software'), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
51#if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
52# error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
53#endif
54
55#ifndef PLIBSYS_HEADER_PATOMIC_H
56#define PLIBSYS_HEADER_PATOMIC_H
57
58#include <ptypes.h>
59#include <pmacros.h>
60
62
72P_LIB_API pint p_atomic_int_get (const volatile pint *atomic);
73
83P_LIB_API void p_atomic_int_set (volatile pint *atomic,
84 pint val);
85
95P_LIB_API void p_atomic_int_inc (volatile pint *atomic);
96
110
128 pint oldval,
129 pint newval);
130
144 pint val);
145
160 puint val);
161
176 puint val);
177
192 puint val);
193
202P_LIB_API ppointer p_atomic_pointer_get (const volatile void *atomic);
203
212P_LIB_API void p_atomic_pointer_set (volatile void *atomic,
213 ppointer val);
214
232 ppointer oldval,
233 ppointer newval);
234
247P_LIB_API pssize p_atomic_pointer_add (volatile void *atomic,
248 pssize val);
249
263P_LIB_API psize p_atomic_pointer_and (volatile void *atomic,
264 psize val);
265
279P_LIB_API psize p_atomic_pointer_or (volatile void *atomic,
280 psize val);
281
295P_LIB_API psize p_atomic_pointer_xor (volatile void *atomic,
296 psize val);
297
307
309
310#endif /* PLIBSYS_HEADER_PATOMIC_H */
P_LIB_API psize p_atomic_pointer_and(volatile void *atomic, psize val)
Atomically performs the bitwise 'and' operation of ppointer-sized atomic value and val storing the re...
P_LIB_API pboolean p_atomic_pointer_compare_and_exchange(volatile void *atomic, ppointer oldval, ppointer newval)
Compares oldval with the value pointed to by atomic and if they are equal, atomically exchanges the v...
P_LIB_API pboolean p_atomic_int_compare_and_exchange(volatile pint *atomic, pint oldval, pint newval)
Compares oldval with the value pointed to by atomic and if they are equal, atomically exchanges the v...
P_LIB_API pint p_atomic_int_add(volatile pint *atomic, pint val)
Atomically adds pint value to atomic value.
P_LIB_API puint p_atomic_int_xor(volatile puint *atomic, puint val)
Atomically performs the bitwise 'xor' operation of atomic value and val storing the result back in at...
P_LIB_API pboolean p_atomic_int_dec_and_test(volatile pint *atomic)
Decrements pint value from atomic by 1 and tests the result for zero.
P_LIB_API void p_atomic_int_inc(volatile pint *atomic)
Increments pint value from atomic by 1.
P_LIB_API pint p_atomic_int_get(const volatile pint *atomic)
Gets pint value from atomic.
P_LIB_API psize p_atomic_pointer_or(volatile void *atomic, psize val)
Atomically performs the bitwise 'or' operation of ppointer-sized atomic value and val storing the res...
P_LIB_API ppointer p_atomic_pointer_get(const volatile void *atomic)
Gets ppointer-sized value from atomic.
P_LIB_API void p_atomic_int_set(volatile pint *atomic, pint val)
Sets pint value to atomic.
P_LIB_API puint p_atomic_int_or(volatile puint *atomic, puint val)
Atomically performs the bitwise 'or' operation of atomic value and val storing the result back in ato...
P_LIB_API pssize p_atomic_pointer_add(volatile void *atomic, pssize val)
Atomically adds ppointer-sized value to atomic value.
P_LIB_API psize p_atomic_pointer_xor(volatile void *atomic, psize val)
Atomically performs the bitwise 'xor' operation of ppointer-sized atomic value and val storing the re...
P_LIB_API pboolean p_atomic_is_lock_free(void)
Checks whether atomic operations are lock-free.
P_LIB_API puint p_atomic_int_and(volatile puint *atomic, puint val)
Atomically performs the bitwise 'and' operation of atomic value and val storing the result back in at...
P_LIB_API void p_atomic_pointer_set(volatile void *atomic, ppointer val)
Sets val to ppointer-sized atomic.
Miscellaneous macros.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition pmacros.h:298
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS.
Definition pmacros.h:299
#define P_LIB_API
Exports a symbol from a shared library.
Definition pmacros.h:138
Types definitions.
signed int pssize
Type for a platform independent signed size_t.
Definition ptypes.h:223
unsigned int psize
Type for a platform independent size_t.
Definition ptypes.h:224
void * ppointer
Type for a pointer.
Definition ptypes.h:109
unsigned int puint
Type for an unsigned int.
Definition ptypes.h:129
int pint
Type for an int.
Definition ptypes.h:120
signed int pboolean
Type for a bool.
Definition ptypes.h:114