Fixed building with pthreads and the pth library
authorSam Lantinga <slouken@libsdl.org>
Thu, 13 Jun 2002 21:36:25 +0000
changeset 415104f32d04cd1
parent 414 dd56447ef292
child 416 6b0363ceaba2
Fixed building with pthreads and the pth library
configure.in
src/timer/linux/SDL_systimer.c
     1.1 --- a/configure.in	Thu Jun 13 17:52:43 2002 +0000
     1.2 +++ b/configure.in	Thu Jun 13 21:36:25 2002 +0000
     1.3 @@ -1138,8 +1138,6 @@
     1.4      AC_ARG_ENABLE(pthread-sem,
     1.5  [  --enable-pthread-sem    use pthread semaphores [default=yes]],
     1.6                    , enable_pthread_sem=yes)
     1.7 -    ac_save_cflags="$CFLAGS"
     1.8 -    ac_save_libs="$LIBS"
     1.9      case "$target" in
    1.10          *-*-bsdi*)
    1.11              pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
    1.12 @@ -1187,9 +1185,12 @@
    1.13              pthread_lib="-lpthread"
    1.14              ;;
    1.15      esac
    1.16 -    CFLAGS="$CFLAGS $pthread_cflags"
    1.17 -    LIBS="$LIBS $pthread_lib"
    1.18      if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
    1.19 +        # Save the original compiler flags and libraries
    1.20 +        ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
    1.21 +        # Add the pthread compiler flags and libraries
    1.22 +        CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
    1.23 +        # Check to see if we have pthread support on this system
    1.24          AC_MSG_CHECKING(for pthreads)
    1.25          use_pthreads=no
    1.26          AC_TRY_LINK([
    1.27 @@ -1201,6 +1202,9 @@
    1.28          use_pthreads=yes
    1.29          ])
    1.30          AC_MSG_RESULT($use_pthreads)
    1.31 +        # Restore the compiler flags and libraries
    1.32 +        CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
    1.33 +        # Do futher testing if we have pthread support...
    1.34          if test x$use_pthreads = xyes; then
    1.35              CFLAGS="$CFLAGS $pthread_cflags -DSDL_USE_PTHREADS"
    1.36              SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
    1.37 @@ -1269,8 +1273,6 @@
    1.38              esac
    1.39          fi
    1.40      fi
    1.41 -    CFLAGS="$ac_save_cflags"
    1.42 -    LIBS="$ac_save_libs"
    1.43  
    1.44      AC_MSG_CHECKING(whether semun is defined in /usr/include/sys/sem.h)
    1.45      have_semun=no
     2.1 --- a/src/timer/linux/SDL_systimer.c	Thu Jun 13 17:52:43 2002 +0000
     2.2 +++ b/src/timer/linux/SDL_systimer.c	Thu Jun 13 21:36:25 2002 +0000
     2.3 @@ -41,6 +41,9 @@
     2.4  #if _POSIX_THREAD_SYSCALL_SOFT
     2.5  #include <pthread.h>
     2.6  #endif
     2.7 +#ifdef ENABLE_PTH
     2.8 +#include <pth.h>
     2.9 +#endif
    2.10  
    2.11  #if defined(DISABLE_THREADS) || defined(FORK_HACK)
    2.12  #define USE_ITIMER
    2.13 @@ -142,6 +145,12 @@
    2.14  
    2.15  void SDL_Delay (Uint32 ms)
    2.16  {
    2.17 +#ifdef ENABLE_PTH
    2.18 +	pth_time_t tv;
    2.19 +	tv.tv_sec  =  ms/1000;
    2.20 +	tv.tv_usec = (ms%1000)*1000;
    2.21 +	pth_nap(tv);
    2.22 +#else
    2.23  	int was_error;
    2.24  
    2.25  #ifdef USE_NANOSLEEP
    2.26 @@ -189,6 +198,7 @@
    2.27  		was_error = select(0, NULL, NULL, NULL, &tv);
    2.28  #endif /* USE_NANOSLEEP */
    2.29  	} while ( was_error && (errno == EINTR) );
    2.30 +#endif /* ENABLE_PTH */
    2.31  }
    2.32  
    2.33  #ifdef USE_ITIMER