src/solaris/native/common/jni_util_md.c

Print this page




  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include <string.h>
  27 
  28 #include "jni.h"
  29 #include "jni_util.h"
  30 #include "dlfcn.h"
  31 
  32 jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
  33     return NULL;
  34 }
  35 
  36 char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
  37     return NULL;
  38 }
  39 







  40 void* getProcessHandle() {
  41     static void *procHandle = NULL;
  42     if (procHandle != NULL) {
  43         return procHandle;
  44     }
  45 #ifdef __APPLE__
  46     procHandle = (void*)dlopen(NULL, RTLD_FIRST);
  47 #else
  48     procHandle = (void*)dlopen(NULL, RTLD_LAZY);
  49 #endif
  50     return procHandle;
  51 }
  52 
  53 void buildJniFunctionName(const char *sym, const char *cname,
  54                           char *jniEntryName) {
  55     strcpy(jniEntryName, sym);
  56     if (cname != NULL) {
  57         strcat(jniEntryName, "_");
  58         strcat(jniEntryName, cname);
  59     }
  60 }
  61 








  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include <string.h>
  27 
  28 #include "jni.h"
  29 #include "jni_util.h"
  30 #include "dlfcn.h"
  31 
  32 jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
  33     return NULL;
  34 }
  35 
  36 char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
  37     return NULL;
  38 }
  39 
  40 #if defined(LINUX) && (defined(_GNU_SOURCE) || \
  41          (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200112L \
  42              && defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 600))
  43 extern int __xpg_strerror_r(int, char *, size_t);
  44 #define strerror_r(a, b, c) __xpg_strerror_r((a), (b), (c))
  45 #endif
  46 
  47 void* getProcessHandle() {
  48     static void *procHandle = NULL;
  49     if (procHandle != NULL) {
  50         return procHandle;
  51     }
  52 #ifdef __APPLE__
  53     procHandle = (void*)dlopen(NULL, RTLD_FIRST);
  54 #else
  55     procHandle = (void*)dlopen(NULL, RTLD_LAZY);
  56 #endif
  57     return procHandle;
  58 }
  59 
  60 void buildJniFunctionName(const char *sym, const char *cname,
  61                           char *jniEntryName) {
  62     strcpy(jniEntryName, sym);
  63     if (cname != NULL) {
  64         strcat(jniEntryName, "_");
  65         strcat(jniEntryName, cname);
  66     }
  67 }
  68 
  69 int
  70 getErrorString(int err, char *buf, size_t len)
  71 {
  72     if (err == 0 || len < 1) return 0;
  73     return strerror_r(err, buf, len);
  74 }