loader: Use thr_self syscall to get thread id on FreeBSD.
This commit is contained in:
parent
af78fa7b68
commit
60833da9f2
|
@ -7478,6 +7478,68 @@ done
|
|||
|
||||
|
||||
|
||||
for ac_header in sys/thr.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
|
||||
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <sys/types.h>
|
||||
#if HAVE_UCONTEXT_H
|
||||
#include <ucontext.h>
|
||||
#endif
|
||||
|
||||
#include <$ac_header>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (ac_try="$ac_compile"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_compile") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && {
|
||||
test -z "$ac_c_werror_flag" ||
|
||||
test ! -s conftest.err
|
||||
} && test -s conftest.$ac_objext; then
|
||||
eval "$as_ac_Header=yes"
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
eval "$as_ac_Header=no"
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
ac_res=`eval echo '${'$as_ac_Header'}'`
|
||||
{ echo "$as_me:$LINENO: result: $ac_res" >&5
|
||||
echo "${ECHO_T}$ac_res" >&6; }
|
||||
if test `eval echo '${'$as_ac_Header'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
|
||||
for ac_header in pthread_np.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
|
|
|
@ -325,6 +325,12 @@ AC_CHECK_HEADERS([resolv.h],,,
|
|||
|
||||
AC_CHECK_HEADERS(ucontext.h,,,[#include <signal.h>])
|
||||
|
||||
AC_CHECK_HEADERS([sys/thr.h],,,
|
||||
[#include <sys/types.h>
|
||||
#if HAVE_UCONTEXT_H
|
||||
#include <ucontext.h>
|
||||
#endif])
|
||||
|
||||
AC_CHECK_HEADERS([pthread_np.h],,,
|
||||
[#ifdef HAVE_PTHREAD_H
|
||||
#include <pthread.h>
|
||||
|
|
|
@ -813,6 +813,9 @@
|
|||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#undef HAVE_SYS_SYSCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/thr.h> header file. */
|
||||
#undef HAVE_SYS_THR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
#undef HAVE_SYS_TIMES_H
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
#ifdef HAVE_MACH_MACH_H
|
||||
#include <mach/mach.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_THR_H
|
||||
#include <sys/ucontext.h>
|
||||
#include <sys/thr.h>
|
||||
#endif
|
||||
|
||||
#include "wine/library.h"
|
||||
#include "wine/pthread.h"
|
||||
|
@ -149,6 +153,12 @@ static void init_current_teb( struct wine_pthread_thread_info *info )
|
|||
info->tid = pthread_self(); /* this should return the lwp id on solaris */
|
||||
#elif defined(__APPLE__)
|
||||
info->tid = mach_thread_self();
|
||||
#elif defined(__FreeBSD__)
|
||||
{
|
||||
long lwpid;
|
||||
thr_self( &lwpid );
|
||||
info->tid = (int) lwpid;
|
||||
}
|
||||
#else
|
||||
info->tid = gettid();
|
||||
#endif
|
||||
|
|
|
@ -156,8 +156,17 @@ void sigchld_callback(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* return the Unix pid to use in ptrace calls for a given thread */
|
||||
/* return the Unix pid to use in ptrace calls for a given process */
|
||||
static int get_ptrace_pid( struct thread *thread )
|
||||
{
|
||||
#ifdef linux /* linux always uses thread id */
|
||||
if (thread->unix_tid != -1) return thread->unix_tid;
|
||||
#endif
|
||||
return thread->unix_pid;
|
||||
}
|
||||
|
||||
/* return the Unix tid to use in ptrace calls for a given thread */
|
||||
static int get_ptrace_tid( struct thread *thread )
|
||||
{
|
||||
if (thread->unix_tid != -1) return thread->unix_tid;
|
||||
return thread->unix_pid;
|
||||
|
@ -501,7 +510,7 @@ void get_selector_entry( struct thread *thread, int entry, unsigned int *base,
|
|||
/* retrieve the thread x86 registers */
|
||||
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
|
||||
{
|
||||
int i, pid = get_ptrace_pid(thread);
|
||||
int i, pid = get_ptrace_tid(thread);
|
||||
long data[8];
|
||||
|
||||
/* all other regs are handled on the client side */
|
||||
|
@ -534,7 +543,7 @@ done:
|
|||
/* set the thread x86 registers */
|
||||
void set_thread_context( struct thread *thread, const CONTEXT *context, unsigned int flags )
|
||||
{
|
||||
int pid = get_ptrace_pid( thread );
|
||||
int pid = get_ptrace_tid( thread );
|
||||
|
||||
/* all other regs are handled on the client side */
|
||||
assert( (flags | CONTEXT_i386) == CONTEXT_DEBUG_REGISTERS );
|
||||
|
@ -568,7 +577,7 @@ void set_thread_context( struct thread *thread, const CONTEXT *context, unsigned
|
|||
/* retrieve the thread x86 registers */
|
||||
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
|
||||
{
|
||||
int pid = get_ptrace_pid(thread);
|
||||
int pid = get_ptrace_tid(thread);
|
||||
struct dbreg dbregs;
|
||||
|
||||
/* all other regs are handled on the client side */
|
||||
|
@ -603,7 +612,7 @@ void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int f
|
|||
/* set the thread x86 registers */
|
||||
void set_thread_context( struct thread *thread, const CONTEXT *context, unsigned int flags )
|
||||
{
|
||||
int pid = get_ptrace_pid(thread);
|
||||
int pid = get_ptrace_tid(thread);
|
||||
struct dbreg dbregs;
|
||||
|
||||
/* all other regs are handled on the client side */
|
||||
|
|
Loading…
Reference in New Issue