This is an automated email from the ASF dual-hosted git repository. gaurava pushed a commit to branch fix-jni in repository https://gitbox.apache.org/repos/asf/hadoop.git
commit d193c917808cd8b81218f62b5c2aad2815d249b3 Author: Gautham Banasandra <gautham.bangal...@gmail.com> AuthorDate: Thu Oct 3 01:44:01 2024 +0530 HDFS-17636. Don't add declspec for Windows * Windows doesn't want the macro _JNI_IMPORT_OR_EXPORT_ to be defined in the function definition. It fails to compile with the following error - "definition of dllimport function not allowed". * However, Linux needs it. Hence, we're going to add this macro based on the OS. --- .../src/main/native/libhdfs/CMakeLists.txt | 2 +- .../src/main/native/libhdfspp/tests/libhdfs_getjni_test.cc | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt index 958bdcf2a41..8cc1d2ade1d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt @@ -57,7 +57,7 @@ set(LIBHDFS_VERSION "0.0.0") set_target_properties(hdfs PROPERTIES SOVERSION ${LIBHDFS_VERSION}) -build_libhdfs_test(test_libhdfs_ops hdfs_static test_libhdfs_ops.c) +build_libhdfs_test(test_libhdfs_ops hdfs_static test_libhdfs_ops.c ../libhdfs/hdfs.c) link_libhdfs_test(test_libhdfs_ops hdfs_static native_mini_dfs ${JAVA_JVM_LIBRARY}) add_libhdfs_test(test_libhdfs_ops hdfs_static) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/libhdfs_getjni_test.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/libhdfs_getjni_test.cc index b2648da23bb..327d10f30d0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/libhdfs_getjni_test.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/libhdfs_getjni_test.cc @@ -20,13 +20,21 @@ #include <hdfs/hdfs.h> #include <jni.h> +#ifdef WIN32 +#define DECLSPEC +#else +// Windows cribs when this is declared in the function definition, +// However, Linux needs it. +#define DECLSPEC _JNI_IMPORT_OR_EXPORT_ +#endif + // hook the jvm runtime function. expect always failure -_JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void*) { +DECLSPEC jint JNICALL JNI_GetDefaultJavaVMInitArgs(void*) { return 1; } // hook the jvm runtime function. expect always failure -_JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM**, void**, void*) { +DECLSPEC jint JNICALL JNI_CreateJavaVM(JavaVM**, void**, void*) { return 1; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org