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>
20 #include <gcj/javaprims.h>
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
);
112 JvRealloc (void *ptr
, jsize size
)
114 return _Jv_Realloc (ptr
, size
);
120 return _Jv_Free (ptr
);
123 typedef struct _Jv_VMOption JvVMOption
;
124 typedef struct _Jv_VMInitArgs JvVMInitArgs
;
127 JvCreateJavaVM (JvVMInitArgs
* vm_args
)
129 return _Jv_CreateJavaVM (vm_args
);
132 extern inline java::lang::Thread
*
133 JvAttachCurrentThread (jstring name
, java::lang::ThreadGroup
* group
)
135 return _Jv_AttachCurrentThread (name
, group
);
138 extern inline java::lang::Thread
*
139 JvAttachCurrentThreadAsDaemon (jstring name
, java::lang::ThreadGroup
* group
)
141 return _Jv_AttachCurrentThreadAsDaemon (name
, group
);
145 JvDetachCurrentThread (void)
147 return _Jv_DetachCurrentThread ();
149 #endif /* __GCJ_CNI_H__ */