| * Copyright 2015 Google Inc. |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| #include "include/private/SkSpinlock.h" |
| #include "include/private/SkMutex.h" |
| static void debug_trace() { |
| int len = backtrace(stack, SK_ARRAY_COUNT(stack)); |
| // As you might imagine, we can't use an SkSpinlock here... |
| SkAutoMutexExclusive locked(lock); |
| backtrace_symbols_fd(stack, len, 2/*stderr*/); |
| static void debug_trace() {} |
| // Renamed from "pause" to avoid conflict with function defined in unistd.h |
| #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 |
| static void do_pause() { _mm_pause(); } |
| static void do_pause() { /*spin*/ } |
| void SkSpinlock::contendedAcquire() { |
| // To act as a mutex, we need an acquire barrier when we acquire the lock. |
| while (fLocked.exchange(true, std::memory_order_acquire)) { |