Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-atomic-private.hh

Issue 10915172: harfbuzz-ng roll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/harfbuzz-ng/harfbuzz.gyp ('k') | third_party/harfbuzz-ng/src/hb-blob.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 #include "hb-private.hh" 35 #include "hb-private.hh"
36 36
37 37
38 /* atomic_int */ 38 /* atomic_int */
39 39
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(_MSC_VER) && _MSC_VER >= 1600 45 #elif !defined(HB_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
46 46
47 #include <intrin.h> 47 #define WIN32_LEAN_AND_MEAN
48 #pragma intrinsic(_InterlockedExchangeAdd, _InterlockedCompareExchangePointer) 48 #include <windows.h>
49
50 /* mingw32 does not have MemoryBarrier.
51 * MemoryBarrier may be defined as a macro or a function.
52 * Just make a failsafe version for ourselves. */
53 #ifdef MemoryBarrier
54 #define HBMemoryBarrier MemoryBarrier
55 #else
56 static inline void HBMemoryBarrier (void) {
57 long dummy = 0;
58 InterlockedExchange (&dummy, 1);
59 }
60 #endif
49 61
50 typedef long hb_atomic_int_t; 62 typedef long hb_atomic_int_t;
51 #define hb_atomic_int_add(AI, V)» _InterlockedExchangeAdd (&(AI), (V)) 63 #define hb_atomic_int_add(AI, V)» InterlockedExchangeAdd (&(AI), (V))
52 64
53 #define hb_atomic_ptr_get(P)» » (MemoryBarrier (), (void *) *(P)) 65 #define hb_atomic_ptr_get(P)» » (HBMemoryBarrier (), (void *) *(P))
54 #define hb_atomic_ptr_cmpexch(P,O,N)» (_InterlockedCompareExchangePointer ((vo id **) (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))
55 67
56 68
57 #elif !defined(HB_NO_MT) && defined(__APPLE__) 69 #elif !defined(HB_NO_MT) && defined(__APPLE__)
58 70
59 #include <libkern/OSAtomic.h> 71 #include <libkern/OSAtomic.h>
60 72
61 typedef int32_t hb_atomic_int_t; 73 typedef int32_t hb_atomic_int_t;
62 #define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V) ) 74 #define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V) )
63 75
64 #define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P)) 76 #define hb_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P))
65 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P)) 77 #define hb_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
66 78
67 79
68 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES) && !defined(__ MINGW32__) 80 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
69 81
70 typedef int hb_atomic_int_t; 82 typedef int hb_atomic_int_t;
71 #define hb_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V)) 83 #define hb_atomic_int_add(AI, V) __sync_fetch_and_add (&(AI), (V))
72 84
73 #define hb_atomic_ptr_get(P) (void *) (__sync_synchronize (), *(P)) 85 #define hb_atomic_ptr_get(P) (void *) (__sync_synchronize (), *(P))
74 #define hb_atomic_ptr_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N)) 86 #define hb_atomic_ptr_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N))
75 87
76 #elif !defined(HB_NO_MT) && defined(HAVE_GLIB) 88 #elif !defined(HB_NO_MT) && defined(HAVE_GLIB)
77 89
78 #include <glib.h> 90 #include <glib.h>
(...skipping 24 matching lines...) Expand all
103 #define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V)) 115 #define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V))
104 116
105 #define hb_atomic_ptr_get(P) ((void *) *(P)) 117 #define hb_atomic_ptr_get(P) ((void *) *(P))
106 #define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (v oid **) (P) = (void *) (N), true) : false) 118 #define hb_atomic_ptr_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (v oid **) (P) = (void *) (N), true) : false)
107 119
108 #endif 120 #endif
109 121
110 /* TODO Add tracing. */ 122 /* TODO Add tracing. */
111 123
112 #endif /* HB_ATOMIC_PRIVATE_HH */ 124 #endif /* HB_ATOMIC_PRIVATE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/harfbuzz.gyp ('k') | third_party/harfbuzz-ng/src/hb-blob.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698