OBJECTS = libthreads.o schedule.o model.o threads.o librace.o action.o \
nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
datarace.o impatomic.o cmodelint.o \
- snapshot.o malloc.o mymemory.o common.o mutex.o promise.o conditionvariable.o
+ snapshot.o malloc.o mymemory.o common.o mutex.o promise.o conditionvariable.o \
+ context.o
CPPFLAGS += -Iinclude -I.
LDFLAGS = -ldl -lrt -rdynamic
--- /dev/null
+#include "context.h"
+
+#ifdef MAC
+
+int model_swapcontext(ucontext_t *oucp, ucontext_t *ucp)
+{
+ /*
+ * Mac OSX swapcontext() clobbers some registers, so use a hand-rolled
+ * version with {get,set}context(). We can avoid the same problem
+ * (where optimizations can break the following code) because we don't
+ * statically link with the C library
+ */
+
+ /* volatile, so that 'i' doesn't get promoted to a register */
+ volatile int i = 0;
+
+ getcontext(oucp);
+
+ if (i == 0) {
+ i = 1;
+ setcontext(ucp);
+ }
+
+ return 0;
+}
+
+#endif /* MAC */
#include <ucontext.h>
-static inline int model_swapcontext(ucontext_t *oucp, ucontext_t *ucp)
-{
#ifdef MAC
- /*
- * Mac OSX swapcontext() clobbers some registers, so use a hand-rolled
- * version with {get,set}context(). We can avoid the same problem
- * (where optimizations can break the following code) because we don't
- * statically link with the C library
- */
-
- /* volatile, so that 'i' doesn't get promoted to a register */
- volatile int i = 0;
- getcontext(oucp);
+int model_swapcontext(ucontext_t *oucp, ucontext_t *ucp);
- if (i == 0) {
- i = 1;
- setcontext(ucp);
- }
+#else /* !MAC */
- return 0;
-#else
+static inline int model_swapcontext(ucontext_t *oucp, ucontext_t *ucp)
+{
return swapcontext(oucp, ucp);
-#endif
}
+#endif /* !MAC */
+
#endif /* __CONTEXT_H__ */