blob: ac2ab199507dadbddc053e0ae4deedec54efc3ca [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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#ifndef _FUTEX_SYNCHRO_H
18#define _FUTEX_SYNCHRO_H
19
20#ifndef HAVE_FUTEX
21#error "HAVE_FUTEX not defined"
22#endif
23
24#define FUTEX_WAIT_INFINITE (0)
25
26typedef struct futex_mutex_t futex_mutex_t;
27
28struct futex_mutex_t
29{
30 volatile int value;
31};
32
33typedef struct futex_cond_t futex_cond_t;
34
35struct futex_cond_t
36{
37 volatile int value;
38};
39
40
41#if __cplusplus
42extern "C" {
43#endif
44
45void futex_mutex_init(futex_mutex_t *m);
46int futex_mutex_lock(futex_mutex_t *m, unsigned msec);
47void futex_mutex_unlock(futex_mutex_t *m);
48int futex_mutex_trylock(futex_mutex_t *m);
49
50void futex_cond_init(futex_cond_t *c);
51int futex_cond_wait(futex_cond_t *c, futex_mutex_t *m, unsigned msec);
52void futex_cond_signal(futex_cond_t *c);
53void futex_cond_broadcast(futex_cond_t *c);
54
55#if __cplusplus
56} // extern "C"
57#endif
58
59#endif // _FUTEX_SYNCHRO_H
60