fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libjava / gcj / cni.h
blob3790dc4d564b1bd21073f0ffad7b9b9221c4c099
1 // gcj/cni.h -*- c++ -*-
2 // This file describes the Compiled Native Interface, CNI.
3 // It provides a nicer interface to many of the things in gcj/javaprims.h.
5 /* Copyright (C) 1998, 1999, 2002 Free Software Foundation
7 This file is part of libgcj.
9 This software is copyrighted work licensed under the terms of the
10 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 details. */
13 #ifndef __GCJ_CNI_H__
14 #define __GCJ_CNI_H__
16 #include <java/lang/Object.h>
17 #include <java/lang/Class.h>
19 #include <gcj/array.h>
21 #include <string.h>
23 extern inline jobject
24 JvAllocObject (jclass cls)
26 return _Jv_AllocObject (cls, cls->size());
29 extern inline jobject
30 JvAllocObject (jclass cls, jsize sz)
32 return _Jv_AllocObject (cls, sz);
35 extern "C" jstring _Jv_NewStringUTF (const char *bytes);
36 extern "C" void _Jv_InitClass (jclass);
38 extern inline void
39 JvInitClass (jclass cls)
41 return _Jv_InitClass (cls);
44 extern inline jstring
45 JvAllocString (jsize sz)
47 return _Jv_AllocString (sz);
50 extern inline jstring
51 JvNewString (const jchar *chars, jsize len)
53 return _Jv_NewString (chars, len);
56 extern inline jstring
57 JvNewStringLatin1 (const char *bytes, jsize len)
59 return _Jv_NewStringLatin1 (bytes, len);
62 extern inline jstring
63 JvNewStringLatin1 (const char *bytes)
65 return _Jv_NewStringLatin1 (bytes, strlen (bytes));
68 extern inline jchar *
69 _Jv_GetStringChars (jstring str)
71 return (jchar*)((char*) str->data + str->boffset);
74 extern inline jchar*
75 JvGetStringChars (jstring str)
77 return _Jv_GetStringChars (str);
80 extern inline jsize
81 JvGetStringUTFLength (jstring string)
83 return _Jv_GetStringUTFLength (string);
86 extern inline jsize
87 JvGetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
89 return _Jv_GetStringUTFRegion (str, start, len, buf);
92 extern inline jstring
93 JvNewStringUTF (const char *bytes)
95 return _Jv_NewStringUTF (bytes);
98 class JvSynchronize
100 private:
101 jobject obj;
102 public:
103 JvSynchronize (const jobject &o) : obj (o)
104 { _Jv_MonitorEnter (obj); }
105 ~JvSynchronize ()
106 { _Jv_MonitorExit (obj); }
109 /* Call malloc, but throw exception if insufficient memory. */
110 extern inline void *
111 JvMalloc (jsize size)
113 return _Jv_Malloc (size);
116 extern inline void
117 JvFree (void *ptr)
119 return _Jv_Free (ptr);
122 extern inline jint
123 JvCreateJavaVM (void* vm_args)
125 return _Jv_CreateJavaVM (vm_args);
128 extern inline java::lang::Thread*
129 JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group)
131 return _Jv_AttachCurrentThread (name, group);
134 extern inline java::lang::Thread*
135 JvAttachCurrentThreadAsDaemon (jstring name, java::lang::ThreadGroup* group)
137 return _Jv_AttachCurrentThreadAsDaemon (name, group);
140 extern inline jint
141 JvDetachCurrentThread (void)
143 return _Jv_DetachCurrentThread ();
145 #endif /* __GCJ_CNI_H__ */