blob: b35319cf42a96930e85cfa0ca4191974a906ef12 [file] [log] [blame]
Glenn Kasten7cc8f542016-12-01 16:12:59 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <audio_utils/fifo_index.h>
18#include <audio_utils/futex.h>
19
20// These are not implemented within <audio_utils/fifo_index.h>
21// so that we don't expose futex.
22
23uint32_t audio_utils_fifo_index::loadAcquire()
24{
25 return atomic_load_explicit(&mIndex, std::memory_order_acquire);
26}
27
28void audio_utils_fifo_index::storeRelease(uint32_t value)
29{
30 atomic_store_explicit(&mIndex, value, std::memory_order_release);
31}
32
33int audio_utils_fifo_index::wait(int op, uint32_t expected, const struct timespec *timeout)
34{
35 return sys_futex(&mIndex, op, expected, timeout, NULL, 0);
36}
37
38int audio_utils_fifo_index::wake(int op, int waiters)
39{
40 return sys_futex(&mIndex, op, waiters, NULL, NULL, 0);
41}