d9bc29bea6d7b116f96e49c09b49822341c0f799
[cacao.git] / src / native / jni.h
1 /* src/native/jni.h - JNI types and data structures
2
3    Copyright (C) 1996-2005, 2006 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    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Roman Obermaisser
29             Christian Thalinger
30
31    $Id: jni.h 6167 2006-12-10 23:20:31Z twisti $
32
33 */
34
35
36 /* GNU Classpath jni.h *********************************************************
37
38    ATTENTION: We include this file before we actually define our own
39    jni.h.  We do this because, otherwise we can get into unresolvable
40    circular header dependencies.
41
42    This is OK as GNU Classpath defines:
43
44    #define _CLASSPATH_JNI_H
45
46    CLASSPATH_JNI_H is in config.h defined.
47
48 *******************************************************************************/
49
50 #include "config.h"
51
52 #include CLASSPATH_JNI_H
53
54
55 #ifndef _JNI_H
56 #define _JNI_H
57
58 /* forward typedefs ***********************************************************/
59
60 typedef struct localref_table localref_table;
61
62
63 #include "vm/types.h"
64
65 #include "vm/global.h"
66 #include "vm/method.h"
67
68
69 /* _Jv_JNIEnv *****************************************************************/
70
71 typedef struct _Jv_JNIEnv _Jv_JNIEnv;
72
73 struct _Jv_JNIEnv {
74         const struct JNINativeInterface *env;     /* This MUST be the first entry */
75 };
76
77
78 /* _Jv_JavaVM *****************************************************************/
79
80 typedef struct _Jv_JavaVM _Jv_JavaVM;
81
82 struct _Jv_JavaVM {
83         const struct JNIInvokeInterface *functions;/* This MUST be the first entry*/
84
85         /* JVM instance-specific variables */
86
87         s8 starttime;                       /* VM startup time                    */
88
89         s4 Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose;
90         s4 Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
91         s4 java_lang_management_ThreadMXBean_PeakThreadCount;
92         s4 java_lang_management_ThreadMXBean_ThreadCount;
93         s8 java_lang_management_ThreadMXBean_TotalStartedThreadCount;
94         s4 Java_java_lang_VMClassLoader_defaultAssertionStatus;
95 };
96
97
98 /* CACAO related stuff ********************************************************/
99
100 extern const struct JNIInvokeInterface _Jv_JNIInvokeInterface;
101 extern struct JNINativeInterface _Jv_JNINativeInterface;
102
103
104 /* local reference table ******************************************************/
105
106 #define LOCALREFTABLE_CAPACITY    16
107
108 /* localref_table **************************************************************
109
110    ATTENTION: keep this structure a multiple of 8-bytes!!! This is
111    essential for the native stub on 64-bit architectures.
112
113 *******************************************************************************/
114
115 struct localref_table {
116         s4                 capacity;        /* table size                         */
117         s4                 used;            /* currently used references          */
118         s4                 localframes;     /* number of current frames           */
119         s4                 PADDING;         /* 8-byte padding                     */
120         localref_table    *prev;            /* link to prev table (LocalFrame)    */
121         java_objectheader *refs[LOCALREFTABLE_CAPACITY]; /* references            */
122 };
123
124 #if defined(ENABLE_THREADS)
125 #define LOCALREFTABLE    (THREADOBJECT->_localref_table)
126 #else
127 extern localref_table *_no_threads_localref_table;
128
129 #define LOCALREFTABLE    (_no_threads_localref_table)
130 #endif
131
132
133 /* hashtable_global_ref_entry *************************************************/
134
135 typedef struct hashtable_global_ref_entry hashtable_global_ref_entry;
136
137 struct hashtable_global_ref_entry {
138         java_objectheader          *o;      /* object pointer of global ref       */
139         s4                          refs;   /* references of the current pointer  */
140         hashtable_global_ref_entry *hashlink; /* link for external chaining       */
141 };
142
143
144 /* function prototypes ********************************************************/
145
146 /* initialize JNI subsystem */
147 bool jni_init(void);
148 bool jni_init_localref_table(void);
149
150 java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
151                                                                                 java_objectarray *params);
152
153 #endif /* _JNI_H */
154
155
156 /*
157  * These are local overrides for various environment variables in Emacs.
158  * Please do not remove this and leave it at the end of the file, where
159  * Emacs will automagically detect them.
160  * ---------------------------------------------------------------------
161  * Local variables:
162  * mode: c
163  * indent-tabs-mode: t
164  * c-basic-offset: 4
165  * tab-width: 4
166  * End:
167  */