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 ClockVector *cv = model->get_cv(tid);
15 raceCheckWrite(tid, addr, cv);
16 (*(uint8_t *)addr) = val;
19 void store_16(void *addr, uint16_t val)
21 DEBUG("addr = %p, val = %" PRIu16 "\n", addr, val);
22 thread_id_t tid = thread_current()->get_id();
23 ClockVector *cv = model->get_cv(tid);
24 raceCheckWrite(tid, addr, cv);
25 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 1), cv);
26 (*(uint16_t *)addr) = val;
29 void store_32(void *addr, uint32_t val)
31 DEBUG("addr = %p, val = %" PRIu32 "\n", addr, val);
32 thread_id_t tid = thread_current()->get_id();
33 ClockVector *cv = model->get_cv(tid);
34 raceCheckWrite(tid, addr, cv);
35 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 1), cv);
36 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 2), cv);
37 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 3), cv);
38 (*(uint32_t *)addr) = val;
41 void store_64(void *addr, uint64_t val)
43 DEBUG("addr = %p, val = %" PRIu64 "\n", addr, val);
44 thread_id_t tid = thread_current()->get_id();
45 ClockVector *cv = model->get_cv(tid);
46 raceCheckWrite(tid, addr, cv);
47 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 1), cv);
48 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 2), cv);
49 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 3), cv);
50 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 4), cv);
51 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 5), cv);
52 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 6), cv);
53 raceCheckWrite(tid, (void *)(((uintptr_t)addr) + 7), cv);
54 (*(uint64_t *)addr) = val;
57 uint8_t load_8(const void *addr)
59 DEBUG("addr = %p\n", addr);
60 thread_id_t tid = thread_current()->get_id();
61 ClockVector *cv = model->get_cv(tid);
62 raceCheckRead(tid, addr, cv);
63 return *((uint8_t *)addr);
66 uint16_t load_16(const void *addr)
68 DEBUG("addr = %p\n", addr);
69 thread_id_t tid = thread_current()->get_id();
70 ClockVector *cv = model->get_cv(tid);
71 raceCheckRead(tid, addr, cv);
72 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 1), cv);
73 return *((uint16_t *)addr);
76 uint32_t load_32(const void *addr)
78 DEBUG("addr = %p\n", addr);
79 thread_id_t tid = thread_current()->get_id();
80 ClockVector *cv = model->get_cv(tid);
81 raceCheckRead(tid, addr, cv);
82 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 1), cv);
83 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 2), cv);
84 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 3), cv);
85 return *((uint32_t *)addr);
88 uint64_t load_64(const void *addr)
90 DEBUG("addr = %p\n", addr);
91 thread_id_t tid = thread_current()->get_id();
92 ClockVector *cv = model->get_cv(tid);
93 raceCheckRead(tid, addr, cv);
94 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 1), cv);
95 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 2), cv);
96 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 3), cv);
97 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 4), cv);
98 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 5), cv);
99 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 6), cv);
100 raceCheckRead(tid, (const void *)(((uintptr_t)addr) + 7), cv);
101 return *((uint64_t *)addr);