[jffi-next] 04/24: JRUBY-4388: [FFI] GetLastError always returns 0 on Windows
Tim Potter
tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
tpot-guest pushed a commit to tag 0.6.5
in repository jffi-next.
commit 73b5d7cdab22d4353dd32e8ac50f213652da17d0
Author: Vladimir Sizikov <vsizikov at gmail.com>
Date: Sun Dec 27 11:24:09 2009 +0100
JRUBY-4388: [FFI] GetLastError always returns 0 on Windows
*NOTE*: This requires GCC 4.4+ in order to have thread-locals work
(needed for errno handling).
---
.hgignore | 3 +++
jni/GNUmakefile | 6 +++++-
jni/jffi/LastError.c | 15 +++++++--------
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/.hgignore b/.hgignore
index 650d224..47990af 100644
--- a/.hgignore
+++ b/.hgignore
@@ -7,3 +7,6 @@
^build/.*$
^dist
^lib/nblibraries-private.properties
+^build.eclipse/
+^.classpath
+^.project
diff --git a/jni/GNUmakefile b/jni/GNUmakefile
index 653e5f9..1c4f72c 100755
--- a/jni/GNUmakefile
+++ b/jni/GNUmakefile
@@ -77,7 +77,11 @@ ifeq ($(OS), win32)
LDFLAGS += -mno-cygwin
endif
CFLAGS += -mwin32 -D_JNI_IMPLEMENTATION_
- LDFLAGS += -Wl,--add-stdcall-alias
+ # Linking against CRTMT.O is a workaround for GCC 4.4 bug
+ # that ignores __thread (which we really need for errno handling).
+ # See: http://n2.nabble.com/gcc-4-4-multi-threaded-exception-handling-thread-specifier-not-working-td3440749.html
+ CRTMT.O = $(shell $(CC) -print-file-name=crtmt.o)
+ LDFLAGS += -Wl,--add-stdcall-alias $(CRTMT.O)
PICFLAGS=
SOFLAGS += -shared -mimpure-text -static-libgcc
PREFIX =
diff --git a/jni/jffi/LastError.c b/jni/jffi/LastError.c
index 4503b02..a99b6d4 100644
--- a/jni/jffi/LastError.c
+++ b/jni/jffi/LastError.c
@@ -6,8 +6,8 @@
#include <jni.h>
#include "LastError.h"
-#if defined(_WIN32) && defined(notyet)
-static int __thread last_error = 0;
+#if defined(_WIN32)
+static __thread int last_error = 0;
#endif
/*
@@ -19,12 +19,9 @@ JNIEXPORT jint JNICALL
Java_com_kenai_jffi_Foreign_getLastError(JNIEnv* env, jobject self)
{
#ifdef _WIN32
-#ifdef notyet
+ // printf("Getting ERRNO: %d on thread %d\n", last_error, (int)GetCurrentThreadId());
return last_error;
#else
- return GetLastError();
-#endif
-#else
return thread_data_get()->error;
#endif
}
@@ -38,7 +35,9 @@ JNIEXPORT void JNICALL
Java_com_kenai_jffi_Foreign_setLastError(JNIEnv* env, jobject self, jint value)
{
#ifdef _WIN32
+ // printf("Setting ERRNO: %d on thread %d\n", value, (int)GetCurrentThreadId());
SetLastError(value);
+ last_error = value;
#else
thread_data_get()->error = errno = value;
#endif
@@ -48,9 +47,9 @@ void
jffi_save_errno(void)
{
#ifdef _WIN32
- //last_error = GetLastError();
+ last_error = GetLastError();
+ // printf("JFFI Saving ERRNO: %d on thread %d\n", last_error, (int)GetCurrentThreadId());
#else
thread_data_get()->error = errno;
#endif
}
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git
More information about the pkg-java-commits
mailing list