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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/ports/SkAtomics_none.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/*
     1.5 + * Copyright 2013 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkAtomics_none_DEFINED
    1.12 +#define SkAtomics_none_DEFINED
    1.13 +
    1.14 +/** Non-atomic atomics for uniprocessor systems. */
    1.15 +
    1.16 +#include <stdint.h>
    1.17 +
    1.18 +static inline int32_t sk_atomic_inc(int32_t* addr) {
    1.19 +    int32_t value = *addr;
    1.20 +    *addr = value + 1;
    1.21 +    return value;
    1.22 +}
    1.23 +
    1.24 +static inline int32_t sk_atomic_add(int32_t* addr, int32_t inc) {
    1.25 +    int32_t value = *addr;
    1.26 +    *addr = value + inc;
    1.27 +    return value;
    1.28 +}
    1.29 +
    1.30 +static inline int32_t sk_atomic_dec(int32_t* addr) {
    1.31 +    int32_t value = *addr;
    1.32 +    *addr = value - 1;
    1.33 +    return value;
    1.34 +}
    1.35 +
    1.36 +static inline void sk_membar_acquire__after_atomic_dec() { }
    1.37 +
    1.38 +static inline int32_t sk_atomic_conditional_inc(int32_t* addr) {
    1.39 +    int32_t value = *addr;
    1.40 +    if (value != 0) ++*addr;
    1.41 +    return value;
    1.42 +}
    1.43 +
    1.44 +static inline bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after) {
    1.45 +    if (*addr != before) return false;
    1.46 +    *addr = after;
    1.47 +    return true;
    1.48 +}
    1.49 +
    1.50 +static inline void sk_membar_acquire__after_atomic_conditional_inc() { }
    1.51 +
    1.52 +#endif

mercurial