From b2d937d5d975b05f140dab37f9c11db3b08178c9 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 12 Nov 2003 03:16:00 +0000 Subject: [PATCH] Added sigsetjmp/siglongjmp and gettid to the portability library. --- configure | 58 +++++++++++++++++++++++++++++++++++++++++++ configure.ac | 16 ++++++++++++ include/config.h.in | 6 +++++ include/wine/port.h | 11 ++++++++ libs/port/Makefile.in | 2 ++ libs/port/gettid.c | 38 ++++++++++++++++++++++++++++ libs/port/sigsetjmp.c | 36 +++++++++++++++++++++++++++ loader/pthread.c | 13 ---------- 8 files changed, 167 insertions(+), 13 deletions(-) create mode 100644 libs/port/gettid.c create mode 100644 libs/port/sigsetjmp.c diff --git a/configure b/configure index efad90541eb..166764533c9 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 +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 75b29bde9d0..78c69de46d8 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 ], + [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 ]) @@ -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 4be7ba5e1fd..b2e24c4ba48 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 9aae76d98b0..b76ff56c13f 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 +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 2fcfd0552b8..70d8ec97787 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 00000000000..b962998d381 --- /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 00000000000..aa2fcde57f9 --- /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 4ec91b78125..94cc089a0fe 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 *