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
16 #include <java/lang/Object.h>
17 #include <java/lang/Class.h>
19 #include <gcj/array.h>
23 extern "C" jstring
_Jv_NewStringUTF (const char *bytes
);
24 extern "C" void _Jv_InitClass (jclass
);
25 extern "C" void *_Jv_AllocBytes (jsize size
) __attribute__((__malloc__
));
28 JvInitClass (jclass cls
)
30 return _Jv_InitClass (cls
);
34 JvAllocBytes (jsize sz
)
36 return _Jv_AllocBytes (sz
);
40 JvAllocString (jsize sz
)
42 return _Jv_AllocString (sz
);
46 JvNewString (const jchar
*chars
, jsize len
)
48 return _Jv_NewString (chars
, len
);
52 JvNewStringLatin1 (const char *bytes
, jsize len
)
54 return _Jv_NewStringLatin1 (bytes
, len
);
58 JvNewStringLatin1 (const char *bytes
)
60 return _Jv_NewStringLatin1 (bytes
, strlen (bytes
));
64 _Jv_GetStringChars (jstring str
)
66 return (jchar
*)((char*) str
->data
+ str
->boffset
);
70 JvGetStringChars (jstring str
)
72 return _Jv_GetStringChars (str
);
76 JvGetStringUTFLength (jstring string
)
78 return _Jv_GetStringUTFLength (string
);
82 JvGetStringUTFRegion (jstring str
, jsize start
, jsize len
, char *buf
)
84 return _Jv_GetStringUTFRegion (str
, start
, len
, buf
);
88 JvNewStringUTF (const char *bytes
)
90 return _Jv_NewStringUTF (bytes
);
98 JvSynchronize (const jobject
&o
) : obj (o
)
99 { _Jv_MonitorEnter (obj
); }
101 { _Jv_MonitorExit (obj
); }
104 /* Call malloc, but throw exception if insufficient memory. */
106 JvMalloc (jsize size
)
108 return _Jv_Malloc (size
);
114 return _Jv_Free (ptr
);
118 JvCreateJavaVM (void* vm_args
)
120 return _Jv_CreateJavaVM (vm_args
);
123 extern inline java::lang::Thread
*
124 JvAttachCurrentThread (jstring name
, java::lang::ThreadGroup
* group
)
126 return _Jv_AttachCurrentThread (name
, group
);
129 extern inline java::lang::Thread
*
130 JvAttachCurrentThreadAsDaemon (jstring name
, java::lang::ThreadGroup
* group
)
132 return _Jv_AttachCurrentThreadAsDaemon (name
, group
);
136 JvDetachCurrentThread (void)
138 return _Jv_DetachCurrentThread ();
140 #endif /* __GCJ_CNI_H__ */