* src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
[cacao.git] / src / native / jni.h
1 /* src/native/jni.h - JNI types and data structures
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: jni.h 7246 2007-01-29 18:49:05Z twisti $
26
27 */
28
29
30 /* GNU Classpath jni.h *********************************************************
31
32    ATTENTION: We include this file before we actually define our own
33    jni.h.  We do this because, otherwise we can get into unresolvable
34    circular header dependencies.
35
36    This is OK as GNU Classpath defines:
37
38    #define _CLASSPATH_JNI_H
39
40    CLASSPATH_JNI_H is in config.h defined.
41
42 *******************************************************************************/
43
44 #include "config.h"
45
46 #include CLASSPATH_JNI_H
47
48
49 #ifndef _JNI_H
50 #define _JNI_H
51
52 /* forward typedefs ***********************************************************/
53
54 typedef struct localref_table localref_table;
55
56
57 #include "vm/types.h"
58
59 #include "vm/global.h"
60
61 #include "vmcore/method.h"
62
63
64 /* _Jv_JNIEnv *****************************************************************/
65
66 typedef struct _Jv_JNIEnv _Jv_JNIEnv;
67
68 struct _Jv_JNIEnv {
69         const struct JNINativeInterface *env;     /* This MUST be the first entry */
70 };
71
72
73 /* _Jv_JavaVM *****************************************************************/
74
75 typedef struct _Jv_JavaVM _Jv_JavaVM;
76
77 struct _Jv_JavaVM {
78         const struct JNIInvokeInterface *functions;/* This MUST be the first entry*/
79
80         /* JVM instance-specific variables */
81
82         s8 starttime;                       /* VM startup time                    */
83
84         s4 Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose;
85         s4 Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
86         s4 java_lang_management_ThreadMXBean_PeakThreadCount;
87         s4 java_lang_management_ThreadMXBean_ThreadCount;
88         s8 java_lang_management_ThreadMXBean_TotalStartedThreadCount;
89         s4 Java_java_lang_VMClassLoader_defaultAssertionStatus;
90 };
91
92
93 /* CACAO related stuff ********************************************************/
94
95 extern const struct JNIInvokeInterface _Jv_JNIInvokeInterface;
96 extern struct JNINativeInterface _Jv_JNINativeInterface;
97
98
99 /* local reference table ******************************************************/
100
101 #define LOCALREFTABLE_CAPACITY    16
102
103 /* localref_table **************************************************************
104
105    ATTENTION: keep this structure a multiple of 8-bytes!!! This is
106    essential for the native stub on 64-bit architectures.
107
108 *******************************************************************************/
109
110 struct localref_table {
111         s4                 capacity;        /* table size                         */
112         s4                 used;            /* currently used references          */
113         s4                 localframes;     /* number of current frames           */
114         s4                 PADDING;         /* 8-byte padding                     */
115         localref_table    *prev;            /* link to prev table (LocalFrame)    */
116         java_objectheader *refs[LOCALREFTABLE_CAPACITY]; /* references            */
117 };
118
119 #if defined(ENABLE_THREADS)
120 #define LOCALREFTABLE    (THREADOBJECT->_localref_table)
121 #else
122 extern localref_table *_no_threads_localref_table;
123
124 #define LOCALREFTABLE    (_no_threads_localref_table)
125 #endif
126
127
128 /* hashtable_global_ref_entry *************************************************/
129
130 typedef struct hashtable_global_ref_entry hashtable_global_ref_entry;
131
132 struct hashtable_global_ref_entry {
133         java_objectheader          *o;      /* object pointer of global ref       */
134         s4                          refs;   /* references of the current pointer  */
135         hashtable_global_ref_entry *hashlink; /* link for external chaining       */
136 };
137
138
139 /* function prototypes ********************************************************/
140
141 /* initialize JNI subsystem */
142 bool jni_init(void);
143 bool jni_init_localref_table(void);
144
145 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
146                                                                                 java_objectarray *params);
147
148 #endif /* _JNI_H */
149
150
151 /*
152  * These are local overrides for various environment variables in Emacs.
153  * Please do not remove this and leave it at the end of the file, where
154  * Emacs will automagically detect them.
155  * ---------------------------------------------------------------------
156  * Local variables:
157  * mode: c
158  * indent-tabs-mode: t
159  * c-basic-offset: 4
160  * tab-width: 4
161  * End:
162  */