1 /*******************************************************************************
2  * @file
3  * @brief Implementation of atomic operations.
4  *******************************************************************************
5  * # License
6  * <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
7  *******************************************************************************
8  *
9  * SPDX-License-Identifier: Zlib
10  *
11  * The licensor of this software is Silicon Laboratories Inc.
12  *
13  * This software is provided 'as-is', without any express or implied
14  * warranty. In no event will the authors be held liable for any damages
15  * arising from the use of this software.
16  *
17  * Permission is granted to anyone to use this software for any purpose,
18  * including commercial applications, and to alter it and redistribute it
19  * freely, subject to the following restrictions:
20  *
21  * 1. The origin of this software must not be misrepresented; you must not
22  *    claim that you wrote the original software. If you use this software
23  *    in a product, an acknowledgment in the product documentation would be
24  *    appreciated but is not required.
25  * 2. Altered source versions must be plainly marked as such, and must not be
26  *    misrepresented as being the original software.
27  * 3. This notice may not be removed or altered from any source distribution.
28  *
29  ******************************************************************************/
30 #ifndef SL_ATOMIC_H
31 #define SL_ATOMIC_H
32 
33 /*******************************************************************************
34  * @addtogroup atomic Atomic Operations
35  * @brief Atomic operations provide RAM store and read functionalities.
36  * @n @section atomic_usage Atomic Operations Usage
37  * @{
38  ******************************************************************************/
39 
40 /***************************************************************************//**
41  * @brief         Perform an atomic load. Use when a variable must be read from
42  *                RAM.
43  *
44  * @param dest    Variable where to copy the loaded value.
45  *
46  * @param source  Variable from where to load the value.
47  *
48  * @note          Does only support native types <= 32 bits.
49  *
50  * @note          Load operation on 32 bit value is atomic on ARM architecture.
51  *
52  * @note          Only the load operation from 'source' is guaranteed to be
53  *                performed atomically. If writing to 'dest' implies a store,
54  *                the load and store operations are not guaranteed to be
55  *                performed atomically.
56  ******************************************************************************/
57 #define sl_atomic_load(dest, source)     ((dest) = (source))
58 
59 /*******************************************************************************
60  * @brief         Perform an atomic store. Use when a value must be stored in
61  *                RAM.
62  *
63  * @param dest    Variable where to store the value.
64  *
65  * @param source  Variable that contains the value to store in 'dest'.
66  *
67  * @note          Does only support native types <= 32 bits.
68  *
69  * @note          Store operation on 32 bit value is atomic on ARM architecture.
70  *
71  * @note          Only the store operation to 'dest' is guaranteed to be
72  *                performed atomically. If reading from 'source' implies a load,
73  *                the store and load operations are not guaranteed to be
74  *                performed atomically.
75  ******************************************************************************/
76 #define sl_atomic_store(dest, source)    ((dest) = (source))
77 
78 /** @} (end addtogroup atomic) */
79 
80 #endif /* SL_ATOMIC_H */
81