2015-01-23 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / libjava / nogc.cc
blob079422d0911d1e0a47c21e9c564e76910f5ddadb
1 // nogc.cc - Implement null garbage collector.
3 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006, 2007
4 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10 details. */
12 #include <config.h>
14 #include <stdio.h>
15 #include <stdlib.h>
17 #include <gcj/cni.h>
18 #include <jvm.h>
20 // Total amount of memory allocated.
21 static long total = 0;
23 void *
24 _Jv_BuildGCDescr(jclass)
26 return 0;
29 void *
30 _Jv_AllocObj (jsize size, jclass klass)
32 total += size;
33 void *obj = calloc (size, 1);
34 if (!obj) _Jv_ThrowNoMemory();
35 *((_Jv_VTable **) obj) = klass->vtable;
36 return obj;
39 void *
40 _Jv_AllocPtrFreeObj (jsize size, jclass klass)
42 total += size;
43 void *obj = calloc (size, 1);
44 if (!obj) _Jv_ThrowNoMemory();
45 *((_Jv_VTable **) obj) = klass->vtable;
46 return obj;
49 void *
50 _Jv_AllocArray (jsize size, jclass klass)
52 total += size;
53 void *obj = calloc (size, 1);
54 if (!obj) _Jv_ThrowNoMemory();
55 *((_Jv_VTable **) obj) = klass->vtable;
56 return obj;
59 void *
60 _Jv_AllocBytes (jsize size)
62 total += size;
63 void *obj = calloc (size, 1);
64 if (!obj) _Jv_ThrowNoMemory();
65 return obj;
68 void *
69 _Jv_AllocRawObj (jsize size)
71 total += size;
72 return calloc (size, 1);
75 _Jv_ClosureList **
76 _Jv_ClosureListFinalizer ()
78 _Jv_ClosureList **clpp;
79 clpp = (_Jv_ClosureList **)_Jv_AllocBytes (sizeof (*clpp));
80 return clpp;
83 void
84 _Jv_RegisterFinalizer (void *, _Jv_FinalizerFunc *)
86 // FIXME: should actually register so that finalizers can be run on
87 // exit.
90 void
91 _Jv_RunFinalizers (void)
95 void
96 _Jv_RunAllFinalizers (void)
98 // FIXME: should still run all finalizers.
101 void
102 _Jv_GCInitializeFinalizers (void (*) (void))
106 void
107 _Jv_RunGC (void)
111 long
112 _Jv_GCTotalMemory (void)
114 return total;
117 long
118 _Jv_GCFreeMemory (void)
120 return 0;
123 void
124 _Jv_GCSetInitialHeapSize (size_t)
128 void
129 _Jv_GCSetMaximumHeapSize (size_t)
133 void
134 _Jv_DisableGC (void)
138 void
139 _Jv_EnableGC (void)
143 void
144 _Jv_InitGC (void)
148 void
149 _Jv_GCRegisterDisappearingLink (jobject *)
153 jboolean
154 _Jv_GCCanReclaimSoftReference (jobject)
156 // For now, always reclaim soft references. FIXME.
157 return true;
160 #ifdef JV_HASH_SYNCHRONIZATION
161 void *
162 _Jv_AllocTraceOne (jsize size /* includes vtable slot */)
164 void *obj = calloc(size, 1);
165 if (!obj) _Jv_ThrowNoMemory();
166 return result;
169 void *
170 _Jv_AllocTraceTwo (jsize size /* includes vtable slot */)
172 void *obj = calloc(size, 1);
173 if (!obj) _Jv_ThrowNoMemory();
174 return result;
176 #endif /* JV_HASH_SYNCHRONIZATION */
178 void
179 _Jv_SuspendThread (_Jv_Thread_t *thread)
183 void
184 _Jv_ResumeThread (_Jv_Thread_t *thread)
189 _Jv_IsThreadSuspended (_Jv_Thread_t *thread)
191 return 0;