summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/iwasm/common/wasm_shared_memory.h
blob: 6c1c49210f2af3ec50e298051da18ae20e3ea234 (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
/*
 * Copyright (C) 2019 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#ifndef _WASM_SHARED_MEMORY_H
#define _WASM_SHARED_MEMORY_H

#include "bh_common.h"
#if WASM_ENABLE_INTERP != 0
#include "wasm_runtime.h"
#endif
#if WASM_ENABLE_AOT != 0
#include "aot_runtime.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct WASMSharedMemNode {
    bh_list_link l;
    /* Lock */
    korp_mutex lock;
    /* The module reference */
    WASMModuleCommon *module;
    /* The memory information */
    WASMMemoryInstanceCommon *memory_inst;
    /* Lock used for atomic operations */
    korp_mutex shared_mem_lock;

    /* reference count */
    uint32 ref_count;
} WASMSharedMemNode;

bool
wasm_shared_memory_init();

void
wasm_shared_memory_destroy();

WASMSharedMemNode *
wasm_module_get_shared_memory(WASMModuleCommon *module);

int32
shared_memory_inc_reference(WASMModuleCommon *module);

int32
shared_memory_dec_reference(WASMModuleCommon *module);

WASMMemoryInstanceCommon *
shared_memory_get_memory_inst(WASMSharedMemNode *node);

WASMSharedMemNode *
shared_memory_set_memory_inst(WASMModuleCommon *module,
                              WASMMemoryInstanceCommon *memory);

uint32
wasm_runtime_atomic_wait(WASMModuleInstanceCommon *module, void *address,
                         uint64 expect, int64 timeout, bool wait64);

uint32
wasm_runtime_atomic_notify(WASMModuleInstanceCommon *module, void *address,
                           uint32 count);

#ifdef __cplusplus
}
#endif

#endif /* end of _WASM_SHARED_MEMORY_H */