diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index c4dabe15e..f9050c377 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -1,7 +1,7 @@ /* * Copyright © 2007 Chris Wilson * Copyright © 2009,2010 Red Hat, Inc. - * Copyright © 2011 Google, Inc. + * Copyright © 2011,2012 Google, Inc. * * This is part of HarfBuzz, a text shaping library. * @@ -39,7 +39,24 @@ /* We need external help for these */ -#if !defined(HB_NO_MT) && defined(HAVE_GLIB) + +#if !defined(HB_NO_MT) && defined(_MSC_VER) && _MSC_VER >= 1600 + +#include +typedef long hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) _InterlockedExchangeAdd (&(AI), V) +#define hb_atomic_int_get(AI) (_ReadBarrier (), (AI)) + + +#elif !defined(HB_NO_MT) && defined(__APPLE__) + +#include +typedef int32_t hb_atomic_int_t; +#define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier((V), &(AI)), (AI) - (V)) +#define hb_atomic_int_get(AI) OSAtomicAdd32Barrier(0, &(AI)) + + +#elif !defined(HB_NO_MT) && defined(HAVE_GLIB) #include typedef volatile int hb_atomic_int_t; @@ -51,20 +68,6 @@ typedef volatile int hb_atomic_int_t; #define hb_atomic_int_get(AI) g_atomic_int_get (&(AI)) -#elif !defined(HB_NO_MT) && defined(_MSC_VER) && _MSC_VER >= 1600 - -#include -typedef long hb_atomic_int_t; -#define hb_atomic_int_add(AI, V) _InterlockedExchangeAdd (&(AI), V) -#define hb_atomic_int_get(AI) (_ReadBarrier (), (AI)) - -#elif !defined(HB_NO_MT) && defined(__APPLE__) - -#include -typedef int32_t hb_atomic_int_t; -#define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier((V), &(AI)), (AI) - (V)) -#define hb_atomic_int_get(AI) OSAtomicAdd32Barrier(0, &(AI)) - #else #define HB_ATOMIC_INT_NIL 1 diff --git a/src/hb-mutex-private.hh b/src/hb-mutex-private.hh index 95228f8ea..bdb438fe5 100644 --- a/src/hb-mutex-private.hh +++ b/src/hb-mutex-private.hh @@ -39,17 +39,8 @@ /* We need external help for these */ -#if !defined(HB_NO_MT) && defined(HAVE_GLIB) -#include -typedef GStaticMutex hb_mutex_impl_t; -#define HB_MUTEX_IMPL_INIT G_STATIC_MUTEX_INIT -#define hb_mutex_impl_init(M) g_static_mutex_init (M) -#define hb_mutex_impl_lock(M) g_static_mutex_lock (M) -#define hb_mutex_impl_unlock(M) g_static_mutex_unlock (M) -#define hb_mutex_impl_free(M) g_static_mutex_free (M) - -#elif !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__) +#if !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__) #include typedef CRITICAL_SECTION hb_mutex_impl_t; @@ -59,6 +50,7 @@ typedef CRITICAL_SECTION hb_mutex_impl_t; #define hb_mutex_impl_unlock(M) LeaveCriticalSection (M) #define hb_mutex_impl_free(M) DeleteCriticalSection (M) + #elif !defined(HB_NO_MT) && defined(__APPLE__) #include @@ -69,6 +61,18 @@ typedef pthread_mutex_t hb_mutex_impl_t; #define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M) #define hb_mutex_impl_free(M) pthread_mutex_destroy (M) + +#elif !defined(HB_NO_MT) && defined(HAVE_GLIB) + +#include +typedef GStaticMutex hb_mutex_impl_t; +#define HB_MUTEX_IMPL_INIT G_STATIC_MUTEX_INIT +#define hb_mutex_impl_init(M) g_static_mutex_init (M) +#define hb_mutex_impl_lock(M) g_static_mutex_lock (M) +#define hb_mutex_impl_unlock(M) g_static_mutex_unlock (M) +#define hb_mutex_impl_free(M) g_static_mutex_free (M) + + #else #define HB_MUTEX_IMPL_NIL 1