diff --git a/configure b/configure
index efad90541eb525f6c4d543ce722a5d487b8ce5fb..166764533c989a48cef09a5a19e7ad7507417e63 100755
--- a/configure
+++ b/configure
@@ -9706,6 +9706,62 @@ _ACEOF
 
 fi
 
+echo "$as_me:$LINENO: checking for sigsetjmp" >&5
+echo $ECHO_N "checking for sigsetjmp... $ECHO_C" >&6
+if test "${ac_cv_c_sigsetjmp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <setjmp.h>
+int
+main ()
+{
+sigjmp_buf buf;
+    sigsetjmp( buf, 1 );
+    siglongjmp( buf, 1 );
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_sigsetjmp="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_sigsetjmp="no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_sigsetjmp" >&5
+echo "${ECHO_T}$ac_cv_c_sigsetjmp" >&6
+if test "$ac_cv_c_sigsetjmp" = "yes"
+then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SIGSETJMP 1
+_ACEOF
+
+fi
+
 echo "$as_me:$LINENO: checking for pthread_rwlock_t" >&5
 echo $ECHO_N "checking for pthread_rwlock_t... $ECHO_C" >&6
 if test "${ac_cv_type_pthread_rwlock_t+set}" = set; then
@@ -13798,6 +13854,7 @@ fi
 
 
 
+
 
 
 for ac_func in \
@@ -13824,6 +13881,7 @@ for ac_func in \
 	getprotobynumber \
 	getpwuid \
 	getservbyport \
+	gettid \
 	gettimeofday \
 	inet_network \
 	lseek64 \
diff --git a/configure.ac b/configure.ac
index 75b29bde9d05308875fd2f6fb2a7f7f3be0bcec0..78c69de46d8cc01967889294ada908de4c5a4257 100644
--- a/configure.ac
+++ b/configure.ac
@@ -517,6 +517,21 @@ then
     AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
 fi
 
+dnl **** Check for sigsetjmp ****
+AC_CACHE_CHECK([for sigsetjmp], ac_cv_c_sigsetjmp,
+ AC_TRY_LINK(
+   [#include <setjmp.h>],
+   [sigjmp_buf buf;
+    sigsetjmp( buf, 1 );
+    siglongjmp( buf, 1 );],
+   [ac_cv_c_sigsetjmp="yes"],
+   [ac_cv_c_sigsetjmp="no"])
+ )
+if test "$ac_cv_c_sigsetjmp" = "yes"
+then
+    AC_DEFINE(HAVE_SIGSETJMP, 1, [Define to 1 if you have the sigsetjmp (and siglongjmp) function])
+fi
+
 dnl **** Check for pthread_rwlock_t ****
 AC_CHECK_TYPES([pthread_rwlock_t, pthread_rwlockattr_t],,,[#define _GNU_SOURCE
 #include <pthread.h>])
@@ -979,6 +994,7 @@ AC_CHECK_FUNCS(\
 	getprotobynumber \
 	getpwuid \
 	getservbyport \
+	gettid \
 	gettimeofday \
 	inet_network \
 	lseek64 \
diff --git a/include/config.h.in b/include/config.h.in
index 4be7ba5e1fd70d1ba1ba1da0cf525a830c40efa0..b2e24c4ba489db0cb447bf31d2ddf7cfe4d79576 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -155,6 +155,9 @@
 /* Define to 1 if you have the `getservbyport' function. */
 #undef HAVE_GETSERVBYPORT
 
+/* Define to 1 if you have the `gettid' function. */
+#undef HAVE_GETTID
+
 /* Define to 1 if you have the `gettimeofday' function. */
 #undef HAVE_GETTIMEOFDAY
 
@@ -467,6 +470,9 @@
 /* Define to 1 if `si_fd' is member of `siginfo_t'. */
 #undef HAVE_SIGINFO_T_SI_FD
 
+/* Define to 1 if you have the sigsetjmp (and siglongjmp) function */
+#undef HAVE_SIGSETJMP
+
 /* Define to 1 if the system has the type `size_t'. */
 #undef HAVE_SIZE_T
 
diff --git a/include/wine/port.h b/include/wine/port.h
index 9aae76d98b00b526b62714586f3010cde186b790..b76ff56c13f661030071d2a78c32ad3d9fe99565 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -216,6 +216,10 @@ extern int getopt_long_only (int ___argc, char *const *___argv,
 size_t getpagesize(void);
 #endif  /* HAVE_GETPAGESIZE */
 
+#ifndef HAVE_GETTID
+pid_t gettid(void);
+#endif /* HAVE_GETTID */
+
 #ifndef HAVE_LSTAT
 int lstat(const char *file_name, struct stat *buf);
 #endif /* HAVE_LSTAT */
@@ -232,6 +236,13 @@ ssize_t pread( int fd, void *buf, size_t count, off_t offset );
 ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
 #endif /* HAVE_PWRITE */
 
+#ifndef HAVE_SIGSETJMP
+# include <setjmp.h>
+typedef jmp_buf sigjmp_buf;
+int sigsetjmp( sigjmp_buf buf, int savesigs );
+void siglongjmp( sigjmp_buf buf, int val );
+#endif /* HAVE_SIGSETJMP */
+
 #ifndef HAVE_STATFS
 int statfs(const char *name, struct statfs *info);
 #endif /* !defined(HAVE_STATFS) */
diff --git a/libs/port/Makefile.in b/libs/port/Makefile.in
index 2fcfd0552b81b373f7ccab447d5671c637c81ce7..70d8ec97787f00535e013a862618e30a79fd313b 100644
--- a/libs/port/Makefile.in
+++ b/libs/port/Makefile.in
@@ -10,6 +10,7 @@ C_SRCS = \
 	getopt.c \
 	getopt1.c \
 	getpagesize.c \
+	gettid.c \
 	interlocked.c \
 	lstat.c \
 	memcpy_unaligned.c \
@@ -17,6 +18,7 @@ C_SRCS = \
 	mkstemps.c \
 	pread.c \
 	pwrite.c \
+	sigsetjmp.c \
 	spawn.c \
 	statfs.c \
 	strcasecmp.c \
diff --git a/libs/port/gettid.c b/libs/port/gettid.c
new file mode 100644
index 0000000000000000000000000000000000000000..b962998d381fed767c8f381ea472272f9bc36956
--- /dev/null
+++ b/libs/port/gettid.c
@@ -0,0 +1,38 @@
+/*
+ * gettid function
+ *
+ * Copyright 2003 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#ifndef HAVE_GETTID
+
+pid_t gettid(void)
+{
+#if defined(__linux__) && defined(__i386__)
+    pid_t ret;
+    __asm__("int $0x80" : "=a" (ret) : "0" (224) /* SYS_gettid */);
+    if (ret < 0) ret = -1;
+    return ret;
+#else
+    return -1;  /* FIXME */
+#endif
+}
+
+#endif  /* HAVE_GETTID */
diff --git a/libs/port/sigsetjmp.c b/libs/port/sigsetjmp.c
new file mode 100644
index 0000000000000000000000000000000000000000..aa2fcde57f924ef296ddc65df1e97bf93314faca
--- /dev/null
+++ b/libs/port/sigsetjmp.c
@@ -0,0 +1,36 @@
+/*
+ * sigsetjmp/siglongjmp functions
+ *
+ * Copyright 2003 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#ifndef HAVE_SIGSETJMP
+
+int sigsetjmp( sigjmp_buf buf, int savesigs )
+{
+    return setjmp( buf );
+}
+
+void siglongjmp( sigjmp_buf buf, int val )
+{
+    longjmp( buf, val );
+}
+
+#endif  /* HAVE_SIGSETJMP */
diff --git a/loader/pthread.c b/loader/pthread.c
index 4ec91b78125e8ed712d2ae7a8e01fb2db09fe12f..94cc089a0fee8aed7a7b001dff673fd31b87687a 100644
--- a/loader/pthread.c
+++ b/loader/pthread.c
@@ -44,19 +44,6 @@ static struct wine_pthread_functions funcs;
 static pthread_key_t teb_key;
 #endif
 
-static inline int gettid(void)
-{
-#if defined(__linux__) && defined(__i386__)
-    int ret;
-    __asm__("int $0x80" : "=a" (ret) : "0" (224) /* SYS_gettid */);
-    if (ret < 0) ret = -1;
-    return ret;
-#else
-    return -1;  /* FIXME */
-#endif
-}
-
-
 /***********************************************************************
  *           wine_pthread_init_process
  *