< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-mutex-private.hh

Print this page




  51 #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__))
  52 
  53 #include <windows.h>
  54 typedef CRITICAL_SECTION hb_mutex_impl_t;
  55 #define HB_MUTEX_IMPL_INIT      {0}
  56 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
  57 #define hb_mutex_impl_init(M)   InitializeCriticalSectionEx (M, 0, 0)
  58 #else
  59 #define hb_mutex_impl_init(M)   InitializeCriticalSection (M)
  60 #endif
  61 #define hb_mutex_impl_lock(M)   EnterCriticalSection (M)
  62 #define hb_mutex_impl_unlock(M) LeaveCriticalSection (M)
  63 #define hb_mutex_impl_finish(M) DeleteCriticalSection (M)
  64 
  65 
  66 #elif !defined(HB_NO_MT) && (defined(HAVE_PTHREAD) || defined(__APPLE__))
  67 
  68 #include <pthread.h>
  69 typedef pthread_mutex_t hb_mutex_impl_t;
  70 #define HB_MUTEX_IMPL_INIT      PTHREAD_MUTEX_INITIALIZER
  71 #define hb_mutex_impl_init(M)   pthread_mutex_init (M, NULL)
  72 #define hb_mutex_impl_lock(M)   pthread_mutex_lock (M)
  73 #define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M)
  74 #define hb_mutex_impl_finish(M) pthread_mutex_destroy (M)
  75 
  76 
  77 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
  78 
  79 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD)
  80 # include <sched.h>
  81 # define HB_SCHED_YIELD() sched_yield ()
  82 #else
  83 # define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END
  84 #endif
  85 
  86 /* This actually is not a totally awful implementation. */
  87 typedef volatile int hb_mutex_impl_t;
  88 #define HB_MUTEX_IMPL_INIT      0
  89 #define hb_mutex_impl_init(M)   *(M) = 0
  90 #define hb_mutex_impl_lock(M)   HB_STMT_START { while (__sync_lock_test_and_set((M), 1)) HB_SCHED_YIELD (); } HB_STMT_END
  91 #define hb_mutex_impl_unlock(M) __sync_lock_release (M)




  51 #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__))
  52 
  53 #include <windows.h>
  54 typedef CRITICAL_SECTION hb_mutex_impl_t;
  55 #define HB_MUTEX_IMPL_INIT      {0}
  56 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_PC_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
  57 #define hb_mutex_impl_init(M)   InitializeCriticalSectionEx (M, 0, 0)
  58 #else
  59 #define hb_mutex_impl_init(M)   InitializeCriticalSection (M)
  60 #endif
  61 #define hb_mutex_impl_lock(M)   EnterCriticalSection (M)
  62 #define hb_mutex_impl_unlock(M) LeaveCriticalSection (M)
  63 #define hb_mutex_impl_finish(M) DeleteCriticalSection (M)
  64 
  65 
  66 #elif !defined(HB_NO_MT) && (defined(HAVE_PTHREAD) || defined(__APPLE__))
  67 
  68 #include <pthread.h>
  69 typedef pthread_mutex_t hb_mutex_impl_t;
  70 #define HB_MUTEX_IMPL_INIT      PTHREAD_MUTEX_INITIALIZER
  71 #define hb_mutex_impl_init(M)   pthread_mutex_init (M, nullptr)
  72 #define hb_mutex_impl_lock(M)   pthread_mutex_lock (M)
  73 #define hb_mutex_impl_unlock(M) pthread_mutex_unlock (M)
  74 #define hb_mutex_impl_finish(M) pthread_mutex_destroy (M)
  75 
  76 
  77 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
  78 
  79 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_YIELD)
  80 # include <sched.h>
  81 # define HB_SCHED_YIELD() sched_yield ()
  82 #else
  83 # define HB_SCHED_YIELD() HB_STMT_START {} HB_STMT_END
  84 #endif
  85 
  86 /* This actually is not a totally awful implementation. */
  87 typedef volatile int hb_mutex_impl_t;
  88 #define HB_MUTEX_IMPL_INIT      0
  89 #define hb_mutex_impl_init(M)   *(M) = 0
  90 #define hb_mutex_impl_lock(M)   HB_STMT_START { while (__sync_lock_test_and_set((M), 1)) HB_SCHED_YIELD (); } HB_STMT_END
  91 #define hb_mutex_impl_unlock(M) __sync_lock_release (M)


< prev index next >