Get rid of the private file which I didn't want to import,
[cegcc.git] / cegcc / test / exception / stdio.c
blobd495a611300a827223fb14bb9d39f6492f3428c2
1 #include <windows.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 #include <excpt.h>
7 int i = 0;
8 FILE *f = NULL;
10 int handler(struct _EXCEPTION_RECORD *ExceptionRecord,
11 void *EstablisherFrame,
12 struct _CONTEXT *ContextRecord,
13 struct _DISPATCHER_CONTEXT *DispatcherContext)
15 fprintf(stderr, "Crash, count %d\nExc Code %x Addr %x Nparams %d\n",
17 ExceptionRecord->ExceptionCode,
18 ExceptionRecord->ExceptionAddress,
19 ExceptionRecord->NumberParameters);
20 i++;
21 return EXCEPTION_EXECUTE_HANDLER;
24 #define FN DATAPATH "/exc-log.txt"
26 int main(int argc, char *argv[])
27 __attribute__((__exception_handler__(handler)));
29 int main(int argc, char *argv[])
31 volatile int *i;
33 f = fopen(FN, "w");
34 if (f == NULL) {
35 fprintf(stderr, "File " FN " not open\n");
36 exit(0);
39 i = 0;
40 fprintf(stderr, "Start\n");
41 *i = 1;
42 fprintf(stderr, "Main: survived\n");
43 fclose(f);
44 exit(0);