blob: 9a4779a1c44e36614b991d2e48df1003a0fe0998 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#include "ghcconfig.h"
#include "Rts.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ITERATIONS 1000
#if defined(mingw32_HOST_OS)
#define OBJPATH L"Test.o"
#else
#define OBJPATH "Test.o"
#endif
typedef int testfun(int);
extern void loadPackages(void);
int main (int argc, char *argv[])
{
testfun *f;
int i, r;
RtsConfig conf = defaultRtsConfig;
conf.rts_opts_enabled = RtsOptsAll;
hs_init_ghc(&argc, &argv, conf);
initLinker_(0);
loadPackages();
for (i=0; i < ITERATIONS; i++) {
r = loadObj(OBJPATH);
if (!r) {
errorBelch("loadObj(%" PATH_FMT ") failed", OBJPATH);
exit(1);
}
r = resolveObjs();
if (!r) {
errorBelch("resolveObjs failed");
exit(1);
}
#if LEADING_UNDERSCORE
f = lookupSymbol("_f");
#else
f = lookupSymbol("f");
#endif
if (!f) {
errorBelch("lookupSymbol failed");
exit(1);
}
r = f(3);
if (r != 4) {
errorBelch("call failed; %d", r);
exit(1);
}
unloadObj(OBJPATH);
performMajorGC();
printf("%d ", i);
fflush(stdout);
}
for (i=0; i < ITERATIONS; i++) {
r = loadObj(OBJPATH);
if (!r) {
errorBelch("loadObj(%" PATH_FMT ") failed", OBJPATH);
exit(1);
}
r = resolveObjs();
if (!r) {
errorBelch("resolveObjs failed");
exit(1);
}
#if LEADING_UNDERSCORE
f = lookupSymbol("_f");
#else
f = lookupSymbol("f");
#endif
if (!f) {
errorBelch("lookupSymbol failed");
exit(1);
}
r = f(3);
if (r != 4) {
errorBelch("call failed; %d", r);
exit(1);
}
// check that we can purge first, then unload
purgeObj(OBJPATH);
performMajorGC();
unloadObj(OBJPATH);
performMajorGC();
printf("%d ", i);
fflush(stdout);
}
hs_exit();
exit(0);
}
|