summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/shared/platform/android/platform_init.c
blob: 1e7cf4447b574fd4dab5c1fa0b508a94d169912d (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
 * Copyright (C) 2019 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#include "platform_api_vmcore.h"
#include "platform_api_extension.h"

#define API_NOT_SUPPORT_ERROR(API, VERSION)                                   \
    __android_log_print(ANDROID_LOG_ERROR, "wasm_runtime::",                  \
                        "%s() is only supported when __ANDROID_API__ >= %s.", \
                        #API, #VERSION);

int
bh_platform_init()
{
    return 0;
}

void
bh_platform_destroy()
{}

int
os_printf(const char *fmt, ...)
{
    int ret;
    va_list ap;

    va_start(ap, fmt);
    ret = __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
    va_end(ap);

    return ret;
}

int
os_vprintf(const char *fmt, va_list ap)
{
    return __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
}

#if __ANDROID_API__ < 19

int
futimens(int __dir_fd, const struct timespec __times[2])
{
    API_NOT_SUPPORT_ERROR(futimens, 19);
    return -1;
}

#endif

#if __ANDROID_API__ < 21

int
posix_fallocate(int __fd, off_t __offset, off_t __length)
{
    API_NOT_SUPPORT_ERROR(posix_fallocate, 21);
    return -1;
}

int
posix_fadvise(int fd, off_t offset, off_t len, int advice)
{
    API_NOT_SUPPORT_ERROR(posix_fadvise, 21);
    return -1;
}

int
linkat(int __old_dir_fd, const char *__old_path, int __new_dir_fd,
       const char *__new_path, int __flags)
{
    API_NOT_SUPPORT_ERROR(linkat, 21);
    return -1;
}

int
symlinkat(const char *__old_path, int __new_dir_fd, const char *__new_path)
{
    API_NOT_SUPPORT_ERROR(symlinkat, 21);
    return -1;
}

ssize_t
readlinkat(int __dir_fd, const char *__path, char *__buf, size_t __buf_size)
{
    API_NOT_SUPPORT_ERROR(readlinkat, 21);
    return -1;
}

int
accept4(int __fd, struct sockaddr *__addr, socklen_t *__addr_length,
        int __flags)
{
    API_NOT_SUPPORT_ERROR(accept4, 21);
    return -1;
}

int
dup3(int oldfd, int newfd, int cloexec)
{
    API_NOT_SUPPORT_ERROR(dup3, 21);
    return -1;
}

int
pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id)
{
    API_NOT_SUPPORT_ERROR(pthread_condattr_setclock, 21);
    return -1;
}

int
epoll_create1(int flags)
{
    API_NOT_SUPPORT_ERROR(epoll_create1, 21);
    return -1;
}

int
epoll_pwait(int epfd, struct epoll_event *events, int maxevents, int timeout,
            const sigset_t *sigmask)
{
    API_NOT_SUPPORT_ERROR(epoll_pwait, 21);
    return -1;
}

int
inotify_init1(int flags)
{
    API_NOT_SUPPORT_ERROR(inotify_init1, 21);
    return -1;
}

#endif

#if __ANDROID_API__ < 23

long
telldir(DIR *__dir)
{
    API_NOT_SUPPORT_ERROR(telldir, 23);
    return -1;
}

void
seekdir(DIR *__dir, long __location)
{
    API_NOT_SUPPORT_ERROR(seekdir, 23);
}

#endif

#if __ANDROID_API__ < 24

ssize_t
preadv(int __fd, const struct iovec *__iov, int __count, off_t __offset)
{
    API_NOT_SUPPORT_ERROR(preadv, 24);
    return -1;
}

ssize_t
pwritev(int __fd, const struct iovec *__iov, int __count, off_t __offset)
{
    API_NOT_SUPPORT_ERROR(pwritev, 24);
    return -1;
}

#endif