Fixed HiFi modes.
[AROS.git] / compiler / purify / src / init.c
blob91c3ae5aefb26562145e92d109a704870df9535f
1 #include <stdio.h>
2 #include <ctype.h>
3 #include <errno.h>
4 #include "memory.h"
5 #include "hash.h"
7 #define Purify_Begincode _start
9 void Purify_Init (void)
11 extern void Purify_Begincode (void);
12 extern void Purify_Endcode (void);
13 extern int Purify_Beginrodata;
14 extern int Purify_Endrodata;
15 extern int Purify_Beginbss;
16 extern int Purify_Endbss;
17 extern int Purify_Begindata;
18 extern int Purify_Enddata;
19 extern int * Purify_Beginstaticdata;
20 extern int * Purify_Endstaticdata;
22 void * ptr;
23 int size;
24 MemHash * node;
26 printf ("Purify active\n");
28 Purify_Filename = "";
29 Purify_Functionname = "_start";
30 Purify_Lineno = 0;
32 ptr = (&Purify_Beginrodata)+1;
33 size = (long)(&Purify_Endrodata) - (long)(&Purify_Beginrodata) - 4;
35 if (size > 0)
37 node = Purify_AddMemory (ptr
38 , size
39 , PURIFY_MemFlag_Readable
40 , PURIFY_MemType_Data
43 node->data = "rodata";
46 ptr = (&Purify_Beginbss)+1;
47 size = (long)(&Purify_Endbss) - (long)(&Purify_Beginbss) - 4;
49 if (size > 0)
51 node = Purify_AddMemory (ptr
52 , size
53 , PURIFY_MemFlag_Readable
54 | PURIFY_MemFlag_Writable
55 , PURIFY_MemType_Data
58 node->data = "bss";
61 ptr = (&Purify_Begindata)+1;
62 size = (long)(&Purify_Enddata) - (long)(&Purify_Begindata) - 4;
64 if (size > 0)
66 node = Purify_AddMemory (ptr
67 , size
68 , PURIFY_MemFlag_Readable
69 | PURIFY_MemFlag_Writable
70 , PURIFY_MemType_Data
73 node->data = "data";
76 size = (long)(Purify_Endstaticdata) - (long)(Purify_Beginstaticdata) - 4;
78 if (size > 0)
80 node = Purify_AddMemory (Purify_Beginstaticdata+1
81 , size
82 , PURIFY_MemFlag_Readable
83 | PURIFY_MemFlag_Writable
84 , PURIFY_MemType_Data
87 node->data = "static data";
90 size = (long)Purify_Endcode - (long)Purify_Begincode;
92 if (size > 0)
94 node = Purify_AddMemory (Purify_Begincode
95 , size
96 , PURIFY_MemFlag_Readable
97 , PURIFY_MemType_Code
100 node->data = "code";
103 node = Purify_AddMemory (__ctype_b
104 , sizeof(__ctype_b[0])*256
105 , PURIFY_MemFlag_Readable
106 , PURIFY_MemType_Data
109 node->data = "ctype array";
111 node = Purify_AddMemory (__ctype_tolower
112 , sizeof(__ctype_tolower[0])*256
113 , PURIFY_MemFlag_Readable
114 , PURIFY_MemType_Data
117 node->data = "tolower array";
119 node = Purify_AddMemory (__ctype_toupper
120 , sizeof(__ctype_toupper[0])*256
121 , PURIFY_MemFlag_Readable
122 , PURIFY_MemType_Data
125 node->data = "toupper array";
127 #define ADDGLOBAL(var,name) \
128 node = Purify_AddMemory (&(var) \
129 , sizeof(var) \
130 , PURIFY_MemFlag_Readable|PURIFY_MemFlag_Writable \
131 , PURIFY_MemType_Data \
132 ); \
134 node->data = name
136 ADDGLOBAL(errno,"errno");
138 node = Purify_AddMemory (stdin
139 , sizeof(stdin)
140 , PURIFY_MemFlag_Readable
141 , PURIFY_MemType_Data
144 node->data = "stdin";
146 node = Purify_AddMemory (stdout
147 , sizeof(stdout)
148 , PURIFY_MemFlag_Readable
149 , PURIFY_MemType_Data
152 node->data = "stdout";
154 Purify_PrintMemory ();
157 void Purify_Exit (void)
159 printf ("Purify finished\n");
161 Purify_MemoryExit ();