1 #define __STDC_FORMAT_MACROS
8 #include "threads-model.h"
10 void store_8(void *addr, uint8_t val)
12 DEBUG("addr = %p, val = %" PRIu8 "\n", addr, val);
13 thread_id_t tid = thread_current()->get_id();
14 raceCheckWrite(tid, addr);
15 (*(uint8_t *)addr) = val;
18 void store_16(void *addr, uint16_t val)
20 DEBUG("addr = %p, val = %" PRIu16 "\n", addr, val);
21 thread_id_t tid = thread_current()->get_id();
22 raceCheckWrite(tid, addr);
23 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 1));
24 (*(uint16_t *)addr) = val;
27 void store_32(void *addr, uint32_t val)
29 DEBUG("addr = %p, val = %" PRIu32 "\n", addr, val);
30 thread_id_t tid = thread_current()->get_id();
31 raceCheckWrite(tid, addr);
32 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 1));
33 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 2));
34 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 3));
35 (*(uint32_t *)addr) = val;
38 void store_64(void *addr, uint64_t val)
40 DEBUG("addr = %p, val = %" PRIu64 "\n", addr, val);
41 thread_id_t tid = thread_current()->get_id();
42 raceCheckWrite(tid, addr);
43 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 1));
44 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 2));
45 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 3));
46 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 4));
47 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 5));
48 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 6));
49 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 7));
50 (*(uint64_t *)addr) = val;
53 uint8_t load_8(const void *addr)
55 DEBUG("addr = %p\n", addr);
56 thread_id_t tid = thread_current()->get_id();
57 raceCheckRead(tid, addr);
58 return *((uint8_t *)addr);
61 uint16_t load_16(const void *addr)
63 DEBUG("addr = %p\n", addr);
64 thread_id_t tid = thread_current()->get_id();
65 raceCheckRead(tid, addr);
66 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 1));
67 return *((uint16_t *)addr);
70 uint32_t load_32(const void *addr)
72 DEBUG("addr = %p\n", addr);
73 thread_id_t tid = thread_current()->get_id();
74 raceCheckRead(tid, addr);
75 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 1));
76 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 2));
77 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 3));
78 return *((uint32_t *)addr);
81 uint64_t load_64(const void *addr)
83 DEBUG("addr = %p\n", addr);
84 thread_id_t tid = thread_current()->get_id();
85 raceCheckRead(tid, addr);
86 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 1));
87 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 2));
88 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 3));
89 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 4));
90 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 5));
91 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 6));
92 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 7));
93 return *((uint64_t *)addr);