1 /*
2 * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
3 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
4 * Copyright (c) 1998 by Fergus Henderson. All rights reserved.
5 * Copyright (c) 2000-2009 by Hewlett-Packard Development Company.
6 * All rights reserved.
7 *
8 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
9 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 *
11 * Permission is hereby granted to use or copy this program
12 * for any purpose, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 */
17 18 #ifndef GC_JAVAXFC_H
19 #define GC_JAVAXFC_H
20 21 #ifndef GC_H
22 # include "gc.h"
23 #endif
24 25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 29 /**
30 * Invoke all remaining finalizers that have not yet been run. (Since the
31 * notifier is not called, this should be called from a separate thread.)
32 * This function is needed for strict compliance with the Java standard,
33 * which can make the runtime guarantee that all finalizers are run.
34 * This is problematic for several reasons:
35 * 1. It means that finalizers, and all methods called by them, must be
36 * prepared to deal with objects that have been finalized in spite of
37 * the fact that they are still referenced by statically allocated
38 * pointer variables (i.e. finalizers run at this point must be
39 * prepared to deal with a mostly broken world);
40 * 2. The Java standard implies we have to keep running finalizers until
41 * there are no more left, thus it may mean that we get stuck in
42 * an infinite loop running finalizers that create new finalizable
43 * objects, though that is probably unlikely.
44 * Thus this is not recommended for general use.
45 * Acquires the allocator lock (to enqueue all finalizers).
46 */
47 GC_API void GC_CALL GC_finalize_all(void);
48 49 #ifdef GC_THREADS
50 /**
51 * External thread suspension support. No thread suspension count
52 * (so a thread which has been suspended numerous times will be resumed
53 * with the very first call to `GC_resume_thread()`). Acquires the
54 * allocator lock. Thread should be registered in the collector.
55 * Unimplemented on some platforms. Not recommended for general use.
56 */
57 # ifndef GC_SUSPEND_THREAD_ID
58 # define GC_SUSPEND_THREAD_ID void *
59 # endif
60 GC_API void GC_CALL GC_suspend_thread(GC_SUSPEND_THREAD_ID);
61 GC_API void GC_CALL GC_resume_thread(GC_SUSPEND_THREAD_ID);
62 63 /**
64 * Is the given thread suspended externally? The result is either
65 * 1 (true) or 0. Acquires the allocator lock in the reader mode.
66 * Note: returns 0 (false) if the thread is not registered in the collector.
67 * Unimplemented on some platforms (same as `GC_suspend_thread()`).
68 */
69 GC_API int GC_CALL GC_is_thread_suspended(GC_SUSPEND_THREAD_ID);
70 #endif /* GC_THREADS */
71 72 #ifdef __cplusplus
73 } /* extern "C" */
74 #endif
75 76 #endif /* GC_JAVAXFC_H */
77