Create two separate wine binaries, one using libpthread and one using

kernel threading directly.
Get rid of the remaining HAVE_NPTL ifdefs.
Remove the scheduler directory.
This commit is contained in:
Alexandre Julliard 2003-11-06 23:05:41 +00:00
parent 357c7401b9
commit f45325e443
8 changed files with 189 additions and 149 deletions

View File

@ -184,7 +184,6 @@ respective dlls.
memory/ - KERNEL memory management
misc/ - KERNEL shell, registry, winsock, etc.
msdos/ - KERNEL DOS support
scheduler/ - KERNEL process and thread management
graphics/ - GDI graphics drivers
objects/ - GDI logical objects

47
configure vendored
View File

@ -308,7 +308,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS WIN16_FILES WIN16_INSTALL LIBPTHREAD build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP TOOLSDIR X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS YACC LEX LEXLIB LEX_OUTPUT_ROOT XYACC XLEX AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS DB2HTML DB2PDF DB2PS DB2TXT JPEGLIB EGREP GIFLIB XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPEINCL ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS CAPI4LINUXLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLL LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS LDD ALLOCA LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS WIN16_FILES WIN16_INSTALL MAIN_BINARY build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP TOOLSDIR X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS YACC LEX LEXLIB LEX_OUTPUT_ROOT XYACC XLEX AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS DB2HTML DB2PDF DB2PS DB2TXT LIBPTHREAD JPEGLIB EGREP GIFLIB XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPEINCL ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS CAPI4LINUXLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLL LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS LDD ALLOCA LIBOBJS LTLIBOBJS'
ac_subst_files='MAKE_RULES MAKE_DLL_RULES MAKE_TEST_RULES MAKE_LIB_RULES MAKE_PROG_RULES'
# Initialize some variables set by options.
@ -1385,12 +1385,10 @@ _ACEOF
fi
if test "x$with_nptl" = "xyes"
then
MAIN_BINARY="wine-pthread"
cat >>confdefs.h <<\_ACEOF
#define HAVE_NPTL 1
_ACEOF
LIBPTHREAD="-lpthread"
else
MAIN_BINARY="wine-kthread"
fi
@ -5895,14 +5893,13 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for mmap in -lmmap" >&5
echo $ECHO_N "checking for mmap in -lmmap... $ECHO_C" >&6
if test "${ac_cv_lib_mmap_mmap+set}" = set; then
echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmmap $LIBS"
LIBS="-lpthread $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
@ -5917,11 +5914,11 @@ extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char mmap ();
char pthread_create ();
int
main ()
{
mmap ();
pthread_create ();
;
return 0;
}
@ -5938,24 +5935,20 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_mmap_mmap=yes
ac_cv_lib_pthread_pthread_create=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_mmap_mmap=no
ac_cv_lib_pthread_pthread_create=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_mmap_mmap" >&5
echo "${ECHO_T}$ac_cv_lib_mmap_mmap" >&6
if test $ac_cv_lib_mmap_mmap = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBMMAP 1
_ACEOF
LIBS="-lmmap $LIBS"
echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5
echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6
if test $ac_cv_lib_pthread_pthread_create = yes; then
LIBPTHREAD="-lpthread"
fi
@ -16903,8 +16896,6 @@ esac
ac_config_commands="$ac_config_commands programs/regedit/tests"
ac_config_commands="$ac_config_commands scheduler"
ac_config_commands="$ac_config_commands windows"
@ -17674,7 +17665,6 @@ do
"objects" ) CONFIG_COMMANDS="$CONFIG_COMMANDS objects" ;;
"programs/regapi/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS programs/regapi/tests" ;;
"programs/regedit/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS programs/regedit/tests" ;;
"scheduler" ) CONFIG_COMMANDS="$CONFIG_COMMANDS scheduler" ;;
"windows" ) CONFIG_COMMANDS="$CONFIG_COMMANDS windows" ;;
"include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
@ -17764,7 +17754,7 @@ s,@ECHO_T@,$ECHO_T,;t t
s,@LIBS@,$LIBS,;t t
s,@WIN16_FILES@,$WIN16_FILES,;t t
s,@WIN16_INSTALL@,$WIN16_INSTALL,;t t
s,@LIBPTHREAD@,$LIBPTHREAD,;t t
s,@MAIN_BINARY@,$MAIN_BINARY,;t t
s,@build@,$build,;t t
s,@build_cpu@,$build_cpu,;t t
s,@build_vendor@,$build_vendor,;t t
@ -17817,6 +17807,7 @@ s,@DB2HTML@,$DB2HTML,;t t
s,@DB2PDF@,$DB2PDF,;t t
s,@DB2PS@,$DB2PS,;t t
s,@DB2TXT@,$DB2TXT,;t t
s,@LIBPTHREAD@,$LIBPTHREAD,;t t
s,@JPEGLIB@,$JPEGLIB,;t t
s,@EGREP@,$EGREP,;t t
s,@GIFLIB@,$GIFLIB,;t t
@ -18407,8 +18398,6 @@ echo "$as_me: creating objects" >&6;} && mkdir "objects") ;;
echo "$as_me: creating programs/regapi/tests" >&6;} && mkdir "programs/regapi/tests") ;;
programs/regedit/tests ) test -d "programs/regedit/tests" || ({ echo "$as_me:$LINENO: creating programs/regedit/tests" >&5
echo "$as_me: creating programs/regedit/tests" >&6;} && mkdir "programs/regedit/tests") ;;
scheduler ) test -d "scheduler" || ({ echo "$as_me:$LINENO: creating scheduler" >&5
echo "$as_me: creating scheduler" >&6;} && mkdir "scheduler") ;;
windows ) test -d "windows" || ({ echo "$as_me:$LINENO: creating windows" >&5
echo "$as_me: creating windows" >&6;} && mkdir "windows") ;;
esac

View File

@ -38,8 +38,9 @@ then
fi
if test "x$with_nptl" = "xyes"
then
AC_DEFINE(HAVE_NPTL,1,[Define to use glibc NPTL threading support.])
AC_SUBST(LIBPTHREAD,"-lpthread")
AC_SUBST(MAIN_BINARY,"wine-pthread")
else
AC_SUBST(MAIN_BINARY,"wine-kthread")
fi
dnl **** Check for some programs ****
@ -143,8 +144,8 @@ dnl Check for -lresolv for Solaris
AC_CHECK_FUNCS(inet_aton,,AC_CHECK_LIB(resolv,inet_aton))
dnl Check for -lxpg4 for FreeBSD
AC_CHECK_LIB(xpg4,_xpg4_setrunelocale)
dnl Check for -lmmap for OS/2
AC_CHECK_LIB(mmap,mmap)
dnl Check for -lpthread
AC_CHECK_LIB(pthread,pthread_create,AC_SUBST(LIBPTHREAD,"-lpthread"))
JPEGLIB=""
AC_SUBST(JPEGLIB)
@ -1393,7 +1394,6 @@ WINE_CONFIG_EXTRA_DIR(msdos)
WINE_CONFIG_EXTRA_DIR(objects)
WINE_CONFIG_EXTRA_DIR(programs/regapi/tests)
WINE_CONFIG_EXTRA_DIR(programs/regedit/tests)
WINE_CONFIG_EXTRA_DIR(scheduler)
WINE_CONFIG_EXTRA_DIR(windows)
MAKE_RULES=Make.rules

View File

@ -230,9 +230,6 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `mmap' library (-lmmap). */
#undef HAVE_LIBMMAP
/* Define if you have the ncurses library (-lncurses) */
#undef HAVE_LIBNCURSES
@ -374,9 +371,6 @@
/* Define to 1 if you have the <net/route.h> header file. */
#undef HAVE_NET_ROUTE_H
/* Define to use glibc NPTL threading support. */
#undef HAVE_NPTL
/* Define to 1 if the system has the type `off_t'. */
#undef HAVE_OFF_T

View File

@ -1,2 +1,4 @@
Makefile
wine
wine-kthread
wine-pthread

View File

@ -3,31 +3,46 @@ TOPOBJDIR = ..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = wine
EXTRALIBS = @LIBPTHREAD@
C_SRCS = \
$(TOPOBJDIR)/scheduler/pthread.c \
main.c
kthread.c \
main.c \
pthread.c
EXTRASUBDIRS = $(TOPOBJDIR)/scheduler
KTHREAD_OBJS = main.o kthread.o
PTHREAD_OBJS = main.o pthread.o
all: $(MODULE)
BINARIES = \
wine-kthread \
wine-pthread
all: $(BINARIES) $(MODULE)
@MAKE_RULES@
LIBPTHREAD = @LIBPTHREAD@
MAIN_BINARY = @MAIN_BINARY@
LDEXECFLAGS = @LDEXECFLAGS@
$(MODULE): $(OBJS) Makefile.in
$(CC) -o $@ $(LDEXECFLAGS) $(OBJS) $(LIBWINE) $(LIBPORT) $(EXTRALIBS) $(LDFLAGS)
wine-kthread: $(KTHREAD_OBJS) Makefile.in
$(CC) -o $@ $(LDEXECFLAGS) $(KTHREAD_OBJS) $(LIBWINE) $(LIBPORT) $(EXTRALIBS) $(LDFLAGS)
install:: $(MODULE)
wine-pthread: $(PTHREAD_OBJS) Makefile.in
$(CC) -o $@ $(LDEXECFLAGS) $(PTHREAD_OBJS) $(LIBWINE) $(LIBPORT) $(LIBPTHREAD) $(EXTRALIBS) $(LDFLAGS)
$(MODULE): $(MAIN_BINARY)
$(RM) $(MODULE) && $(LN_S) $(MAIN_BINARY) $(MODULE)
install:: $(BINARIES)
$(MKINSTALLDIRS) $(bindir)
$(INSTALL_PROGRAM) wine $(bindir)/wine
$(INSTALL_PROGRAM) wine-kthread $(bindir)/wine-kthread
$(INSTALL_PROGRAM) wine-pthread $(bindir)/wine-pthread
cd $(bindir) && $(RM) $(MODULE) && $(LN_S) $(MAIN_BINARY) $(MODULE)
uninstall::
$(RM) $(bindir)/wine
$(RM) $(BINARIES:%=$(bindir)/%) $(bindir)/$(MODULE)
clean::
$(RM) $(MODULE)
$(RM) $(BINARIES) $(MODULE)
### Dependencies:

View File

@ -1,5 +1,5 @@
/*
* pthread emulation for re-entrant libcs
* pthread emulation based on kernel threads
*
* We can't use pthreads directly, so why not let libcs
* that want pthreads use Wine's own threading instead...
@ -55,12 +55,22 @@ struct _pthread_cleanup_buffer;
#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#endif
#ifdef HAVE_SYS_SYSCALL_H
# include <sys/syscall.h>
#endif
#ifdef HAVE_SYS_LWP_H
# include <sys/lwp.h>
#endif
#ifdef HAVE_UCONTEXT_H
# include <ucontext.h>
#endif
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
#include "wine/library.h"
#include "wine/pthread.h"
#ifndef HAVE_NPTL
#define P_OUTPUT(stuff) write(2,stuff,strlen(stuff))
#define PSTR(str) __ASM_NAME(#str)
@ -309,12 +319,6 @@ void wine_pthread_abort_thread( int status )
#if defined(__GLIBC__) || defined(__FreeBSD__)
#ifndef __USE_UNIX98
#define __USE_UNIX98
#endif
#include <pthread.h>
/* adapt as necessary (a construct like this is used in glibc sources) */
#define strong_alias(orig, alias) \
asm(".globl " PSTR(alias) "\n" \
@ -894,10 +898,10 @@ static struct pthread_functions libc_pthread_functions =
NULL, /* FIXME */ /* ptr_pthread_attr_setinheritsched */
NULL, /* FIXME */ /* ptr_pthread_attr_getschedparam */
pthread_attr_setschedparam, /* ptr_pthread_attr_setschedparam */
NULL, /* FIXME */ /* ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *); */
NULL, /* FIXME */ /* ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int); */
NULL, /* FIXME */ /* ptr_pthread_attr_getscope) (const pthread_attr_t *, int *); */
NULL, /* FIXME */ /* ptr_pthread_attr_setscope) (pthread_attr_t *, int); */
NULL, /* FIXME */ /* ptr_pthread_attr_getschedpolicy */
NULL, /* FIXME */ /* ptr_pthread_attr_setschedpolicy */
NULL, /* FIXME */ /* ptr_pthread_attr_getscope */
NULL, /* FIXME */ /* ptr_pthread_attr_setscope */
pthread_condattr_destroy, /* ptr_pthread_condattr_destroy */
pthread_condattr_init, /* ptr_pthread_condattr_init */
__pthread_cond_broadcast, /* ptr___pthread_cond_broadcast */
@ -932,87 +936,3 @@ static struct pthread_functions libc_pthread_functions =
};
#endif /* __GLIBC__ || __FREEBSD__ */
#else /* HAVE_NPTL */
/***********************************************************************
* wine_pthread_init_process
*
* Initialization for a newly created process.
*/
void wine_pthread_init_process( const struct wine_pthread_functions *functions )
{
}
/***********************************************************************
* wine_pthread_init_thread
*
* Initialization for a newly created thread.
*/
void wine_pthread_init_thread(void)
{
}
/***********************************************************************
* wine_pthread_create_thread
*/
int wine_pthread_create_thread( struct wine_pthread_thread_info *info )
{
pthread_t id;
pthread_attr_t attr;
if (!info->stack_base)
{
info->stack_base = wine_anon_mmap( NULL, info->stack_size,
PROT_READ | PROT_WRITE | PROT_EXEC, 0 );
if (info->stack_base == (void *)-1) return -1;
}
pthread_attr_init( &attr );
pthread_attr_setstack( &attr, info->stack_base, info->stack_size );
if (pthread_create( &id, &attr, (void * (*)(void *))info->entry, info )) return -1;
return 0;
}
/***********************************************************************
* wine_pthread_exit_thread
*/
void wine_pthread_exit_thread( struct wine_pthread_thread_info *info )
{
struct cleanup_info
{
pthread_t self;
struct wine_pthread_thread_info thread_info;
};
static struct cleanup_info *previous_info;
struct cleanup_info *cleanup_info, *free_info;
void *ptr;
/* store it at the end of the TEB structure */
cleanup_info = (struct cleanup_info *)((char *)info->teb_base + info->teb_size) - 1;
cleanup_info->self = pthread_self();
cleanup_info->thread_info = *info;
if ((free_info = interlocked_xchg_ptr( (void **)&previous_info, cleanup_info )) != NULL)
{
pthread_join( free_info->self, &ptr );
wine_ldt_free_fs( free_info->thread_info.teb_sel );
munmap( free_info->thread_info.stack_base, free_info->thread_info.stack_size );
munmap( free_info->thread_info.teb_base, free_info->thread_info.teb_size );
}
pthread_exit( (void *)info->exit_status );
}
/***********************************************************************
* wine_pthread_abort_thread
*/
void wine_pthread_abort_thread( int status )
{
pthread_exit( (void *)status );
}
#endif /* HAVE_NPTL */

121
loader/pthread.c Normal file
View File

@ -0,0 +1,121 @@
/*
* Wine threading routines using the pthread library
*
* 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"
#ifdef HAVE_PTHREAD_H
#include <assert.h>
#include <stdlib.h>
#include <signal.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#include "wine/library.h"
#include "wine/pthread.h"
/***********************************************************************
* wine_pthread_init_process
*
* Initialization for a newly created process.
*/
void wine_pthread_init_process( const struct wine_pthread_functions *functions )
{
}
/***********************************************************************
* wine_pthread_init_thread
*
* Initialization for a newly created thread.
*/
void wine_pthread_init_thread(void)
{
}
/***********************************************************************
* wine_pthread_create_thread
*/
int wine_pthread_create_thread( struct wine_pthread_thread_info *info )
{
pthread_t id;
pthread_attr_t attr;
if (!info->stack_base)
{
info->stack_base = wine_anon_mmap( NULL, info->stack_size,
PROT_READ | PROT_WRITE | PROT_EXEC, 0 );
if (info->stack_base == (void *)-1) return -1;
}
pthread_attr_init( &attr );
pthread_attr_setstack( &attr, info->stack_base, info->stack_size );
if (pthread_create( &id, &attr, (void * (*)(void *))info->entry, info )) return -1;
return 0;
}
/***********************************************************************
* wine_pthread_exit_thread
*/
void wine_pthread_exit_thread( struct wine_pthread_thread_info *info )
{
struct cleanup_info
{
pthread_t self;
struct wine_pthread_thread_info thread_info;
};
static struct cleanup_info *previous_info;
struct cleanup_info *cleanup_info, *free_info;
void *ptr;
/* store it at the end of the TEB structure */
cleanup_info = (struct cleanup_info *)((char *)info->teb_base + info->teb_size) - 1;
cleanup_info->self = pthread_self();
cleanup_info->thread_info = *info;
if ((free_info = interlocked_xchg_ptr( (void **)&previous_info, cleanup_info )) != NULL)
{
pthread_join( free_info->self, &ptr );
wine_ldt_free_fs( free_info->thread_info.teb_sel );
munmap( free_info->thread_info.stack_base, free_info->thread_info.stack_size );
munmap( free_info->thread_info.teb_base, free_info->thread_info.teb_size );
}
pthread_exit( (void *)info->exit_status );
}
/***********************************************************************
* wine_pthread_abort_thread
*/
void wine_pthread_abort_thread( int status )
{
pthread_exit( (void *)status );
}
#endif /* HAVE_PTHREAD_H */