2 Copyright (C) 2001, 2005, 2007, 2010 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
27 #ifndef __GCJ_JNI_MD_H__
28 #define __GCJ_JNI_MD_H__
30 #include <gcj/libgcj-config.h>
32 #ifdef __GCJ_JNI_IMPL__
34 /* If __GCJ_JNI_IMPL__ is defined, then we assume that we're building
35 libgcj itself, and we include headers which taint the namespace
36 more than is acceptable for the ordinary JNI user. */
37 #include <gcj/javaprims.h>
38 #include <gcj/array.h>
39 #include <gnu/gcj/runtime/JNIWeakRef.h>
41 typedef gnu::gcj::runtime::JNIWeakRef *jweak;
43 typedef struct _Jv_JNIEnv JNIEnv;
44 typedef struct _Jv_JavaVM JavaVM;
47 #define JNI_FALSE false
49 /* We defined jobject and friends, so don't redefine them in jni.h. */
50 #define _CLASSPATH_VM_JNI_TYPES_DEFINED
52 /* We defined jmethodID and and jfieldID, so don't redefine them in
54 #define _CLASSPATH_VM_INTERNAL_TYPES_DEFINED
56 /* Contents of the JNIEnv; but only inside the implementation. */
57 #define _CLASSPATH_JNIENV_CONTENTS \
58 /* The current exception. */ \
61 /* The chain of local frames. */ \
62 struct _Jv_JNI_LocalFrame *locals; \
64 /* The bottom-most element of the chain, initialized with the env and \
65 reused between non-nesting JNI calls. */ \
66 struct _Jv_JNI_LocalFrame *bottom_locals;
68 /* JNI calling convention. Also defined in javaprims.h. */
70 #if (defined (_WIN32) || defined (__WIN32__) || defined (WIN32)) \
72 #define JNICALL __stdcall
78 #else /* __GCJ_JNI_IMPL__ */
82 /* If we're using gcc, we can use a platform-independent scheme to get
83 the right integer types. FIXME: this is not always correct, for
84 instance on the c4x it will be wrong -- it depends on whether
86 typedef int jbyte __attribute__((__mode__(__QI__)));
87 typedef int jshort __attribute__((__mode__(__HI__)));
88 typedef int jint __attribute__((__mode__(__SI__)));
89 typedef int jlong __attribute__((__mode__(__DI__)));
90 typedef unsigned int jboolean __attribute__((__mode__(__QI__)));
91 typedef unsigned short jchar __attribute__((__mode__(__HI__)));
93 typedef double jdouble;
98 # ifdef JV_HAVE_INTTYPES_H
100 /* If <inttypes.h> is available, we use it. */
102 # include <inttypes.h>
104 typedef int8_t jbyte;
105 typedef int16_t jshort;
106 typedef int32_t jint;
107 typedef int64_t jlong;
108 typedef float jfloat;
109 typedef double jdouble;
111 typedef uint8_t jboolean;
112 typedef uint16_t jchar;
114 # else /* JV_HAVE_INTTYPES_H */
116 /* For now, we require either gcc or <inttypes.h>. If we did more
117 work at configure time we could get around this, but right now it
118 doesn't seem worth it. */
119 # error jni.h not ported to this platform
121 # endif /* JV_HAVE_INTTYPES_H */
123 # endif /* __GNUC__ */
125 #endif /* __GCJ_JNI_IMPL__ */
128 /* Linkage and calling conventions. */
129 #if (defined (_WIN32) || defined (__WIN32__) || defined (WIN32)) \
132 #define JNIIMPORT __declspec(dllimport)
133 #define JNIEXPORT __declspec(dllexport)
136 #define JNICALL __stdcall
139 #else /* !( _WIN32 || __WIN32__ || WIN32) || _WIN64 */
142 #if defined(__GNUC__) && __GNUC__ > 3
143 #define JNIEXPORT __attribute__ ((visibility("default")))
152 #endif /* !( _WIN32 || __WIN32__ || WIN32) || _WIN64 */
154 /* These defines apply to symbols in libgcj */
156 # ifdef __GCJ_JNI_IMPL__
157 # define _CLASSPATH_JNIIMPEXP JNIEXPORT
159 # define _CLASSPATH_JNIIMPEXP JNIIMPORT
160 # endif /* ! __GCJ_JNI_IMPL__ */
161 #else /* ! __GCJ_DLL__ */
162 # define _CLASSPATH_JNIIMPEXP
163 #endif /* __GCJ_DLL__ */
165 #endif /* __GCJ_JNI_MD_H__ */