librace: add load/store interface for checking data races
authorBrian Norris <banorris@uci.edu>
Wed, 25 Apr 2012 23:55:46 +0000 (16:55 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 25 Apr 2012 23:55:46 +0000 (16:55 -0700)
The compiler portion will need to replace loads/stores with calls to the
store_X() and load_X() functions.

Makefile
librace.cc [new file with mode: 0644]
librace.h [new file with mode: 0644]

index 52120a5fdde3ed631f5e11caab908d3c2958a5ec..1f91c5dd6b86b22182c0813e0d2906bfbed7664d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,9 +8,9 @@ LIB_SO=lib$(LIB_NAME).so
 USER_O=userprog.o
 USER_H=libthreads.h libatomic.h
 
-MODEL_CC=libthreads.cc schedule.cc libatomic.cc model.cc malloc.c threads.cc tree.cc
-MODEL_O=libthreads.o schedule.o libatomic.o model.o malloc.o threads.o tree.o
-MODEL_H=libthreads.h schedule.h common.h libatomic.h model.h threads.h tree.h
+MODEL_CC=libthreads.cc schedule.cc libatomic.cc model.cc malloc.c threads.cc tree.cc librace.cc
+MODEL_O=libthreads.o schedule.o libatomic.o model.o malloc.o threads.o tree.o librace.o
+MODEL_H=libthreads.h schedule.h common.h libatomic.h model.h threads.h tree.h librace.h
 
 CPPFLAGS=-Wall -g
 LDFLAGS=-ldl
diff --git a/librace.cc b/librace.cc
new file mode 100644 (file)
index 0000000..1219bf3
--- /dev/null
@@ -0,0 +1,46 @@
+#include "librace.h"
+#include "common.h"
+
+void store_8(void *addr, uint8_t val)
+{
+       DEBUG("addr = %p, val = %u\n", addr, val);
+}
+
+void store_16(void *addr, uint16_t val)
+{
+       DEBUG("addr = %p, val = %u\n", addr, val);
+}
+
+void store_32(void *addr, uint32_t val)
+{
+       DEBUG("addr = %p, val = %u\n", addr, val);
+}
+
+void store_64(void *addr, uint64_t val)
+{
+       DEBUG("addr = %p, val = %llu\n", addr, val);
+}
+
+uint8_t load_8(void *addr)
+{
+       DEBUG("addr = %p\n", addr);
+       return 0;
+}
+
+uint16_t load_16(void *addr)
+{
+       DEBUG("addr = %p\n", addr);
+       return 0;
+}
+
+uint32_t load_32(void *addr)
+{
+       DEBUG("addr = %p\n", addr);
+       return 0;
+}
+
+uint64_t load_64(void *addr)
+{
+       DEBUG("addr = %p\n", addr);
+       return 0;
+}
diff --git a/librace.h b/librace.h
new file mode 100644 (file)
index 0000000..a8af686
--- /dev/null
+++ b/librace.h
@@ -0,0 +1,24 @@
+#ifndef __LIBRACE_H__
+#define __LIBRACE_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+       void store_8(void *addr, uint8_t val);
+       void store_16(void *addr, uint16_t val);
+       void store_32(void *addr, uint32_t val);
+       void store_64(void *addr, uint64_t val);
+
+       uint8_t load_8(void *addr);
+       uint16_t load_16(void *addr);
+       uint32_t load_32(void *addr);
+       uint64_t load_64(void *addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBRACE_H__ */