From 8d376755dc3c39aaeb8c5b8f4bb01482a9160248 Mon Sep 17 00:00:00 2001 From: Timothy Wall Date: Sun, 21 Apr 2013 09:33:33 -0400 Subject: [PATCH] clean up some function naming fix typo --- native/Makefile | 2 ++ native/callback.c | 10 +++++----- native/dispatch.c | 32 +++++++++++++++--------------- native/dispatch.h | 10 +++++----- test/com/sun/jna/PlatformTest.java | 2 +- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/native/Makefile b/native/Makefile index c027283263..aecfa042cd 100644 --- a/native/Makefile +++ b/native/Makefile @@ -367,6 +367,8 @@ $(LIBRARY): $(JNIDISPATCH_OBJS) $(FFI_LIB) $(TESTLIB): $(BUILD)/testlib.o $(LD) $(LDFLAGS) $< $(LIBS) +# These targets provide for different shared library loading methods +# without getting into native library load conflicts $(TESTLIB_JAR) $(TESTLIB_PATH) $(TESTLIB_TRUNC): $(TESTLIB) @cp $< $@ diff --git a/native/callback.c b/native/callback.c index 87c605e2a8..9812dc41f4 100644 --- a/native/callback.c +++ b/native/callback.c @@ -538,7 +538,7 @@ static void make_thread_keys() { /** Store the requested detach state for the current thread. */ void -jnidispatch_detach(jboolean d) { +JNA_detach(jboolean d) { if (!TLS_SET(tls_detach_key, L2A((jlong)(d?THREAD_DETACH:THREAD_LEAVE_ATTACHED)))) { fprintf(stderr, "JNA: unable to set thread-local detach value\n"); } @@ -546,7 +546,7 @@ jnidispatch_detach(jboolean d) { /** Store the value of errno/GetLastError in TLS */ void -jnidispatch_set_last_error(int err) { +JNA_set_last_error(int err) { if (!TLS_SET(tls_errno_key, L2A((jlong)err))) { fprintf(stderr, "JNA: unable to set thread-local errno value\n"); } @@ -554,7 +554,7 @@ jnidispatch_set_last_error(int err) { /** Store the value of errno/GetLastError in TLS */ int -jnidispatch_get_last_error() { +JNA_get_last_error() { return (int)A2L(TLS_GET(tls_errno_key)); } @@ -645,7 +645,7 @@ callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) { } const char* -jnidispatch_callback_init(JNIEnv* env) { +JNA_callback_init(JNIEnv* env) { #ifndef _WIN32 static pthread_once_t key_once = PTHREAD_ONCE_INIT; pthread_once(&key_once, make_thread_keys); @@ -657,7 +657,7 @@ jnidispatch_callback_init(JNIEnv* env) { } void -jnidispatch_callback_dispose(JNIEnv* env) { +JNA_callback_dispose(JNIEnv* env) { if (classObject) { (*env)->DeleteWeakGlobalRef(env, classObject); classObject = NULL; diff --git a/native/dispatch.c b/native/dispatch.c index 8afc6901d9..8b83c12052 100644 --- a/native/dispatch.c +++ b/native/dispatch.c @@ -2,7 +2,7 @@ * @(#)dispatch.c 1.9 98/03/22 * * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2007-2012 Timothy Wall. All Rights Reserved. + * Copyright (c) 2007-2013 Timothy Wall. All Rights Reserved. * Copyright (c) 2007 Wayne Meissner. All Rights Reserved. * * This library is free software; you can redistribute it and/or @@ -28,6 +28,12 @@ #include #define STRTYPE wchar_t* #define NAME2CSTR(ENV,JSTR) newWideCString(ENV,JSTR) +#ifdef _WIN32_WCE +#include +#define DEFAULT_LOAD_OPTS 0 /* altered search path unsupported on CE */ +#undef GetProcAddress +#define GetProcAddress GetProcAddressA +#else /* See http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx: * "Note that the standard search strategy and the alternate search strategy * specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in @@ -35,12 +41,6 @@ * directory, and the alternate search begins in the directory of the * executable module that LoadLibraryEx is loading." */ -#ifdef _WIN32_WCE -#include -#define DEFAULT_LOAD_OPTS 0 /* altered search path unsupported on CE */ -#undef GetProcAddress -#define GetProcAddress GetProcAddressA -#else #define DEFAULT_LOAD_OPTS LOAD_WITH_ALTERED_SEARCH_PATH #endif #define LOAD_LIBRARY(NAME,OPTS) (NAME ? LoadLibraryExW(NAME, NULL, OPTS) : GetModuleHandleW(NULL)) @@ -571,7 +571,7 @@ dispatch(JNIEnv *env, void* func, jint flags, jobjectArray arr, } } else if (preserve_last_error) { - jnidispatch_set_last_error(GET_LAST_ERROR()); + JNA_set_last_error(GET_LAST_ERROR()); } PROTECTED_END(do { throw_type=EError;throw_msg="Invalid memory access";} while(0)); } @@ -1226,7 +1226,7 @@ get_system_property(JNIEnv* env, const char* name, jboolean wide) { } static const char* -jnidispatch_init(JNIEnv* env) { +JNA_init(JNIEnv* env) { if (!LOAD_CREF(env, Object, "java/lang/Object")) return "java.lang.Object"; if (!LOAD_CREF(env, Class, "java/lang/Class")) return "java.lang.Class"; if (!LOAD_CREF(env, Method, "java/lang/reflect/Method")) return "java.lang.reflect.Method"; @@ -1718,7 +1718,7 @@ method_handler(ffi_cif* cif, void* volatile resp, void** argp, void *cdata) { } } else if (preserve_last_error) { - jnidispatch_set_last_error(GET_LAST_ERROR()); + JNA_set_last_error(GET_LAST_ERROR()); } PROTECTED_END(do { throw_type=EError;throw_msg="Invalid memory access"; } while(0)); } @@ -2939,13 +2939,13 @@ Java_com_sun_jna_Native_getPreserveLastError(JNIEnv *UNUSED(env), jclass UNUSED( JNIEXPORT void JNICALL Java_com_sun_jna_Native_setLastError(JNIEnv *env, jclass UNUSED(classp), jint code) { - jnidispatch_set_last_error(code); + JNA_set_last_error(code); SET_LAST_ERROR(code); } JNIEXPORT jint JNICALL Java_com_sun_jna_Native_getLastError(JNIEnv *env, jclass UNUSED(classp)) { - return jnidispatch_get_last_error(); + return JNA_get_last_error(); } JNIEXPORT jstring JNICALL @@ -2978,11 +2978,11 @@ JNI_OnLoad(JavaVM *jvm, void *UNUSED(reserved)) { } } - if ((err = jnidispatch_init(env)) != NULL) { + if ((err = JNA_init(env)) != NULL) { fprintf(stderr, "JNA: Problems loading core IDs: %s\n", err); result = 0; } - else if ((err = jnidispatch_callback_init(env)) != NULL) { + else if ((err = JNA_callback_init(env)) != NULL) { fprintf(stderr, "JNA: Problems loading callback IDs: %s\n", err); result = 0; } @@ -3034,7 +3034,7 @@ JNI_OnUnload(JavaVM *vm, void *UNUSED(reserved)) { } } - jnidispatch_callback_dispose(env); + JNA_callback_dispose(env); #ifdef JAWT_HEADLESS_HACK if (jawt_handle != NULL) { @@ -3249,7 +3249,7 @@ Java_com_sun_jna_Native_initialize_1ffi_1type(JNIEnv *env, jclass UNUSED(cls), j JNIEXPORT void JNICALL Java_com_sun_jna_Native_detach(JNIEnv* env, jclass UNUSED(cls), jboolean d) { - jnidispatch_detach(d); + JNA_detach(d); } #ifdef __cplusplus diff --git a/native/dispatch.h b/native/dispatch.h index 3394b4aa50..cd65853469 100644 --- a/native/dispatch.h +++ b/native/dispatch.h @@ -174,11 +174,11 @@ extern void throwByName(JNIEnv *env, const char *name, const char *msg); extern int get_jtype(JNIEnv*, jclass); extern ffi_type* get_ffi_type(JNIEnv*, jclass, char); extern ffi_type* get_ffi_rtype(JNIEnv*, jclass, char); -extern const char* jnidispatch_callback_init(JNIEnv*); -extern void jnidispatch_set_last_error(int); -extern int jnidispatch_get_last_error(); -extern void jnidispatch_callback_dispose(JNIEnv*); -extern void jnidispatch_detach(jboolean); +extern const char* JNA_callback_init(JNIEnv*); +extern void JNA_set_last_error(int); +extern int JNA_get_last_error(); +extern void JNA_callback_dispose(JNIEnv*); +extern void JNA_detach(jboolean); extern callback* create_callback(JNIEnv*, jobject, jobject, jobjectArray, jclass, callconv_t, jint); diff --git a/test/com/sun/jna/PlatformTest.java b/test/com/sun/jna/PlatformTest.java index 6e679d51e0..c4813ded6e 100644 --- a/test/com/sun/jna/PlatformTest.java +++ b/test/com/sun/jna/PlatformTest.java @@ -1,4 +1,4 @@ -/* Copyright (c) 20013 Timothy Wall, All Rights Reserved +/* Copyright (c) 2013 Timothy Wall, All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public