2 #include "structdefs.h"
13 extern int classsize[];
14 jmp_buf error_handler;
19 float failurechance=0;
21 int injectinstructionfailures;
23 float instfailurechance=0;
31 void initializeexithandler() {}
33 void exithandler(int sig, siginfo_t *info, void * uap) {
35 printf("exit in exithandler\n");
40 void initializeexithandler() {
42 sig.sa_sigaction=&exithandler;
43 sig.sa_flags=SA_SIGINFO;
44 sigemptyset(&sig.sa_mask);
45 sigaction(SIGUSR2, &sig, 0);
49 /* This function inject failures */
51 void injectinstructionfailure() {
53 // not supported in RAW version
57 if (injectinstructionfailures) {
60 instructioncount=failurecount;
61 instaccum+=failurecount;
62 if ((((double)random())/RAND_MAX)<instfailurechance) {
65 printf("FAILURE!!! %d\n",numfailures);
66 longjmp(error_handler,11);
71 if (injectinstructionfailures) {
74 instaccum+=failurecount;
75 if ((((double)random())/RAND_MAX)<instfailurechance) {
78 printf("FAILURE!!! %d\n",numfailures);
87 void CALL11(___System______exit____I,int ___status___, int ___status___) {
89 printf("exit in CALL11\n");
92 raw_test_done(___status___);
98 void CALL11(___System______printI____I,int ___status___, int ___status___) {
100 printf("printI in CALL11\n");
103 raw_test_pass(0x1111);
104 raw_test_pass_reg(___status___);
106 printf("%d\n", ___status___);
110 long CALL00(___System______currentTimeMillis____) {
112 // not supported in RAW version
115 struct timeval tv; long long retval;
116 gettimeofday(&tv, NULL);
117 retval = tv.tv_sec; /* seconds */
118 retval*=1000; /* milliseconds */
119 retval+= (tv.tv_usec/1000); /* adjust milliseconds & add them in */
124 void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
127 struct ArrayObject * chararray=VAR(___s___)->___value___;
129 int offset=VAR(___s___)->___offset___;
130 for(i=0;i<VAR(___s___)->___count___;i++) {
131 short sc=((short *)(((char *)& chararray->___length___)+sizeof(int)))[i+offset];
137 /* Object allocation function */
140 void * allocate_new(void * ptr, int type) {
141 struct ___Object___ * v=(struct ___Object___ *) mygcmalloc((struct garbagelist *) ptr, classsize[type]);
153 /* Array allocation function */
155 struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
156 struct ArrayObject * v=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]);
162 printf("ERROR: negative array\n");
166 v->___length___=length;
176 void * allocate_new(int type) {
177 struct ___Object___ * v=FREEMALLOC(classsize[type]);
184 /* Array allocation function */
186 struct ArrayObject * allocate_newarray(int type, int length) {
187 struct ArrayObject * v=FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
191 v->___length___=length;
197 /* Converts C character arrays into Java strings */
199 struct ___String___ * NewString(void * ptr, const char *str,int length) {
201 struct ___String___ * NewString(const char *str,int length) {
205 struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
206 int ptrarray[]={1, (int) ptr, (int) chararray};
207 struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
208 chararray=(struct ArrayObject *) ptrarray[2];
210 struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
211 struct ___String___ * strobj=allocate_new(STRINGTYPE);
213 strobj->___value___=chararray;
214 strobj->___count___=length;
215 strobj->___offset___=0;
217 for(i=0;i<length;i++) {
218 ((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i]; }
222 /* Generated code calls this if we fail a bounds check */
224 void failedboundschk() {
226 printf("Array out of bounds\n");
233 longjmp(error_handler,2);
237 /* Abort task call */
240 longjmp(error_handler,4);
242 printf("Aborting\n");