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

Side by Side Diff: Source/wtf/Atomics.h

Issue 21666003: Enhancements to PartitionAlloc to support threading and arbitrary allocation sizes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review comments. Created 7 years, 4 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 | « Source/core/rendering/RenderObject.cpp ('k') | Source/wtf/PartitionAlloc.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 (C) 2007, 2008, 2010, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 26 matching lines...) Expand all
37 #if OS(WINDOWS) 37 #if OS(WINDOWS)
38 #include <windows.h> 38 #include <windows.h>
39 #elif OS(ANDROID) 39 #elif OS(ANDROID)
40 #include <sys/atomics.h> 40 #include <sys/atomics.h>
41 #endif 41 #endif
42 42
43 namespace WTF { 43 namespace WTF {
44 44
45 #if OS(WINDOWS) 45 #if OS(WINDOWS)
46 46
47 inline int atomicIncrement(int volatile* addend) { return InterlockedIncrement(r einterpret_cast<long volatile*>(addend)); } 47 ALWAYS_INLINE int atomicIncrement(int volatile* addend) { return InterlockedIncr ement(reinterpret_cast<long volatile*>(addend)); }
48 inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(r einterpret_cast<long volatile*>(addend)); } 48 ALWAYS_INLINE int atomicDecrement(int volatile* addend) { return InterlockedDecr ement(reinterpret_cast<long volatile*>(addend)); }
49 49
50 inline int64_t atomicIncrement(int64_t volatile* addend) { return InterlockedInc rement64(reinterpret_cast<long long volatile*>(addend)); } 50 ALWAYS_INLINE int64_t atomicIncrement(int64_t volatile* addend) { return Interlo ckedIncrement64(reinterpret_cast<long long volatile*>(addend)); }
51 inline int64_t atomicDecrement(int64_t volatile* addend) { return InterlockedDec rement64(reinterpret_cast<long long volatile*>(addend)); } 51 ALWAYS_INLINE int64_t atomicDecrement(int64_t volatile* addend) { return Interlo ckedDecrement64(reinterpret_cast<long long volatile*>(addend)); }
52 52
53 #elif OS(ANDROID) 53 #elif OS(ANDROID)
54 54
55 // Note, __atomic_{inc, dec}() return the previous value of addend's content. 55 // Note, __atomic_{inc, dec}() return the previous value of addend's content.
56 inline int atomicIncrement(int volatile* addend) { return __atomic_inc(addend) + 1; } 56 ALWAYS_INLINE int atomicIncrement(int volatile* addend) { return __atomic_inc(ad dend) + 1; }
57 inline int atomicDecrement(int volatile* addend) { return __atomic_dec(addend) - 1; } 57 ALWAYS_INLINE int atomicDecrement(int volatile* addend) { return __atomic_dec(ad dend) - 1; }
58 58
59 #else 59 #else
60 60
61 inline int atomicIncrement(int volatile* addend) { return __sync_add_and_fetch(a ddend, 1); } 61 ALWAYS_INLINE int atomicIncrement(int volatile* addend) { return __sync_add_and_ fetch(addend, 1); }
62 inline int atomicDecrement(int volatile* addend) { return __sync_sub_and_fetch(a ddend, 1); } 62 ALWAYS_INLINE int atomicDecrement(int volatile* addend) { return __sync_sub_and_ fetch(addend, 1); }
63 63
64 inline int64_t atomicIncrement(int64_t volatile* addend) { return __sync_add_and _fetch(addend, 1); } 64 ALWAYS_INLINE int64_t atomicIncrement(int64_t volatile* addend) { return __sync_ add_and_fetch(addend, 1); }
65 inline int64_t atomicDecrement(int64_t volatile* addend) { return __sync_sub_and _fetch(addend, 1); } 65 ALWAYS_INLINE int64_t atomicDecrement(int64_t volatile* addend) { return __sync_ sub_and_fetch(addend, 1); }
66 66
67 #endif 67 #endif
68 68
69 } // namespace WTF 69 } // namespace WTF
70 70
71 using WTF::atomicDecrement; 71 using WTF::atomicDecrement;
72 using WTF::atomicIncrement; 72 using WTF::atomicIncrement;
73 73
74 #endif // Atomics_h 74 #endif // Atomics_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderObject.cpp ('k') | Source/wtf/PartitionAlloc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698