comparison lphobos/gc/gcstub.d @ 94:61615fa85940 trunk

[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca"). Added support for array .sort and .reverse properties. Fixed some bugs with pointer arithmetic. Disabled some DMD AST optimizations that was messing things up, destroying valuable information. Added a KDevelop project file, this is what I use for coding LLVMDC now :) Other minor stuff.
author lindquist
date Mon, 12 Nov 2007 06:32:46 +0100
parents
children
comparison
equal deleted inserted replaced
93:08508eebbb3e 94:61615fa85940
1 /*
2 * Copyright (C) 2004 by Digital Mars, www.digitalmars.com
3 * Written by Walter Bright
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * o The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 * o Altered source versions must be plainly marked as such, and must not
18 * be misrepresented as being the original software.
19 * o This notice may not be removed or altered from any source
20 * distribution.
21 */
22
23 // D Garbage Collector stub to prevent linking in gc
24
25 module gcx;
26
27 //debug=PRINTF;
28
29 /***************************************************/
30
31 import object;
32
33 version (Win32)
34 {
35 import win32;
36 }
37
38 version (linux)
39 {
40 import gclinux;
41 }
42
43
44 //alias GC* gc_t;
45 alias GC gc_t;
46
47 struct GCStats { }
48
49 /* ============================ GC =============================== */
50
51
52 //alias int size_t;
53 alias void (*GC_FINALIZER)(void *p, void *dummy);
54
55 const uint GCVERSION = 1; // increment every time we change interface
56 // to GC.
57
58 class GC
59 {
60 uint gcversion = GCVERSION;
61
62 void *gcx; // implementation
63
64 void initialize()
65 {
66 debug(PRINTF) printf("initialize()\n");
67 }
68
69
70 void Dtor()
71 {
72 debug(PRINTF) printf("Dtor()\n");
73 }
74
75 /+invariant
76 {
77 debug(PRINTF) printf("invariant()\n");
78 }+/
79
80 void *malloc(size_t size)
81 {
82 debug(PRINTF) printf("malloc()\n");
83 return null;
84 }
85
86 void *mallocNoSync(size_t size)
87 {
88 debug(PRINTF) printf("mallocNoSync()\n");
89 return null;
90 }
91
92
93 void *calloc(size_t size, size_t n)
94 {
95 debug(PRINTF) printf("calloc()\n");
96 return null;
97 }
98
99
100 void *realloc(void *p, size_t size)
101 {
102 debug(PRINTF) printf("realloc()\n");
103 return null;
104 }
105
106
107 void free(void *p)
108 {
109 debug(PRINTF) printf("free()\n");
110 }
111
112 size_t capacity(void *p)
113 {
114 debug(PRINTF) printf("capacity()\n");
115 return 0;
116 }
117
118 void check(void *p)
119 {
120 debug(PRINTF) printf("check()\n");
121 }
122
123
124 void setStackBottom(void *p)
125 {
126 debug(PRINTF) printf("setStackBottom()\n");
127 }
128
129 static void scanStaticData(gc_t g)
130 {
131 void *pbot;
132 void *ptop;
133 uint nbytes;
134
135 debug(PRINTF) printf("scanStaticData()\n");
136 //debug(PRINTF) printf("+GC.scanStaticData()\n");
137 os_query_staticdataseg(&pbot, &nbytes);
138 ptop = pbot + nbytes;
139 g.addRange(pbot, ptop);
140 //debug(PRINTF) printf("-GC.scanStaticData()\n");
141 }
142
143 static void unscanStaticData(gc_t g)
144 {
145 void *pbot;
146 uint nbytes;
147
148 debug(PRINTF) printf("unscanStaticData()\n");
149 os_query_staticdataseg(&pbot, &nbytes);
150 g.removeRange(pbot);
151 }
152
153
154 void addRoot(void *p) // add p to list of roots
155 {
156 debug(PRINTF) printf("addRoot()\n");
157 }
158
159 void removeRoot(void *p) // remove p from list of roots
160 {
161 debug(PRINTF) printf("removeRoot()\n");
162 }
163
164 void addRange(void *pbot, void *ptop) // add range to scan for roots
165 {
166 debug(PRINTF) printf("addRange()\n");
167 }
168
169 void removeRange(void *pbot) // remove range
170 {
171 debug(PRINTF) printf("removeRange()\n");
172 }
173
174 void fullCollect() // do full garbage collection
175 {
176 debug(PRINTF) printf("fullCollect()\n");
177 }
178
179 void fullCollectNoStack() // do full garbage collection
180 {
181 debug(PRINTF) printf("fullCollectNoStack()\n");
182 }
183
184 void genCollect() // do generational garbage collection
185 {
186 debug(PRINTF) printf("genCollect()\n");
187 }
188
189 void minimize() // minimize physical memory usage
190 {
191 debug(PRINTF) printf("minimize()\n");
192 }
193
194 void setFinalizer(void *p, GC_FINALIZER pFn)
195 {
196 debug(PRINTF) printf("setFinalizer()\n");
197 }
198
199 void enable()
200 {
201 debug(PRINTF) printf("enable()\n");
202 }
203
204 void disable()
205 {
206 debug(PRINTF) printf("disable()\n");
207 }
208
209 void getStats(out GCStats stats)
210 {
211 debug(PRINTF) printf("getStats()\n");
212 }
213 }