Permalink
Browse files

Fix 07-writebarrier.t for Win32.

  • Loading branch information...
1 parent 32bbd4f commit 95df414c103bcff66bc1445a88db4024bfdbc616 @jnthn committed Sep 25, 2012
Showing with 13 additions and 7 deletions.
  1. +13 −7 t/07-writebarrier.c
View
@@ -1,27 +1,33 @@
#include <stdlib.h>
+#ifdef WIN32
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT extern
+#endif
+
typedef struct {
long *ptr;
} Structy;
static Structy *saved = NULL;
-long _deref(long *ptr) {
+DLLEXPORT long _deref(long *ptr) {
return *ptr;
}
-long *make_ptr() {
+DLLEXPORT long *make_ptr() {
long *ptr = (long *) malloc(sizeof(long));
*ptr = 32;
return ptr;
}
-void struct_twiddle(Structy *s) {
+DLLEXPORT void struct_twiddle(Structy *s) {
s->ptr = (long *) malloc(sizeof(long));
*(s->ptr) = 9;
}
-void array_twiddle(long **arr) {
+DLLEXPORT void array_twiddle(long **arr) {
arr[0] = (long *) malloc(sizeof(long));
arr[1] = (long *) malloc(sizeof(long));
arr[2] = (long *) malloc(sizeof(long));
@@ -31,15 +37,15 @@ void array_twiddle(long **arr) {
*arr[2] = 3;
}
-void dummy(void **arr) {
+DLLEXPORT void dummy(void **arr) {
/* dummy */
}
-void save_ref(Structy *s) {
+DLLEXPORT void save_ref(Structy *s) {
saved = s;
}
-void atadistance(void) {
+DLLEXPORT void atadistance(void) {
saved->ptr = (long *) malloc(sizeof(long));
*(saved->ptr) = 42;
}

0 comments on commit 95df414

Please sign in to comment.