summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/multi-module/wasm-apps/mE.cpp
blob: 11e70af1fe1f96f45765466eecd19ab2d5cc7745 (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
#include <cstdlib>
#include <cstdio>
#include <iostream>

static void
bye_setup()
{
    std::cout << "mE " << __FUNCTION__ << std::endl;
}

static void
bye_func()
{
    std::cout << "mE " << __FUNCTION__ << std::endl;
}

__attribute__((constructor)) void
setup()
{
    std::cout << "mE " << __FUNCTION__ << std::endl;
    if (std::atexit(bye_setup) != 0) {
        std::perror("register an atexit handler failed");
    }
}

__attribute__((destructor)) void
teardown()
{
    std::cout << "mE " << __FUNCTION__ << std::endl;
}

__attribute__((export_name("func1"))) void
func1()
{
    std::cout << "mE " << __FUNCTION__ << std::endl;
    if (std::atexit(bye_func) != 0) {
        std::perror("register an atexit handler failed");
    }
}

__attribute__((export_name("func2"))) void
func2()
{
    std::cout << "mE " << __FUNCTION__ << std::endl;
}