summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/app-framework/base/app/bh_platform.h
blob: 8e10dcb646cd9e4ca33b9ec7139b4e27419ff41d (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
/*
 * Copyright (C) 2019 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#ifndef DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_
#define DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_

#include <stdbool.h>

typedef unsigned char uint8;
typedef char int8;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned int uint32;
typedef int int32;

#ifndef NULL
#define NULL ((void *)0)
#endif

#ifndef __cplusplus
#define true 1
#define false 0
#define inline __inline
#endif

// all wasm-app<->native shared source files should use WA_MALLOC/WA_FREE.
// they will be mapped to different implementations in each side
#ifndef WA_MALLOC
#define WA_MALLOC malloc
#endif

#ifndef WA_FREE
#define WA_FREE free
#endif

uint32
htonl(uint32 value);
uint32
ntohl(uint32 value);
uint16
htons(uint16 value);
uint16
ntohs(uint16 value);

// We are not worried for the WASM world since the sandbox will catch it.
#define bh_memcpy_s(dst, dst_len, src, src_len) memcpy(dst, src, src_len)

#ifdef NDEBUG
#define bh_assert(v) (void)0
#else
#define bh_assert(v)                                                     \
    do {                                                                 \
        if (!(v)) {                                                      \
            int _count;                                                  \
            printf("ASSERTION FAILED: %s, at %s, line %d", #v, __FILE__, \
                   __LINE__);                                            \
            _count = printf("\n");                                       \
            printf("%d\n", _count / (_count - 1));                       \
        }                                                                \
    } while (0)
#endif

#endif /* DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_ */