epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #include "SkThread.h" |
| 9 | |
reed@google.com | dcbd6e3 | 2012-01-12 15:21:16 +0000 | [diff] [blame] | 10 | int32_t sk_atomic_inc(int32_t* addr) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 11 | int32_t value = *addr; |
| 12 | *addr = value + 1; |
| 13 | return value; |
| 14 | } |
| 15 | |
scroggo@google.com | 50ccb0a | 2012-07-16 16:51:28 +0000 | [diff] [blame] | 16 | int32_t sk_atomic_add(int32_t* addr, int32_t inc) { |
| 17 | int32_t value = *addr; |
| 18 | *addr = value + inc; |
| 19 | return value; |
| 20 | } |
| 21 | |
reed@google.com | dcbd6e3 | 2012-01-12 15:21:16 +0000 | [diff] [blame] | 22 | int32_t sk_atomic_dec(int32_t* addr) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | int32_t value = *addr; |
| 24 | *addr = value - 1; |
| 25 | return value; |
| 26 | } |
bungeman@google.com | a02bc15 | 2012-05-16 18:21:56 +0000 | [diff] [blame] | 27 | void sk_membar_aquire__after_atomic_dec() { } |
| 28 | |
| 29 | int32_t sk_atomic_conditional_inc(int32_t* addr) { |
| 30 | int32_t value = *addr; |
| 31 | if (value != 0) ++*addr; |
| 32 | return value; |
| 33 | } |
| 34 | void sk_membar_aquire__after_atomic_conditional_inc() { } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 35 | |
reed@google.com | dcbd6e3 | 2012-01-12 15:21:16 +0000 | [diff] [blame] | 36 | SkMutex::SkMutex() {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | |
reed@google.com | dcbd6e3 | 2012-01-12 15:21:16 +0000 | [diff] [blame] | 38 | SkMutex::~SkMutex() {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 39 | |
bungeman@google.com | 5548752 | 2012-05-14 14:09:24 +0000 | [diff] [blame] | 40 | #ifndef SK_USE_POSIX_THREADS |
reed@google.com | dcbd6e3 | 2012-01-12 15:21:16 +0000 | [diff] [blame] | 41 | void SkMutex::acquire() {} |
reed@google.com | dcbd6e3 | 2012-01-12 15:21:16 +0000 | [diff] [blame] | 42 | void SkMutex::release() {} |
bungeman@google.com | 5548752 | 2012-05-14 14:09:24 +0000 | [diff] [blame] | 43 | #endif |