Stub code for platforms without functional pthreads.

This commit is contained in:
Ryan C. Gordon 2002-07-25 17:13:03 +00:00
parent fc2df394c3
commit cdac19f131
2 changed files with 58 additions and 10 deletions

View File

@ -195,6 +195,17 @@ if test x$have_llseek = xyes; then
fi
dnl determine if we should use the stubbed pthread code.
AC_ARG_ENABLE(pthreads,
[ --enable-pthreads include POSIX threads support [default=yes]],
, enable_pthreads=yes)
if test x$enable_pthreads = xyes; then
AC_CHECK_HEADER(pthread.h, have_pthread_hdr=yes)
if test x$have_pthread_hdr != xyes; then
enable_pthreads=no
fi
fi
dnl determine if we should use the stubbed CD-ROM detection code.
AC_ARG_ENABLE(cdrom,
[ --enable-cdrom include CD-ROM support [default=yes]],
@ -218,10 +229,14 @@ if test x$enable_cdrom = xyes; then
fi
fi
have_non_posix_threads=no
dnl AC_CHECK_HEADER(be/kernel/OS.h, this_is_beos=yes)
AC_MSG_CHECKING([if this is BeOS])
if test x$build_os = xbeos; then
this_is_beos=yes
enable_pthreads=no
have_non_posix_threads=yes
LIBS="$LIBS -lroot -lbe"
else
this_is_beos=no
@ -233,6 +248,8 @@ AC_MSG_CHECKING([if this is Cygwin])
if test x$build_os = xcygwin; then
this_is_cygwin=yes
CFLAGS="$CFLAGS -DWIN32"
enable_pthreads=no
have_non_posix_threads=yes
else
this_is_cygwin=no
fi
@ -281,7 +298,7 @@ if test x$we_have_sed = xyes; then
if test x$x = xatheos; then
this_is_atheos=yes
enable_cdrom=no
LDFLAGS="$LDFLAGS -lpthread"
enable_pthreads=no
fi
AC_MSG_RESULT([$this_is_atheos])
@ -292,11 +309,26 @@ if test x$enable_cdrom != xyes; then
AC_DEFINE([PHYSFS_NO_CDROM_SUPPORT], 1, [define if we have no CD support])
AC_MSG_WARN([***])
AC_MSG_WARN([*** There is no CD-ROM support in this build!])
AC_MSG_WARN([*** PhysicsFS will just pretend there are no discs!])
AC_MSG_WARN([*** Is this what you really wanted?])
AC_MSG_WARN([*** PhysicsFS will just pretend there are no discs.])
AC_MSG_WARN([*** This may be fine, depending on how PhysicsFS is used,])
AC_MSG_WARN([*** but is this what you REALLY wanted?])
AC_MSG_WARN([*** (Maybe fix configure.in, or write a platform driver?)])
AC_MSG_WARN([***])
fi
if test x$enable_pthreads != xyes; then
AC_DEFINE([PHYSFS_NO_PTHREADS_SUPPORT], 1, [define if we have no POSIX threads support])
if test x$have_non_posix_threads != xyes; then
AC_MSG_WARN([***])
AC_MSG_WARN([*** There is no thread support in this build!])
AC_MSG_WARN([*** PhysicsFS will NOT be reentrant!])
AC_MSG_WARN([*** This may be fine, depending on how PhysicsFS is used,])
AC_MSG_WARN([*** but is this what you REALLY wanted?])
AC_MSG_WARN([*** (Maybe fix configure.in, or write a platform driver?)])
AC_MSG_WARN([***])
fi
fi
# Checks for header files.
AC_HEADER_STDC

View File

@ -17,7 +17,6 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
@ -28,6 +27,10 @@
#include <errno.h>
#include <sys/mount.h>
#if (!defined PHYSFS_NO_PTHREADS_SUPPORT)
#include <pthread.h>
#endif
#ifdef PHYSFS_HAVE_SYS_UCRED_H
# ifdef PHYSFS_HAVE_MNTENT_H
# undef PHYSFS_HAVE_MNTENT_H /* don't do both... */
@ -256,12 +259,6 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
} /* __PHYSFS_platformCalcBaseDir */
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
{
return((PHYSFS_uint64) pthread_self());
} /* __PHYSFS_platformGetThreadID */
/* Much like my college days, try to sleep for 10 milliseconds at a time... */
void __PHYSFS_platformTimeslice(void)
{
@ -283,6 +280,22 @@ char *__PHYSFS_platformRealPath(const char *path)
} /* __PHYSFS_platformRealPath */
#if (!defined PHYSFS_NO_PTHREADS_SUPPORT)
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) { return(0x0001); }
void *__PHYSFS_platformCreateMutex(void) { return((void *) 0x0001); }
void __PHYSFS_platformDestroyMutex(void *mutex) {}
int __PHYSFS_platformGrabMutex(void *mutex) { return(1); }
void __PHYSFS_platformReleaseMutex(void *mutex) {}
#else
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
{
return((PHYSFS_uint64) pthread_self());
} /* __PHYSFS_platformGetThreadID */
void *__PHYSFS_platformCreateMutex(void)
{
int rc;
@ -317,6 +330,9 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
pthread_mutex_unlock((pthread_mutex_t *) mutex);
} /* __PHYSFS_platformReleaseMutex */
#endif /* !PHYSFS_NO_PTHREADS_SUPPORT */
#endif /* !defined __BEOS__ && !defined WIN32 */
/* end of unix.c ... */