tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / compiler / purify / src / init.c
blob542914477fd244874516728fecafd805e80b9e57
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <ctype.h>
8 #include <errno.h>
9 #include "memory.h"
10 #include "hash.h"
12 #define Purify_Begincode _start
14 void Purify_Init (void)
16 extern void Purify_Begincode (void);
17 extern void Purify_Endcode (void);
18 extern int Purify_Beginrodata;
19 extern int Purify_Endrodata;
20 extern int Purify_Beginbss;
21 extern int Purify_Endbss;
22 extern int Purify_Begindata;
23 extern int Purify_Enddata;
24 extern int * Purify_Beginstaticdata;
25 extern int * Purify_Endstaticdata;
27 void * ptr;
28 int size;
29 MemHash * node;
31 printf ("Purify active\n");
33 Purify_Filename = "";
34 Purify_Functionname = "_start";
35 Purify_Lineno = 0;
37 ptr = (&Purify_Beginrodata)+1;
38 size = (long)(&Purify_Endrodata) - (long)(&Purify_Beginrodata) - 4;
40 if (size > 0)
42 node = Purify_AddMemory (ptr
43 , size
44 , PURIFY_MemFlag_Readable
45 , PURIFY_MemType_Data
48 node->data = "rodata";
51 ptr = (&Purify_Beginbss)+1;
52 size = (long)(&Purify_Endbss) - (long)(&Purify_Beginbss) - 4;
54 if (size > 0)
56 node = Purify_AddMemory (ptr
57 , size
58 , PURIFY_MemFlag_Readable
59 | PURIFY_MemFlag_Writable
60 , PURIFY_MemType_Data
63 node->data = "bss";
66 ptr = (&Purify_Begindata)+1;
67 size = (long)(&Purify_Enddata) - (long)(&Purify_Begindata) - 4;
69 if (size > 0)
71 node = Purify_AddMemory (ptr
72 , size
73 , PURIFY_MemFlag_Readable
74 | PURIFY_MemFlag_Writable
75 , PURIFY_MemType_Data
78 node->data = "data";
81 size = (long)(Purify_Endstaticdata) - (long)(Purify_Beginstaticdata) - 4;
83 if (size > 0)
85 node = Purify_AddMemory (Purify_Beginstaticdata+1
86 , size
87 , PURIFY_MemFlag_Readable
88 | PURIFY_MemFlag_Writable
89 , PURIFY_MemType_Data
92 node->data = "static data";
95 size = (long)Purify_Endcode - (long)Purify_Begincode;
97 if (size > 0)
99 node = Purify_AddMemory (Purify_Begincode
100 , size
101 , PURIFY_MemFlag_Readable
102 , PURIFY_MemType_Code
105 node->data = "code";
108 node = Purify_AddMemory (__ctype_b
109 , sizeof(__ctype_b[0])*256
110 , PURIFY_MemFlag_Readable
111 , PURIFY_MemType_Data
114 node->data = "ctype array";
116 node = Purify_AddMemory (__ctype_tolower
117 , sizeof(__ctype_tolower[0])*256
118 , PURIFY_MemFlag_Readable
119 , PURIFY_MemType_Data
122 node->data = "tolower array";
124 node = Purify_AddMemory (__ctype_toupper
125 , sizeof(__ctype_toupper[0])*256
126 , PURIFY_MemFlag_Readable
127 , PURIFY_MemType_Data
130 node->data = "toupper array";
132 #define ADDGLOBAL(var,name) \
133 node = Purify_AddMemory (&(var) \
134 , sizeof(var) \
135 , PURIFY_MemFlag_Readable|PURIFY_MemFlag_Writable \
136 , PURIFY_MemType_Data \
137 ); \
139 node->data = name
141 ADDGLOBAL(errno,"errno");
143 node = Purify_AddMemory (stdin
144 , sizeof(stdin)
145 , PURIFY_MemFlag_Readable
146 , PURIFY_MemType_Data
149 node->data = "stdin";
151 node = Purify_AddMemory (stdout
152 , sizeof(stdout)
153 , PURIFY_MemFlag_Readable
154 , PURIFY_MemType_Data
157 node->data = "stdout";
159 Purify_PrintMemory ();
162 void Purify_Exit (void)
164 printf ("Purify finished\n");
166 Purify_MemoryExit ();