e569ba17f0a469733c203598b32af42433904a96
[satcheck.git] / include / libinterface.h
1 /** @file libinterface.h
2  *  @brief Interface to check normal memory operations for data races.
3  */
4
5 #ifndef __LIBINTERFACE_H__
6 #define __LIBINTERFACE_H__
7
8 #include <stdint.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13   typedef unsigned int MCID;
14 #define MC2_PTR_LENGTH sizeof(void *)
15         
16 #define MCID_NODEP ((MCID)0)
17 #define MCID_INIT ((MCID)0)
18 #define MCID_FIRST ((MCID)1)
19
20 #define MC2_OFFSET(x, y) (uintptr_t)(&((x)(0))->y)
21         
22         void store_8(void *addr, uint8_t val);
23         void store_16(void *addr, uint16_t val);
24         void store_32(void *addr, uint32_t val);
25         void store_64(void *addr, uint64_t val);
26
27         uint8_t load_8(const void *addr);
28         uint16_t load_16(const void *addr);
29         uint32_t load_32(const void *addr);
30         uint64_t load_64(const void *addr);
31   
32         enum atomicop {
33                 ADD,
34                 CAS,
35                 EXC
36         };
37
38         uint8_t rmw_8(enum atomicop op, void *addr, uint8_t oldval, uint8_t valarg);
39         uint16_t rmw_16(enum atomicop op, void *addr, uint16_t oldval, uint16_t valarg);
40         uint32_t rmw_32(enum atomicop op, void *addr, uint32_t oldval, uint32_t valarg);
41         uint64_t rmw_64(enum atomicop op, void *addr, uint64_t oldval, uint64_t valarg);
42         MCID MC2_nextRMW(MCID addr, MCID oldval, MCID valarg);
43
44   MCID MC2_nextOpLoad(MCID addr);
45   void MC2_nextOpStore(MCID addr, MCID value);
46
47         MCID MC2_nextRMWOffset(MCID addr, uintptr_t offset, MCID oldval, MCID valarg);
48
49   MCID MC2_nextOpLoadOffset(MCID addr, uintptr_t offset);
50   void MC2_nextOpStoreOffset(MCID addr, uintptr_t offset, MCID value);
51   MCID MC2_branchUsesID(MCID condition, int direction, int num_directions, bool anyvalue);
52   void MC2_nextOpThrd_create(MCID startfunc, MCID param);
53   void MC2_nextOpThrd_join(MCID jointhrd);
54
55   void MC2_merge(MCID branchid);
56   MCID MC2_function(unsigned int num_args, int numbytesretval, uint64_t val, ...);
57         MCID MC2_function_id(unsigned int id, unsigned int num_args, int numbytesretval, uint64_t val, ...);
58         uint64_t MC2_equals(MCID op1, uint64_t val1, MCID op2, uint64_t val2, MCID *retval);
59         
60   MCID MC2_phi(MCID input);
61         MCID MC2_loop_phi(MCID input);
62
63   void MC2_yield();
64         void MC2_fence();
65   void MC2_enterLoop();
66   void MC2_exitLoop();
67   void MC2_loopIterate();
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif /* __LIBINTERFACE_H__ */