From 7f1051b6ca9d1a146f4142844bfead43bce452c8 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Fri, 18 Aug 2017 12:58:35 -0700 Subject: [PATCH] Include JNIEXPORT on exported symbols Motivation: As noticed in https://stackoverflow.com/questions/45700277/ compilation can fail if the definition of a method doesn't match the declaration. It's easy enough to add this in, and make it easy to compile. Modifications: Add JNIEXPORT to the entry points. * On Windows this adds: `__declspec(dllexport)` * On Mac this adds: `__attribute__((visibility("default")))` * On Linux (GCC 4.2+) this adds: ` __attribute__((visibility("default")))` * On other it doesn't add anything. Result: Easier compilation --- transport-native-epoll/src/main/c/netty_epoll_native.c | 4 ++-- transport-native-kqueue/src/main/c/netty_kqueue_native.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/transport-native-epoll/src/main/c/netty_epoll_native.c b/transport-native-epoll/src/main/c/netty_epoll_native.c index 1f8df12c99..7b398250fb 100644 --- a/transport-native-epoll/src/main/c/netty_epoll_native.c +++ b/transport-native-epoll/src/main/c/netty_epoll_native.c @@ -624,7 +624,7 @@ jint JNI_OnLoad_netty_transport_native_epoll(JavaVM* vm, void* reserved) { } #ifndef NETTY_BUILD_STATIC -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { return JNI_OnLoad_netty_transport_native_epoll(vm, reserved); } #endif /* NETTY_BUILD_STATIC */ @@ -640,7 +640,7 @@ void JNI_OnUnload_netty_transport_native_epoll(JavaVM* vm, void* reserved) { } #ifndef NETTY_BUILD_STATIC -void JNI_OnUnload(JavaVM* vm, void* reserved) { +JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) { JNI_OnUnload_netty_transport_native_epoll(vm, reserved); } #endif /* NETTY_BUILD_STATIC */ diff --git a/transport-native-kqueue/src/main/c/netty_kqueue_native.c b/transport-native-kqueue/src/main/c/netty_kqueue_native.c index 710b7b31c6..94899e037e 100644 --- a/transport-native-kqueue/src/main/c/netty_kqueue_native.c +++ b/transport-native-kqueue/src/main/c/netty_kqueue_native.c @@ -352,7 +352,7 @@ jint JNI_OnLoad_netty_transport_native_kqueue(JavaVM* vm, void* reserved) { } #ifndef NETTY_BUILD_STATIC -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { return JNI_OnLoad_netty_transport_native_kqueue(vm, reserved); } #endif /* NETTY_BUILD_STATIC */ @@ -368,7 +368,7 @@ void JNI_OnUnload_netty_transport_native_kqueue(JavaVM* vm, void* reserved) { } #ifndef NETTY_BUILD_STATIC -void JNI_OnUnload(JavaVM* vm, void* reserved) { +JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) { return JNI_OnUnload_netty_transport_native_kqueue(vm, reserved); } #endif /* NETTY_BUILD_STATIC */