1/*
2 * Copyright 2023, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _FBSD_COMPAT_SYS_CONDVAR_H_
6#define _FBSD_COMPAT_SYS_CONDVAR_H_
7
8
9#include <sys/param.h>
10#include <KernelExport.h>
11
12
13__BEGIN_DECLS
14
15
16struct cv {
17	// We cannot include <condition_variable.h> here as it is C++-only.
18	char condition[roundup((sizeof(void*) * 5) + sizeof(spinlock) + sizeof(int32), sizeof(void*))];
19};
20
21#ifdef __cplusplus
22#	define __cv_ConditionVariable(CV) reinterpret_cast<ConditionVariable*>(&(CV)->condition)
23#endif
24
25
26void cv_init(struct cv*, const char*);
27void cv_destroy(struct cv*);
28void cv_wait(struct cv*, struct mtx*);
29int cv_timedwait(struct cv*, struct mtx*, int);
30void cv_signal(struct cv*);
31
32
33__END_DECLS
34
35
36#endif /* _FBSD_COMPAT_SYS_CONDVAR_H_ */
37