[haiku-gsoc] Updated patch

  • From: Nathan Heisey <nathanheisey@xxxxxxxxx>
  • To: haiku-gsoc <haiku-gsoc@xxxxxxxxxxxxx>
  • Date: Wed, 22 Jun 2011 17:43:42 +0000

Third update to SDL 1.3 patch 00: Altered commit message (there should
be no change to contents).

Ryan, thanks for all your help and clarifications on how to properly
make a patch, I'll try to keep all of your advice in mind for the next
one so that I don't have to spam this list in future.

By the way, hg rollback didn't work- it said there was no rollback information.

-Nathan Heisey
# HG changeset patch
# User Nathan Heisey <nathanheisey@xxxxxxxxx>
# Date 1308738828 0
# Node ID c1ed57cbfd66e146a7af034a806377bb271b1696
# Parent  45a709ef443db5617404c2aed35073b26d996fc3
Implemented pthread spinlocks.

diff -r 45a709ef443d -r c1ed57cbfd66 configure.in
--- a/configure.in      Wed Jun 15 10:28:01 2011 +0100
+++ b/configure.in      Wed Jun 22 10:33:48 2011 +0000
@@ -280,6 +280,25 @@
     fi
 fi
 
+# Check for pthread implementation
+AC_MSG_CHECKING(for pthread spinlock)
+have_pthread_spinlock=no
+
+AC_TRY_LINK([
+#include <pthread.h>
+],[
+pthread_spinlock_t a;
+pthread_spin_trylock(&a);
+pthread_spin_unlock(&a);
+],[
+have_pthread_spinlock=yes
+])
+AC_MSG_RESULT($have_pthread_spinlock)
+if test x$have_pthread_spinlock = xyes; then
+    AC_DEFINE(HAVE_PTHREAD_SPINLOCK, 1, [ ])
+fi
+
+
 # Standard C sources
 SOURCES="$SOURCES $srcdir/src/*.c"
 SOURCES="$SOURCES $srcdir/src/atomic/*.c"
diff -r 45a709ef443d -r c1ed57cbfd66 include/SDL_config.h.in
--- a/include/SDL_config.h.in   Wed Jun 15 10:28:01 2011 +0100
+++ b/include/SDL_config.h.in   Wed Jun 22 10:33:48 2011 +0000
@@ -45,6 +45,7 @@
 #undef SIZEOF_VOIDP
 #undef HAVE_GCC_ATOMICS
 #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET
+#undef HAVE_PTHREAD_SPINLOCK
 
 /* Comment this if you want to build without any C library requirements */
 #undef HAVE_LIBC
diff -r 45a709ef443d -r c1ed57cbfd66 src/atomic/SDL_spinlock.c
--- a/src/atomic/SDL_spinlock.c Wed Jun 15 10:28:01 2011 +0100
+++ b/src/atomic/SDL_spinlock.c Wed Jun 22 10:33:48 2011 +0000
@@ -77,9 +77,13 @@
         : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
     return (result == 0);
 
-#else
+#elif HAVE_PTHREAD_SPINLOCK
+    /* pthread instructions */
+    return (pthread_spin_trylock(lock) == 0);
+#else  
     /* Need CPU instructions for spinlock here! */
     __need_spinlock_implementation__
+       
 #endif
 }
 
@@ -101,7 +105,10 @@
 
 #elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
     __sync_lock_release(lock);
-
+    
+#elif HAVE_PTHREAD_SPINLOCK
+    pthread_spin_unlock(lock);
+       
 #else
     *lock = 0;
 #endif
exporting patch:
<fdopen>

Other related posts: