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