OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2007 Chris Wilson | 2 * Copyright © 2007 Chris Wilson |
3 * Copyright © 2009,2010 Red Hat, Inc. | 3 * Copyright © 2009,2010 Red Hat, Inc. |
4 * Copyright © 2011,2012 Google, Inc. | 4 * Copyright © 2011,2012 Google, Inc. |
5 * | 5 * |
6 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
7 * | 7 * |
8 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
9 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
10 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
(...skipping 29 matching lines...) Expand all Loading... |
40 /* We need external help for these */ | 40 /* We need external help for these */ |
41 | 41 |
42 #if 0 | 42 #if 0 |
43 | 43 |
44 | 44 |
45 #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) | 45 #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) |
46 | 46 |
47 #define WIN32_LEAN_AND_MEAN | 47 #define WIN32_LEAN_AND_MEAN |
48 #include <windows.h> | 48 #include <windows.h> |
49 | 49 |
50 #if defined(__MINGW32__) && !defined(MemoryBarrier) | 50 /* MinGW has a convoluted history of supporting MemoryBarrier |
| 51 * properly. As such, define a function to wrap the whole |
| 52 * thing. */ |
51 static inline void _HBMemoryBarrier (void) { | 53 static inline void _HBMemoryBarrier (void) { |
| 54 #if !defined(MemoryBarrier) |
52 long dummy = 0; | 55 long dummy = 0; |
53 InterlockedExchange (&dummy, 1); | 56 InterlockedExchange (&dummy, 1); |
| 57 #else |
| 58 MemoryBarrier (); |
| 59 #endif |
54 } | 60 } |
55 # define MemoryBarrier _HBMemoryBarrier | |
56 #endif | |
57 | 61 |
58 typedef LONG hb_atomic_int_t; | 62 typedef LONG hb_atomic_int_t; |
59 #define hb_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V)) | 63 #define hb_atomic_int_add(AI, V) InterlockedExchangeAdd (&(AI), (V)) |
60 | 64 |
61 #define hb_atomic_ptr_get(P)» » (MemoryBarrier (), (void *) *(P)) | 65 #define hb_atomic_ptr_get(P)» » (_HBMemoryBarrier (), (void *) *(P)) |
62 #define hb_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((voi
d **) (P), (void *) (N), (void *) (O)) == (void *) (O)) | 66 #define hb_atomic_ptr_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((voi
d **) (P), (void *) (N), (void *) (O)) == (void *) (O)) |
63 | 67 |
64 | 68 |
65 #elif !defined(HB_NO_MT) && defined(__APPLE__) | 69 #elif !defined(HB_NO_MT) && defined(__APPLE__) |
66 | 70 |
67 #include <libkern/OSAtomic.h> | 71 #include <libkern/OSAtomic.h> |
68 #ifdef __MAC_OS_X_MIN_REQUIRED | 72 #ifdef __MAC_OS_X_MIN_REQUIRED |
69 #include <AvailabilityMacros.h> | 73 #include <AvailabilityMacros.h> |
70 #elif defined(__IPHONE_OS_MIN_REQUIRED) | 74 #elif defined(__IPHONE_OS_MIN_REQUIRED) |
71 #include <Availability.h> | 75 #include <Availability.h> |
72 #endif | 76 #endif |
73 | 77 |
74 typedef int32_t hb_atomic_int_t; | 78 typedef int32_t hb_atomic_int_t; |
75 #define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V)
) | 79 #define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V)
) |
76 | 80 |
77 #define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P)) | 81 #define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P)) |
78 #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_M
IN_REQUIRED >= 20100) | 82 #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_M
IN_REQUIRED >= 20100) |
79 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void
*) (O), (void *) (N), (void **) (P)) | 83 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void
*) (O), (void *) (N), (void **) (P)) |
80 #else | 84 #else |
81 #if __ppc64__ || __x86_64__ | 85 #if __ppc64__ || __x86_64__ || __arm64__ |
82 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_
t) (O), (int64_t) (N), (int64_t*) (P)) | 86 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_
t) (O), (int64_t) (N), (int64_t*) (P)) |
83 #else | 87 #else |
84 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_
t) (O), (int32_t) (N), (int32_t*) (P)) | 88 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_
t) (O), (int32_t) (N), (int32_t*) (P)) |
85 #endif | 89 #endif |
86 #endif | 90 #endif |
87 | 91 |
88 | 92 |
89 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) | 93 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) |
90 | 94 |
91 typedef int hb_atomic_int_t; | 95 typedef int hb_atomic_int_t; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 #define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V)) | 127 #define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V)) |
124 | 128 |
125 #define hb_atomic_ptr_get(P) ((void *) *(P)) | 129 #define hb_atomic_ptr_get(P) ((void *) *(P)) |
126 #define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (v
oid **) (P) = (void *) (N), true) : false) | 130 #define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (v
oid **) (P) = (void *) (N), true) : false) |
127 | 131 |
128 #endif | 132 #endif |
129 | 133 |
130 /* TODO Add tracing. */ | 134 /* TODO Add tracing. */ |
131 | 135 |
132 #endif /* HB_ATOMIC_PRIVATE_HH */ | 136 #endif /* HB_ATOMIC_PRIVATE_HH */ |
OLD | NEW |