EM-ODP  3.7.0
Event Machine on ODP
em_atomic.h
1 /*
2  * Copyright (c) 2014, Nokia Solutions and Networks
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef EM_ATOMIC_H_
32 #define EM_ATOMIC_H_
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Types and macros to avoid #ifdef EM_64_BIT/EM_32_BIT throughout the code
40  */
41 
42 #if defined(EM_64_BIT)
43 
45 
46 #define EM_ATOMIC_INIT(...) env_atomic64_init(__VA_ARGS__)
47 #define EM_ATOMIC_GET(...) env_atomic64_get(__VA_ARGS__)
48 #define EM_ATOMIC_SET(...) env_atomic64_set(__VA_ARGS__)
49 #define EM_ATOMIC_ADD(...) env_atomic64_add(__VA_ARGS__)
50 #define EM_ATOMIC_ADD_RETURN(...) env_atomic64_add_return(__VA_ARGS__)
51 #define EM_ATOMIC_RETURN_ADD(...) env_atomic64_return_add(__VA_ARGS__)
52 #define EM_ATOMIC_INC(...) env_atomic64_inc(__VA_ARGS__)
53 #define EM_ATOMIC_DEC(...) env_atomic64_dec(__VA_ARGS__)
54 #define EM_ATOMIC_SUB(...) env_atomic64_sub(__VA_ARGS__)
55 #define EM_ATOMIC_SUB_RETURN(...) env_atomic64_sub_return(__VA_ARGS__)
56 #define EM_ATOMIC_RETURN_SUB(...) env_atomic64_return_sub(__VA_ARGS__)
57 #define EM_ATOMIC_CMPSET(...) env_atomic64_cmpset(__VA_ARGS__)
58 #define EM_ATOMIC_EXCHANGE(...) env_atomic64_exchange(__VA_ARGS__)
59 
60 #elif defined(EM_32_BIT)
61 
63 
64 #define EM_ATOMIC_INIT(...) env_atomic32_init(__VA_ARGS__)
65 #define EM_ATOMIC_GET(...) env_atomic32_get(__VA_ARGS__)
66 #define EM_ATOMIC_SET(...) env_atomic32_set(__VA_ARGS__)
67 #define EM_ATOMIC_ADD(...) env_atomic32_add(__VA_ARGS__)
68 #define EM_ATOMIC_ADD_RETURN(...) env_atomic32_add_return(__VA_ARGS__)
69 #define EM_ATOMIC_RETURN_ADD(...) env_atomic32_return_add(__VA_ARGS__)
70 #define EM_ATOMIC_INC(...) env_atomic32_inc(__VA_ARGS__)
71 #define EM_ATOMIC_DEC(...) env_atomic32_dec(__VA_ARGS__)
72 #define EM_ATOMIC_SUB(...) env_atomic32_sub(__VA_ARGS__)
73 #define EM_ATOMIC_SUB_RETURN(...) env_atomic32_sub_return(__VA_ARGS__)
74 #define EM_ATOMIC_RETURN_SUB(...) env_atomic32_return_sub(__VA_ARGS__)
75 #define EM_ATOMIC_CMPSET(...) env_atomic32_cmpset(__VA_ARGS__)
76 #define EM_ATOMIC_EXCHANGE(...) env_atomic32_exchange(__VA_ARGS__)
77 
78 #else
79 #error "Neither EM_64_BIT nor EM_32_BIT set!"
80 #endif
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif
_env_atomic64
Definition: env_atomic.h:48
_env_atomic32
Definition: env_atomic.h:44