OSDN Git Service

improve open-coding of complex divide, use new method in g77
[pf3gnuchains/gcc-fork.git] / libjava / include / cni.h
1 // cni.h -*- c++ -*-
2 // This file describes the Cygnus Native Interface, CNI.
3 // It provides a nicer interface to many of the things in javaprims.h.
4
5 /* Copyright (C) 1998, 1999  Cygnus Solutions
6
7    This file is part of libgcj.
8
9 This software is copyrighted work licensed under the terms of the
10 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
11 details.  */
12
13 #ifndef __JAVA_CNI_H__
14 #define __JAVA_CNI_H__
15
16 #include <java/lang/Object.h>
17 #include <java/lang/Class.h>
18
19 #include <java-threads.h>
20 #include <java-array.h>
21
22 extern inline jobject
23 JvAllocObject (jclass cls)
24 {
25   return _Jv_AllocObject (cls, cls->size());
26 }
27
28 extern inline jobject
29 JvAllocObject (jclass cls, jsize sz)
30 {
31   return _Jv_AllocObject (cls, sz);
32 }
33
34 extern "C" jstring _Jv_NewStringUTF (const char *bytes);
35 extern "C" void _Jv_InitClass (jclass);
36
37 extern inline void
38 JvInitClass (jclass cls)
39 {
40   return _Jv_InitClass (cls);
41 }
42
43 extern inline jstring
44 JvAllocString (jsize sz)
45 {
46   return _Jv_AllocString (sz);
47 }
48
49 extern inline jstring
50 JvNewString (const jchar *chars, jsize len)
51 {
52   return _Jv_NewString (chars, len);
53 }
54
55 extern inline jstring
56 JvNewStringLatin1 (const char *bytes, jsize len)
57 {
58   return _Jv_NewStringLatin1 (bytes, len);
59 }
60
61 extern inline jstring
62 JvNewStringLatin1 (const char *bytes)
63 {
64   return _Jv_NewStringLatin1 (bytes, strlen (bytes));
65 }
66
67 extern inline jchar *
68 _Jv_GetStringChars (jstring str)
69 {
70   return (jchar*)((char*) str->data + str->boffset);
71 }
72
73 extern inline jchar*
74 JvGetStringChars (jstring str)
75 {
76   return _Jv_GetStringChars (str);
77 }
78
79 extern inline jsize
80 JvGetStringUTFLength (jstring string)
81 {
82   return _Jv_GetStringUTFLength (string);
83 }
84
85 extern inline jsize
86 JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf) 
87
88   return _Jv_GetStringUTFRegion (str, start, len, buf); 
89
90
91 extern inline jstring
92 JvNewStringUTF (const char *bytes)
93 {
94   return _Jv_NewStringUTF (bytes);
95 }
96
97 extern class _Jv_PrimClass _Jv_byteClass, _Jv_shortClass, _Jv_intClass,
98   _Jv_longClass, _Jv_booleanClass, _Jv_charClass, _Jv_floatClass,
99   _Jv_doubleClass, _Jv_voidClass;
100 #define JvPrimClass(TYPE) ((jclass) & _Jv_##TYPE##Class)
101
102 class JvSynchronize
103 {
104 private:
105   jobject obj;
106 public:
107   JvSynchronize (const jobject &o) : obj (o)
108     { _Jv_MonitorEnter (obj); }
109   ~JvSynchronize ()
110     { _Jv_MonitorExit (obj); }
111 };
112
113 // Throw some exception.
114 extern void JvThrow (jobject obj) __attribute__ ((__noreturn__));
115 extern inline void
116 JvThrow (jobject obj)
117 {
118   _Jv_Throw ((void *) obj);
119 }
120
121 /* Call malloc, but throw exception if insufficient memory. */
122 extern inline void *
123 JvMalloc (jsize size)
124 {
125   return _Jv_Malloc (size);
126 }
127
128 extern inline void
129 JvFree (void *ptr)
130 {
131   return _Jv_Free (ptr);
132 }
133 #endif /* __JAVA_CNI_H__ */