Change initialize a bit
[c11tester.git] / include / cmodelint.h
1 /** @file cmodelint.h
2  *  @brief C interface to the model checker.
3  */
4
5 #ifndef CMODELINT_H
6 #define CMODELINT_H
7 #include <inttypes.h>
8 #include "memoryorder.h"
9
10 #if __cplusplus
11 using std::memory_order;
12 extern "C" {
13 #else
14 typedef int bool;
15 #endif
16
17
18 uint64_t model_read_action(void * obj, memory_order ord);
19 void model_write_action(void * obj, memory_order ord, uint64_t val);
20 void model_init_action(void * obj, uint64_t val);
21 uint64_t model_rmwr_action(void *obj, memory_order ord);
22 uint64_t model_rmwrcas_action(void *obj, memory_order ord, uint64_t oval, int size);
23 void model_rmw_action(void *obj, memory_order ord, uint64_t val);
24 void model_rmwc_action(void *obj, memory_order ord);
25 void model_fence_action(memory_order ord);
26
27 uint64_t model_rmwr_action_helper(void *obj, int atomic_index, const char *position);
28 uint64_t model_rmwrcas_action_helper(void *obj, int atomic_index, uint64_t oval, int size, const char *position);
29 void model_rmw_action_helper(void *obj, uint64_t val, int atomic_index, const char *position);
30 void model_rmwc_action_helper(void *obj, int atomic_index, const char *position);
31 // void model_fence_action_helper(int atomic_index);
32
33 /* the following functions are used by llvm pass */
34 // cds volatile loads
35 uint8_t cds_volatile_load8(void * obj, const char * position);
36 uint16_t cds_volatile_load16(void * obj, const char * position);
37 uint32_t cds_volatile_load32(void * obj, const char * position);
38 uint64_t cds_volatile_load64(void * obj, const char * position);
39
40 // cds volatile stores
41 void cds_volatile_store8(void * obj, uint8_t val, const char * position);
42 void cds_volatile_store16(void * obj, uint16_t val, const char * position);
43 void cds_volatile_store32(void * obj, uint32_t val, const char * position);
44 void cds_volatile_store64(void * obj, uint64_t val, const char * position);
45
46 void cds_atomic_init8(void * obj, uint8_t val, const char * position);
47 void cds_atomic_init16(void * obj, uint16_t val, const char * position);
48 void cds_atomic_init32(void * obj, uint32_t val, const char * position);
49 void cds_atomic_init64(void * obj, uint64_t val, const char * position);
50
51 uint8_t  cds_atomic_load8(void * obj, int atomic_index, const char * position);
52 uint16_t cds_atomic_load16(void * obj, int atomic_index, const char * position);
53 uint32_t cds_atomic_load32(void * obj, int atomic_index, const char * position);
54 uint64_t cds_atomic_load64(void * obj, int atomic_index, const char * position);
55
56 void cds_atomic_store8(void * obj, uint8_t val, int atomic_index, const char * position);
57 void cds_atomic_store16(void * obj, uint16_t val, int atomic_index, const char * position);
58 void cds_atomic_store32(void * obj, uint32_t val, int atomic_index, const char * position);
59 void cds_atomic_store64(void * obj, uint64_t val, int atomic_index, const char * position);
60
61
62 // cds atomic exchange
63 uint8_t cds_atomic_exchange8(void* addr, uint8_t val, int atomic_index, const char * position);
64 uint16_t cds_atomic_exchange16(void* addr, uint16_t val, int atomic_index, const char * position);
65 uint32_t cds_atomic_exchange32(void* addr, uint32_t val, int atomic_index, const char * position);
66 uint64_t cds_atomic_exchange64(void* addr, uint64_t val, int atomic_index, const char * position);
67 // cds atomic fetch add
68 uint8_t  cds_atomic_fetch_add8(void* addr, uint8_t val, int atomic_index, const char * position);
69 uint16_t cds_atomic_fetch_add16(void* addr, uint16_t val, int atomic_index, const char * position);
70 uint32_t cds_atomic_fetch_add32(void* addr, uint32_t val, int atomic_index, const char * position);
71 uint64_t cds_atomic_fetch_add64(void* addr, uint64_t val, int atomic_index, const char * position);
72 // cds atomic fetch sub
73 uint8_t  cds_atomic_fetch_sub8(void* addr, uint8_t val, int atomic_index, const char * position);
74 uint16_t cds_atomic_fetch_sub16(void* addr, uint16_t val, int atomic_index, const char * position);
75 uint32_t cds_atomic_fetch_sub32(void* addr, uint32_t val, int atomic_index, const char * position);
76 uint64_t cds_atomic_fetch_sub64(void* addr, uint64_t val, int atomic_index, const char * position);
77 // cds atomic fetch and
78 uint8_t cds_atomic_fetch_and8(void* addr, uint8_t val, int atomic_index, const char * position);
79 uint16_t cds_atomic_fetch_and16(void* addr, uint16_t val, int atomic_index, const char * position);
80 uint32_t cds_atomic_fetch_and32(void* addr, uint32_t val, int atomic_index, const char * position);
81 uint64_t cds_atomic_fetch_and64(void* addr, uint64_t val, int atomic_index, const char * position);
82 // cds atomic fetch or
83 uint8_t cds_atomic_fetch_or8(void* addr, uint8_t val, int atomic_index, const char * position);
84 uint16_t cds_atomic_fetch_or16(void* addr, uint16_t val, int atomic_index, const char * position);
85 uint32_t cds_atomic_fetch_or32(void* addr, uint32_t val, int atomic_index, const char * position);
86 uint64_t cds_atomic_fetch_or64(void* addr, uint64_t val, int atomic_index, const char * position);
87 // cds atomic fetch xor
88 uint8_t cds_atomic_fetch_xor8(void* addr, uint8_t val, int atomic_index, const char * position);
89 uint16_t cds_atomic_fetch_xor16(void* addr, uint16_t val, int atomic_index, const char * position);
90 uint32_t cds_atomic_fetch_xor32(void* addr, uint32_t val, int atomic_index, const char * position);
91 uint64_t cds_atomic_fetch_xor64(void* addr, uint64_t val, int atomic_index, const char * position);
92
93 // cds atomic compare and exchange (strong)
94 uint8_t cds_atomic_compare_exchange8_v1(void* addr, uint8_t expected, uint8_t desire,
95                                                                                                                                                                 int atomic_index_succ, int atomic_index_fail, const char *position);
96 uint16_t cds_atomic_compare_exchange16_v1(void* addr, uint16_t expected, uint16_t desire,
97                                                                                                                                                                         int atomic_index_succ, int atomic_index_fail, const char *position);
98 uint32_t cds_atomic_compare_exchange32_v1(void* addr, uint32_t expected, uint32_t desire,
99                                                                                                                                                                         int atomic_index_succ, int atomic_index_fail, const char *position);
100 uint64_t cds_atomic_compare_exchange64_v1(void* addr, uint64_t expected, uint64_t desire,
101                                                                                                                                                                         int atomic_index_succ, int atomic_index_fail, const char *position);
102
103 bool cds_atomic_compare_exchange8_v2(void* addr, uint8_t* expected, uint8_t desired,
104                                                                                                                                                  int atomic_index_succ, int atomic_index_fail, const char *position);
105 bool cds_atomic_compare_exchange16_v2(void* addr, uint16_t* expected, uint16_t desired,
106                                                                                                                                                         int atomic_index_succ, int atomic_index_fail, const char *position);
107 bool cds_atomic_compare_exchange32_v2(void* addr, uint32_t* expected, uint32_t desired,
108                                                                                                                                                         int atomic_index_succ, int atomic_index_fail, const char *position);
109 bool cds_atomic_compare_exchange64_v2(void* addr, uint64_t* expected, uint64_t desired,
110                                                                                                                                                         int atomic_index_succ, int atomic_index_fail, const char *position);
111
112 // cds atomic thread fence
113 void cds_atomic_thread_fence(int atomic_index, const char * position);
114
115 void cds_func_entry(const char * funcName);
116 void cds_func_exit(const char * funcName);
117
118 #if __cplusplus
119 }
120 #endif
121
122 #endif