gfx/skia/trunk/src/ports/SkAtomics_none.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /*
     2  * Copyright 2013 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef SkAtomics_none_DEFINED
     9 #define SkAtomics_none_DEFINED
    11 /** Non-atomic atomics for uniprocessor systems. */
    13 #include <stdint.h>
    15 static inline int32_t sk_atomic_inc(int32_t* addr) {
    16     int32_t value = *addr;
    17     *addr = value + 1;
    18     return value;
    19 }
    21 static inline int32_t sk_atomic_add(int32_t* addr, int32_t inc) {
    22     int32_t value = *addr;
    23     *addr = value + inc;
    24     return value;
    25 }
    27 static inline int32_t sk_atomic_dec(int32_t* addr) {
    28     int32_t value = *addr;
    29     *addr = value - 1;
    30     return value;
    31 }
    33 static inline void sk_membar_acquire__after_atomic_dec() { }
    35 static inline int32_t sk_atomic_conditional_inc(int32_t* addr) {
    36     int32_t value = *addr;
    37     if (value != 0) ++*addr;
    38     return value;
    39 }
    41 static inline bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after) {
    42     if (*addr != before) return false;
    43     *addr = after;
    44     return true;
    45 }
    47 static inline void sk_membar_acquire__after_atomic_conditional_inc() { }
    49 #endif

mercurial