Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 52 lines (40 sloc) 0.912 kb
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
1 #include <stdlib.h>
2
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
3 #ifdef WIN32
4 #define DLLEXPORT __declspec(dllexport)
5 #else
6 #define DLLEXPORT extern
7 #endif
8
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
9 typedef struct {
10 long *ptr;
11 } Structy;
12
3bf6712 Arne Skjærholt Expose refresh op through function, tests for refresh().
arnsholt authored
13 static Structy *saved = NULL;
14
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
15 DLLEXPORT long _deref(long *ptr) {
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
16 return *ptr;
17 }
18
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
19 DLLEXPORT long *make_ptr() {
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
20 long *ptr = (long *) malloc(sizeof(long));
21 *ptr = 32;
22 return ptr;
23 }
24
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
25 DLLEXPORT void struct_twiddle(Structy *s) {
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
26 s->ptr = (long *) malloc(sizeof(long));
27 *(s->ptr) = 9;
28 }
29
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
30 DLLEXPORT void array_twiddle(long **arr) {
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
31 arr[0] = (long *) malloc(sizeof(long));
32 arr[1] = (long *) malloc(sizeof(long));
33 arr[2] = (long *) malloc(sizeof(long));
34
35 *arr[0] = 1;
36 *arr[1] = 2;
37 *arr[2] = 3;
38 }
39
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
40 DLLEXPORT void dummy(void **arr) {
3b4926f Arne Skjærholt Add tests for write-barriering of CArray and CStruct types.
arnsholt authored
41 /* dummy */
42 }
3bf6712 Arne Skjærholt Expose refresh op through function, tests for refresh().
arnsholt authored
43
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
44 DLLEXPORT void save_ref(Structy *s) {
3bf6712 Arne Skjærholt Expose refresh op through function, tests for refresh().
arnsholt authored
45 saved = s;
46 }
47
95df414 Jonathan Worthington Fix 07-writebarrier.t for Win32.
authored
48 DLLEXPORT void atadistance(void) {
3bf6712 Arne Skjærholt Expose refresh op through function, tests for refresh().
arnsholt authored
49 saved->ptr = (long *) malloc(sizeof(long));
50 *(saved->ptr) = 42;
51 }
Something went wrong with that request. Please try again.