summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/pthread_forward.cpp
blob: 32fcd015e72d63703c1ce287d856538c757b0c36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright (c) 2021, Gunnar Beutner <gunnar@beutner.name>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <AK/Assertions.h>
#include <LibC/bits/pthread_forward.h>

static PthreadFunctions s_pthread_functions;

void __init_pthread_forward(PthreadFunctions funcs)
{
    s_pthread_functions = funcs;
}

int pthread_mutex_trylock(pthread_mutex_t* mutex)
{
    VERIFY(s_pthread_functions.pthread_mutex_trylock);
    return s_pthread_functions.pthread_mutex_trylock(mutex);
}

int pthread_mutex_destroy(pthread_mutex_t* mutex)
{
    VERIFY(s_pthread_functions.pthread_mutex_destroy);
    return s_pthread_functions.pthread_mutex_destroy(mutex);
}

int pthread_mutexattr_init(pthread_mutexattr_t* attr)
{
    VERIFY(s_pthread_functions.pthread_mutexattr_init);
    return s_pthread_functions.pthread_mutexattr_init(attr);
}

int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type)
{
    VERIFY(s_pthread_functions.pthread_mutexattr_settype);
    return s_pthread_functions.pthread_mutexattr_settype(attr, type);
}

int pthread_mutexattr_destroy(pthread_mutexattr_t* attr)
{
    VERIFY(s_pthread_functions.pthread_mutexattr_destroy);
    return s_pthread_functions.pthread_mutexattr_destroy(attr);
}

int pthread_once(pthread_once_t* self, void (*callback)(void))
{
    VERIFY(s_pthread_functions.pthread_once);
    return s_pthread_functions.pthread_once(self, callback);
}

int pthread_cond_broadcast(pthread_cond_t* cond)
{
    VERIFY(s_pthread_functions.pthread_cond_broadcast);
    return s_pthread_functions.pthread_cond_broadcast(cond);
}

int pthread_cond_init(pthread_cond_t* cond, pthread_condattr_t const* attr)
{
    VERIFY(s_pthread_functions.pthread_cond_init);
    return s_pthread_functions.pthread_cond_init(cond, attr);
}

int pthread_cond_signal(pthread_cond_t* cond)
{
    VERIFY(s_pthread_functions.pthread_cond_signal);
    return s_pthread_functions.pthread_cond_signal(cond);
}

int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
{
    VERIFY(s_pthread_functions.pthread_cond_wait);
    return s_pthread_functions.pthread_cond_wait(cond, mutex);
}

int pthread_cond_destroy(pthread_cond_t* cond)
{
    VERIFY(s_pthread_functions.pthread_cond_destroy);
    return s_pthread_functions.pthread_cond_destroy(cond);
}

int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime)
{
    VERIFY(s_pthread_functions.pthread_cond_timedwait);
    return s_pthread_functions.pthread_cond_timedwait(cond, mutex, abstime);
}