[HarfBuzz] harfbuzz-ng: Branch 'master' - 3 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Sun May 27 07:15:52 PDT 2012


 src/hb-atomic-private.hh |    6 +++---
 src/hb-cache-private.hh  |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit e4b6d503c5575ddbf49249e3fef693d75ae75170
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 27 10:11:13 2012 -0400

    Don't use atomic ops in hb_cache_t
    
    We don't care about linearizability, so unprotected int read/write
    are enough, no need for expensive memory barriers.  It's a cache,
    that's all.

diff --git a/src/hb-cache-private.hh b/src/hb-cache-private.hh
index 7394fbb..a0928a0 100644
--- a/src/hb-cache-private.hh
+++ b/src/hb-cache-private.hh
@@ -36,7 +36,7 @@ template <unsigned int key_bits, unsigned int value_bits, unsigned int cache_bit
 struct hb_cache_t
 {
   ASSERT_STATIC (key_bits >= cache_bits);
-  ASSERT_STATIC (key_bits + value_bits - cache_bits < 8 * sizeof (hb_atomic_int_t));
+  ASSERT_STATIC (key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int));
 
   inline void clear (void)
   {
@@ -46,7 +46,7 @@ struct hb_cache_t
   inline bool get (unsigned int key, unsigned int *value)
   {
     unsigned int k = key & ((1<<cache_bits)-1);
-    unsigned int v = hb_atomic_int_get (values[k]);
+    unsigned int v = values[k];
     if ((v >> value_bits) != (key >> cache_bits))
       return false;
   }
@@ -57,12 +57,12 @@ struct hb_cache_t
       return false; /* Overflows */
     unsigned int k = key & ((1<<cache_bits)-1);
     unsigned int v = ((key>>cache_bits)<<value_bits) | value;
-    hb_atomic_int_set (values[k], v);
+    values[k] = v;
     return true;
   }
 
   private:
-  hb_atomic_int_t values[1<<cache_bits];
+  unsigned int values[1<<cache_bits];
 };
 
 typedef hb_cache_t<21, 16, 8> hb_cmap_cache_t;
commit 819faa05307aa192015f4b43d8103a35e87d6cc7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 27 10:09:18 2012 -0400

    Minor

diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh
index b587fde..ba52773 100644
--- a/src/hb-atomic-private.hh
+++ b/src/hb-atomic-private.hh
@@ -78,7 +78,7 @@ typedef volatile int hb_atomic_int_t;
 
 #define HB_ATOMIC_INT_NIL 1
 typedef volatile int hb_atomic_int_t;
-#define hb_atomic_int_add(AI, V)	((AI) += (V), (AI) - (V))
+#define hb_atomic_int_add(AI, V)	(((AI) += (V)) - (V))
 #define hb_atomic_int_set(AI, V)	((void) ((AI) = (V)))
 #define hb_atomic_int_get(AI)		(AI)
 
commit 303d5850ec0516e198db241456b0cfc4899ef9c0
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun May 27 10:01:13 2012 -0400

    Fix Windows atomic get/set
    
    According to:
    http://msdn.microsoft.com/en-us/library/65tt87y8.aspx
    
    MemoryBarrier() is the right macro to protect these, not _ReadBarrier()
    and/or _WriteBarrier().

diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh
index 684e856..b587fde 100644
--- a/src/hb-atomic-private.hh
+++ b/src/hb-atomic-private.hh
@@ -47,8 +47,8 @@
 #include <intrin.h>
 typedef long hb_atomic_int_t;
 #define hb_atomic_int_add(AI, V)	_InterlockedExchangeAdd (&(AI), (V))
-#define hb_atomic_int_set(AI, V)	_InterlockedExchange (&(AI), (V))
-#define hb_atomic_int_get(AI)		(_ReadBarrier (), (AI))
+#define hb_atomic_int_set(AI, V)	((AI) = (V), MemoryBarrier ())
+#define hb_atomic_int_get(AI)		(MemoryBarrier (), (AI))
 
 
 #elif !defined(HB_NO_MT) && defined(__APPLE__)



More information about the HarfBuzz mailing list