summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/wasi-threads/wasm-apps/wasi_thread_start.h
blob: a46917d0a0de959ff53c690960de08fead90feb6 (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
/*
 * Copyright (C) 2022 Amazon.com Inc. or its affiliates. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */
#ifndef WASI_THREAD_START_H
#define WASI_THREAD_START_H

#define STACK_SIZE 32 * 1024 // same as the main stack

typedef struct {
    void *stack;
} start_args_t;

static inline int
start_args_init(start_args_t *start_args)
{
    start_args->stack = malloc(STACK_SIZE);
    if (!start_args->stack) {
        return 0;
    }

    start_args->stack += STACK_SIZE;
    return 1;
}

static inline void
start_args_deinit(start_args_t *start_args)
{
    free(start_args->stack - STACK_SIZE);
}

#endif