OSDN Git Service

* configure: Rebuilt.
[pf3gnuchains/gcc-fork.git] / libjava / include / jvm.h
1 // jvm.h - Header file for private implementation information. -*- c++ -*-
2
3 /* Copyright (C) 1998, 1999  Cygnus Solutions
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 #ifndef __JAVA_JVM_H__
12 #define __JAVA_JVM_H__
13
14 #include <gcj/javaprims.h>
15
16 #include <java-assert.h>
17 #include <java-threads.h>
18 // Must include java-gc.h before Object.h for the implementation.
19 #include <java-gc.h>
20
21 #include <java/lang/Object.h>
22
23 // Include cni.h before field.h to enable all definitions.  FIXME.
24 #include <gcj/cni.h>
25 #include <gcj/field.h>
26
27 /* Structure of the virtual table.  */
28 struct _Jv_VTable
29 {
30   jclass clas;
31   void *method[1];
32 };
33
34 /* Extract a character from a Java-style Utf8 string.
35  * PTR points to the current character.
36  * LIMIT points to the end of the Utf8 string.
37  * PTR is incremented to point after the character thta gets returns.
38  * On an error, -1 is returned. */
39 #define UTF8_GET(PTR, LIMIT) \
40   ((PTR) >= (LIMIT) ? -1 \
41    : *(PTR) < 128 ? *(PTR)++ \
42    : (*(PTR)&0xE0) == 0xC0 && ((PTR)+=2)<=(LIMIT) && ((PTR)[-1]&0xC0) == 0x80 \
43    ? (((PTR)[-2] & 0x1F) << 6) + ((PTR)[-1] & 0x3F) \
44    : (*(PTR) & 0xF0) == 0xE0 && ((PTR) += 3) <= (LIMIT) \
45    && ((PTR)[-2] & 0xC0) == 0x80 && ((PTR)[-1] & 0xC0) == 0x80 \
46    ? (((PTR)[-3]&0x0F) << 12) + (((PTR)[-2]&0x3F) << 6) + ((PTR)[-1]&0x3F) \
47    : ((PTR)++, -1))
48
49 extern int _Jv_strLengthUtf8(char* str, int len);
50
51 typedef struct _Jv_Utf8Const Utf8Const;
52 _Jv_Utf8Const *_Jv_makeUtf8Const (char *s, int len);
53 _Jv_Utf8Const *_Jv_makeUtf8Const (jstring string);
54 extern jboolean _Jv_equalUtf8Consts (_Jv_Utf8Const *, _Jv_Utf8Const *);
55 extern jboolean _Jv_equal (_Jv_Utf8Const *, jstring, jint);
56
57 #define StringClass _CL_Q34java4lang6String
58 extern java::lang::Class StringClass;
59
60 /* Type of pointer used as finalizer.  */
61 typedef void _Jv_FinalizerFunc (jobject);
62
63 /* Allocate space for a new Java object.  */
64 void *_Jv_AllocObj (jsize size);
65 /* Allocate space for an array of Java objects.  */
66 void *_Jv_AllocArray (jsize size);
67 /* Allocate space that is known to be pointer-free.  */
68 void *_Jv_AllocBytes (jsize size);
69 /* Initialize the GC.  */
70 void _Jv_InitGC (void);
71 /* Register a finalizer.  */
72 void _Jv_RegisterFinalizer (void *object, _Jv_FinalizerFunc *method);
73
74 /* Run finalizers for objects ready to be finalized..  */
75 void _Jv_RunFinalizers (void);
76 /* Run all finalizers.  Should be called only before exit.  */
77 void _Jv_RunAllFinalizers (void);
78 /* Perform a GC.  */
79 void _Jv_RunGC (void);
80
81 /* Return approximation of total size of heap.  */
82 long _Jv_GCTotalMemory (void);
83 /* Return approximation of total free memory.  */
84 long _Jv_GCFreeMemory (void);
85
86 /* Allocate some unscanned bytes.  Throw exception if out of memory.  */
87 void *_Jv_AllocBytesChecked (jsize size);
88
89 // This function is used to determine the hash code of an object.
90 inline jint
91 _Jv_HashCode (jobject obj)
92 {
93   return (jint) obj;
94 }
95
96 extern "C" void _Jv_ThrowBadArrayIndex (jint bad_index);
97 extern "C" jobject _Jv_NewArray (jint type, jint size);
98 extern "C" jobject _Jv_NewMultiArray (jclass klass, jint dims, ...);
99 extern "C" void *_Jv_CheckCast (jclass klass, jobject obj);
100 extern "C" void *_Jv_LookupInterfaceMethod (jclass klass, Utf8Const *name,
101                                             Utf8Const *signature);
102 extern "C" void _Jv_CheckArrayStore (jobject array, jobject obj);
103 extern "C" void _Jv_RegisterClass (jclass klass);
104 extern "C" void _Jv_RegisterClasses (jclass *classes);
105 extern void _Jv_UnregisterClass (_Jv_Utf8Const*, java::lang::ClassLoader*);
106
107 extern jclass _Jv_FindClass (_Jv_Utf8Const *name,
108                              java::lang::ClassLoader *loader);
109 extern jclass _Jv_FindClassFromSignature (char *,
110                                           java::lang::ClassLoader *loader);
111
112 extern jobject _Jv_NewMultiArray (jclass, jint ndims, jint* dims);
113
114 /* Checked divide subroutines. */
115 extern "C"
116 {
117   jint _Jv_divI (jint, jint);
118   jint _Jv_remI (jint, jint);
119   jlong _Jv_divJ (jlong, jlong);
120   jlong _Jv_remJ (jlong, jlong);
121 }
122
123 #endif /* __JAVA_JVM_H__ */