jni_md.h 4.8 KB

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