summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/linux-sgx/untrusted/pthread.c
blob: 890ef754c56b28d18917549cf231b43aa1f6ca0f (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
/*
 * Copyright (C) 2019 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#include <stdlib.h>
#include <pthread.h>

int
ocall_pthread_rwlock_init(void **rwlock, void *attr)
{
    int ret = 0;

    *rwlock = malloc(sizeof(pthread_rwlock_t));
    if (*rwlock == NULL)
        return -1;

    ret = pthread_rwlock_init((pthread_rwlock_t *)*rwlock, NULL);
    if (ret != 0) {
        free(*rwlock);
        *rwlock = NULL;
    }
    (void)attr;
    return ret;
}

int
ocall_pthread_rwlock_destroy(void *rwlock)
{
    pthread_rwlock_t *lock = (pthread_rwlock_t *)rwlock;
    int ret;

    ret = pthread_rwlock_destroy(lock);
    free(lock);
    return ret;
}

int
ocall_pthread_rwlock_rdlock(void *rwlock)
{
    return pthread_rwlock_rdlock((pthread_rwlock_t *)rwlock);
}

int
ocall_pthread_rwlock_wrlock(void *rwlock)
{
    return pthread_rwlock_wrlock((pthread_rwlock_t *)rwlock);
}

int
ocall_pthread_rwlock_unlock(void *rwlock)
{
    return pthread_rwlock_unlock((pthread_rwlock_t *)rwlock);
}