[HarfBuzz] harfbuzz-ng: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed May 4 21:21:41 PDT 2011
src/hb-blob.cc | 28 ++++++++++++++--------------
src/hb-mutex-private.hh | 38 +++++++++++++++++++++++---------------
2 files changed, 37 insertions(+), 29 deletions(-)
New commits:
commit b81bd42951e1ce1569b29168015d3c5a2dacf773
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu May 5 00:21:16 2011 -0400
Make hb_mutex_*() macros take a pointer
More intuitive.
diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index ed2f871..664ad78 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -113,7 +113,7 @@ hb_blob_create (const char *data,
return &_hb_blob_nil;
}
- hb_mutex_init (blob->lock);
+ hb_mutex_init (&blob->lock);
blob->lock_count = 0;
blob->data = data;
@@ -147,13 +147,13 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
pdata = hb_blob_lock (parent);
- hb_mutex_lock (parent->lock);
+ hb_mutex_lock (&parent->lock);
blob = hb_blob_create (pdata + offset,
MIN (length, parent->length - offset),
parent->mode,
hb_blob_reference (parent),
(hb_destroy_func_t) _hb_blob_unlock_and_destroy);
- hb_mutex_unlock (parent->lock);
+ hb_mutex_unlock (&parent->lock);
return blob;
}
@@ -176,7 +176,7 @@ hb_blob_destroy (hb_blob_t *blob)
if (!hb_object_destroy (blob)) return;
_hb_blob_destroy_user_data (blob);
- hb_mutex_free (blob->lock);
+ hb_mutex_free (&blob->lock);
free (blob);
}
@@ -210,7 +210,7 @@ hb_blob_lock (hb_blob_t *blob)
if (hb_object_is_inert (blob))
return NULL;
- hb_mutex_lock (blob->lock);
+ hb_mutex_lock (&blob->lock);
(void) (HB_DEBUG_BLOB &&
fprintf (stderr, "%p %s (%d) -> %p\n", blob, HB_FUNC,
@@ -218,7 +218,7 @@ hb_blob_lock (hb_blob_t *blob)
blob->lock_count++;
- hb_mutex_unlock (blob->lock);
+ hb_mutex_unlock (&blob->lock);
return blob->data;
}
@@ -229,7 +229,7 @@ hb_blob_unlock (hb_blob_t *blob)
if (hb_object_is_inert (blob))
return;
- hb_mutex_lock (blob->lock);
+ hb_mutex_lock (&blob->lock);
(void) (HB_DEBUG_BLOB &&
fprintf (stderr, "%p %s (%d) -> %p\n", blob, HB_FUNC,
@@ -238,7 +238,7 @@ hb_blob_unlock (hb_blob_t *blob)
assert (blob->lock_count > 0);
blob->lock_count--;
- hb_mutex_unlock (blob->lock);
+ hb_mutex_unlock (&blob->lock);
}
hb_bool_t
@@ -249,11 +249,11 @@ hb_blob_is_writable (hb_blob_t *blob)
if (hb_object_is_inert (blob))
return FALSE;
- hb_mutex_lock (blob->lock);
+ hb_mutex_lock (&blob->lock);
mode = blob->mode;
- hb_mutex_unlock (blob->lock);
+ hb_mutex_unlock (&blob->lock);
return mode == HB_MEMORY_MODE_WRITABLE;
}
@@ -331,14 +331,14 @@ hb_blob_try_writable_inplace (hb_blob_t *blob)
if (hb_object_is_inert (blob))
return FALSE;
- hb_mutex_lock (blob->lock);
+ hb_mutex_lock (&blob->lock);
if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
try_writable_inplace_locked (blob);
mode = blob->mode;
- hb_mutex_unlock (blob->lock);
+ hb_mutex_unlock (&blob->lock);
return mode == HB_MEMORY_MODE_WRITABLE;
}
@@ -351,7 +351,7 @@ hb_blob_try_writable (hb_blob_t *blob)
if (hb_object_is_inert (blob))
return FALSE;
- hb_mutex_lock (blob->lock);
+ hb_mutex_lock (&blob->lock);
if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE)
try_writable_inplace_locked (blob);
@@ -383,7 +383,7 @@ hb_blob_try_writable (hb_blob_t *blob)
done:
mode = blob->mode;
- hb_mutex_unlock (blob->lock);
+ hb_mutex_unlock (&blob->lock);
return mode == HB_MEMORY_MODE_WRITABLE;
}
diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh
index f87473d..cf5beb1 100644
--- a/src/hb-mutex-private.hh
+++ b/src/hb-mutex-private.hh
@@ -52,11 +52,11 @@ typedef volatile int hb_atomic_int_t;
typedef GStaticMutex hb_mutex_t;
#define HB_MUTEX_INIT G_STATIC_MUTEX_INIT
-#define hb_mutex_init(M) g_static_mutex_init (&(M))
-#define hb_mutex_lock(M) g_static_mutex_lock (&(M))
-#define hb_mutex_trylock(M) g_static_mutex_trylock (&(M))
-#define hb_mutex_unlock(M) g_static_mutex_unlock (&(M))
-#define hb_mutex_free(M) g_static_mutex_free (&(M))
+#define hb_mutex_init(M) g_static_mutex_init (M)
+#define hb_mutex_lock(M) g_static_mutex_lock (M)
+#define hb_mutex_trylock(M) g_static_mutex_trylock (M)
+#define hb_mutex_unlock(M) g_static_mutex_unlock (M)
+#define hb_mutex_free(M) g_static_mutex_free (M)
#elif defined(_MSC_VER)
@@ -72,11 +72,11 @@ typedef long hb_atomic_int_t;
typedef CRITICAL_SECTION hb_mutex_t;
#define HB_MUTEX_INIT { NULL, 0, 0, NULL, NULL, 0 }
-#define hb_mutex_init(M) InitializeCriticalSection (&(M))
-#define hb_mutex_lock(M) EnterCriticalSection (&(M))
-#define hb_mutex_trylock(M) TryEnterCriticalSection (&(M))
-#define hb_mutex_unlock(M) LeaveCriticalSection (&(M))
-#define hb_mutex_free(M) DeleteCriticalSection (&(M))
+#define hb_mutex_init(M) InitializeCriticalSection (M)
+#define hb_mutex_lock(M) EnterCriticalSection (M)
+#define hb_mutex_trylock(M) TryEnterCriticalSection (M)
+#define hb_mutex_unlock(M) LeaveCriticalSection (M)
+#define hb_mutex_free(M) DeleteCriticalSection (M)
#else
@@ -90,11 +90,11 @@ typedef volatile int hb_atomic_int_t;
typedef volatile int hb_mutex_t;
#define HB_MUTEX_INIT 0
-#define hb_mutex_init(M) ((void) ((M) = 0))
-#define hb_mutex_lock(M) ((void) ((M) = 1))
-#define hb_mutex_trylock(M) ((M) = 1, 1)
-#define hb_mutex_unlock(M) ((void) ((M) = 0))
-#define hb_mutex_free(M) ((void) ((M) = 2))
+#define hb_mutex_init(M) ((void) (*(M) = 0))
+#define hb_mutex_lock(M) ((void) (*(M) = 1))
+#define hb_mutex_trylock(M) (*(M) = 1, 1)
+#define hb_mutex_unlock(M) ((void) (*(M) = 0))
+#define hb_mutex_free(M) ((void) (*(M) = 2))
#endif
@@ -103,7 +103,7 @@ typedef volatile int hb_mutex_t;
struct hb_static_mutex_t : hb_mutex_t
{
hb_static_mutex_t (void) {
- hb_mutex_init (*this);
+ hb_mutex_init (this);
}
};
commit a4b1900913c91aa9db74c4fdfa7c691a5cdf02a8
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu May 5 00:17:43 2011 -0400
Add hb_static_mutex_t
diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh
index a81d362..f87473d 100644
--- a/src/hb-mutex-private.hh
+++ b/src/hb-mutex-private.hh
@@ -100,6 +100,14 @@ typedef volatile int hb_mutex_t;
#endif
+struct hb_static_mutex_t : hb_mutex_t
+{
+ hb_static_mutex_t (void) {
+ hb_mutex_init (*this);
+ }
+};
+
+
HB_END_DECLS
#endif /* HB_MUTEX_PRIVATE_HH */
More information about the HarfBuzz
mailing list