Apply clang-format for core/iwasm compilation and libraries (#784)

Apply clang-format for core/iwasm/compilation and core/iwasm/libraries files.
Add wasm-c-api empty_imports sample to workflow test.
And enable triggering workflow when core/config.h changes.
This commit is contained in:
Wenyong Huang
2021-10-13 15:13:00 +08:00
committed by GitHub
parent dc65d2910a
commit fb4afc7ca4
87 changed files with 9321 additions and 9829 deletions

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -32,13 +34,13 @@
#define LOCKS_SHARED(...) LOCK_ANNOTATE(shared_lock_function(__VA_ARGS__))
#define TRYLOCKS_EXCLUSIVE(...) \
LOCK_ANNOTATE(exclusive_trylock_function(__VA_ARGS__))
LOCK_ANNOTATE(exclusive_trylock_function(__VA_ARGS__))
#define TRYLOCKS_SHARED(...) LOCK_ANNOTATE(shared_trylock_function(__VA_ARGS__))
#define UNLOCKS(...) LOCK_ANNOTATE(unlock_function(__VA_ARGS__))
#define REQUIRES_EXCLUSIVE(...) \
LOCK_ANNOTATE(exclusive_locks_required(__VA_ARGS__))
LOCK_ANNOTATE(exclusive_locks_required(__VA_ARGS__))
#define REQUIRES_SHARED(...) LOCK_ANNOTATE(shared_locks_required(__VA_ARGS__))
#define REQUIRES_UNLOCKED(...) LOCK_ANNOTATE(locks_excluded(__VA_ARGS__))
@ -50,8 +52,10 @@ struct LOCKABLE mutex {
pthread_mutex_t object;
};
/* clang-format off */
#define MUTEX_INITIALIZER \
{ PTHREAD_MUTEX_INITIALIZER }
{ PTHREAD_MUTEX_INITIALIZER }
/* clang-format on */
static inline bool
mutex_init(struct mutex *lock) REQUIRES_UNLOCKED(*lock)
@ -117,14 +121,15 @@ rwlock_destroy(struct rwlock *lock) UNLOCKS(*lock) NO_LOCK_ANALYSIS
struct LOCKABLE cond {
pthread_cond_t object;
#if !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK || \
!CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
#if !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK \
|| !CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
clockid_t clock;
#endif
};
static inline bool
cond_init_monotonic(struct cond *cond) {
cond_init_monotonic(struct cond *cond)
{
bool ret = false;
#if CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK
pthread_condattr_t attr;
@ -147,8 +152,8 @@ fail:
ret = true;
#endif
#if !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK || \
!CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
#if !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK \
|| !CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
cond->clock = CLOCK_MONOTONIC;
#endif
return ret;
@ -159,28 +164,29 @@ cond_init_realtime(struct cond *cond)
{
if (pthread_cond_init(&cond->object, NULL) != 0)
return false;
#if !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK || \
!CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
#if !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK \
|| !CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
cond->clock = CLOCK_REALTIME;
#endif
return true;
}
static inline void
cond_destroy(struct cond *cond) {
cond_destroy(struct cond *cond)
{
pthread_cond_destroy(&cond->object);
}
static inline void
cond_signal(struct cond *cond) {
cond_signal(struct cond *cond)
{
pthread_cond_signal(&cond->object);
}
#if !CONFIG_HAS_CLOCK_NANOSLEEP
static inline bool
cond_timedwait(struct cond *cond, struct mutex *lock,
uint64_t timeout, bool abstime)
REQUIRES_EXCLUSIVE(*lock) NO_LOCK_ANALYSIS
cond_timedwait(struct cond *cond, struct mutex *lock, uint64_t timeout,
bool abstime) REQUIRES_EXCLUSIVE(*lock) NO_LOCK_ANALYSIS
{
int ret;
struct timespec ts = {
@ -220,8 +226,8 @@ cond_timedwait(struct cond *cond, struct mutex *lock,
else {
#if CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
/* Implementation supports relative timeouts. */
ret = pthread_cond_timedwait_relative_np(&cond->object,
&lock->object, &ts);
ret = pthread_cond_timedwait_relative_np(&cond->object, &lock->object,
&ts);
bh_assert((ret == 0 || ret == ETIMEDOUT)
&& "pthread_cond_timedwait_relative_np() failed");
return ret == ETIMEDOUT;

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -12,29 +14,29 @@
#ifndef COMMON_LIMITS_H
#define COMMON_LIMITS_H
#define NUMERIC_MIN(t) \
_Generic((t)0, char \
: CHAR_MIN, signed char \
: SCHAR_MIN, unsigned char : 0, short \
: SHRT_MIN, unsigned short : 0, int \
: INT_MIN, unsigned int : 0, long \
: LONG_MIN, unsigned long : 0, long long \
: LLONG_MIN, unsigned long long : 0, default \
: (void)0)
#define NUMERIC_MIN(t) \
_Generic((t)0, char \
: CHAR_MIN, signed char \
: SCHAR_MIN, unsigned char : 0, short \
: SHRT_MIN, unsigned short : 0, int \
: INT_MIN, unsigned int : 0, long \
: LONG_MIN, unsigned long : 0, long long \
: LLONG_MIN, unsigned long long : 0, default \
: (void)0)
#define NUMERIC_MAX(t) \
_Generic((t)0, char \
: CHAR_MAX, signed char \
: SCHAR_MAX, unsigned char \
: UCHAR_MAX, short \
: SHRT_MAX, unsigned short \
: USHRT_MAX, int \
: INT_MAX, unsigned int \
: UINT_MAX, long \
: LONG_MAX, unsigned long \
: ULONG_MAX, long long \
: LLONG_MAX, unsigned long long \
: ULLONG_MAX, default \
: (void)0)
#define NUMERIC_MAX(t) \
_Generic((t)0, char \
: CHAR_MAX, signed char \
: SCHAR_MAX, unsigned char \
: UCHAR_MAX, short \
: SHRT_MAX, unsigned short \
: USHRT_MAX, int \
: INT_MAX, unsigned int \
: UINT_MAX, long \
: LONG_MAX, unsigned long \
: ULONG_MAX, long long \
: LLONG_MAX, unsigned long long \
: ULLONG_MAX, default \
: (void)0)
#endif

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -20,41 +22,48 @@ struct fd_prestat;
struct syscalls;
struct fd_table {
struct rwlock lock;
struct fd_entry *entries;
size_t size;
size_t used;
struct rwlock lock;
struct fd_entry *entries;
size_t size;
size_t used;
};
struct fd_prestats {
struct rwlock lock;
struct fd_prestat *prestats;
size_t size;
size_t used;
struct rwlock lock;
struct fd_prestat *prestats;
size_t size;
size_t used;
};
struct argv_environ_values {
const char *argv_buf;
size_t argv_buf_size;
char **argv_list;
size_t argc;
char *environ_buf;
size_t environ_buf_size;
char **environ_list;
size_t environ_count;
const char *argv_buf;
size_t argv_buf_size;
char **argv_list;
size_t argc;
char *environ_buf;
size_t environ_buf_size;
char **environ_list;
size_t environ_count;
};
bool fd_table_init(struct fd_table *);
bool fd_table_insert_existing(struct fd_table *, __wasi_fd_t, int);
bool fd_prestats_init(struct fd_prestats *);
bool fd_prestats_insert(struct fd_prestats *, const char *, __wasi_fd_t);
bool argv_environ_init(struct argv_environ_values *argv_environ,
char *argv_buf, size_t argv_buf_size,
char **argv_list, size_t argc,
char *environ_buf, size_t environ_buf_size,
char **environ_list, size_t environ_count);
void argv_environ_destroy(struct argv_environ_values *argv_environ);
void fd_table_destroy(struct fd_table *ft);
void fd_prestats_destroy(struct fd_prestats *pt);
bool
fd_table_init(struct fd_table *);
bool
fd_table_insert_existing(struct fd_table *, __wasi_fd_t, int);
bool
fd_prestats_init(struct fd_prestats *);
bool
fd_prestats_insert(struct fd_prestats *, const char *, __wasi_fd_t);
bool
argv_environ_init(struct argv_environ_values *argv_environ, char *argv_buf,
size_t argv_buf_size, char **argv_list, size_t argc,
char *environ_buf, size_t environ_buf_size,
char **environ_list, size_t environ_count);
void
argv_environ_destroy(struct argv_environ_values *argv_environ);
void
fd_table_destroy(struct fd_table *ft);
void
fd_prestats_destroy(struct fd_prestats *pt);
#endif

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -15,76 +17,82 @@
// LIST: Double-linked list.
#define LIST_HEAD(name, type) \
struct name { \
struct type *l_first; \
}
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
struct name { \
struct type *l_first; \
}
#define LIST_ENTRY(type) \
struct { \
struct type *l_next; \
struct type **l_prev; \
}
/* clang-format off */
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
/* clang-format on */
#define LIST_ENTRY(type) \
struct { \
struct type *l_next; \
struct type **l_prev; \
}
#define LIST_FOREACH(var, head, field) \
for ((var) = (head)->l_first; (var) != NULL; (var) = (var)->field.l_next)
#define LIST_INIT(head) \
do { \
(head)->l_first = NULL; \
} while (0)
#define LIST_INSERT_HEAD(head, element, field) \
do { \
(element)->field.l_next = (head)->l_first; \
if ((head)->l_first != NULL) \
(head)->l_first->field.l_prev = &(element)->field.l_next; \
(head)->l_first = (element); \
(element)->field.l_prev = &(head)->l_first; \
} while (0)
#define LIST_REMOVE(element, field) \
do { \
if ((element)->field.l_next != NULL) \
(element)->field.l_next->field.l_prev = (element)->field.l_prev; \
*(element)->field.l_prev = (element)->field.l_next; \
} while (0)
for ((var) = (head)->l_first; (var) != NULL; (var) = (var)->field.l_next)
#define LIST_INIT(head) \
do { \
(head)->l_first = NULL; \
} while (0)
#define LIST_INSERT_HEAD(head, element, field) \
do { \
(element)->field.l_next = (head)->l_first; \
if ((head)->l_first != NULL) \
(head)->l_first->field.l_prev = &(element)->field.l_next; \
(head)->l_first = (element); \
(element)->field.l_prev = &(head)->l_first; \
} while (0)
#define LIST_REMOVE(element, field) \
do { \
if ((element)->field.l_next != NULL) \
(element)->field.l_next->field.l_prev = (element)->field.l_prev; \
*(element)->field.l_prev = (element)->field.l_next; \
} while (0)
// TAILQ: Double-linked list with tail pointer.
#define TAILQ_HEAD(name, type) \
struct name { \
struct type *t_first; \
struct type **t_last; \
}
struct name { \
struct type *t_first; \
struct type **t_last; \
}
#define TAILQ_ENTRY(type) \
struct { \
struct type *t_next; \
struct type **t_prev; \
}
#define TAILQ_ENTRY(type) \
struct { \
struct type *t_next; \
struct type **t_prev; \
}
#define TAILQ_EMPTY(head) ((head)->t_first == NULL)
#define TAILQ_FIRST(head) ((head)->t_first)
#define TAILQ_FOREACH(var, head, field) \
for ((var) = (head)->t_first; (var) != NULL; (var) = (var)->field.t_next)
#define TAILQ_INIT(head) \
do { \
(head)->t_first = NULL; \
(head)->t_last = &(head)->t_first; \
} while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) \
do { \
(elm)->field.t_next = NULL; \
(elm)->field.t_prev = (head)->t_last; \
*(head)->t_last = (elm); \
(head)->t_last = &(elm)->field.t_next; \
} while (0)
#define TAILQ_REMOVE(head, element, field) \
do { \
if ((element)->field.t_next != NULL) \
(element)->field.t_next->field.t_prev = (element)->field.t_prev; \
else \
(head)->t_last = (element)->field.t_prev; \
*(element)->field.t_prev = (element)->field.t_next; \
} while (0)
for ((var) = (head)->t_first; (var) != NULL; (var) = (var)->field.t_next)
#define TAILQ_INIT(head) \
do { \
(head)->t_first = NULL; \
(head)->t_last = &(head)->t_first; \
} while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) \
do { \
(elm)->field.t_next = NULL; \
(elm)->field.t_prev = (head)->t_last; \
*(head)->t_last = (elm); \
(head)->t_last = &(elm)->field.t_next; \
} while (0)
#define TAILQ_REMOVE(head, element, field) \
do { \
if ((element)->field.t_next != NULL) \
(element)->field.t_next->field.t_prev = (element)->field.t_prev; \
else \
(head)->t_last = (element)->field.t_prev; \
*(element)->field.t_prev = (element)->field.t_next; \
} while (0)
#endif

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -15,8 +17,10 @@
#if CONFIG_HAS_ARC4RANDOM_BUF
void random_buf(void *buf, size_t len) {
arc4random_buf(buf, len);
void
random_buf(void *buf, size_t len)
{
arc4random_buf(buf, len);
}
#elif CONFIG_HAS_GETRANDOM
@ -25,42 +29,48 @@ void random_buf(void *buf, size_t len) {
#include <sys/random.h>
#endif
void random_buf(void *buf, size_t len) {
for (;;) {
ssize_t x = getrandom(buf, len, 0);
if (x < 0) {
if (errno == EINTR)
continue;
os_printf("getrandom failed: %s", strerror(errno));
abort();
}
if ((size_t)x == len)
return;
buf = (void *)((unsigned char *)buf + x);
len -= (size_t)x;
}
void
random_buf(void *buf, size_t len)
{
for (;;) {
ssize_t x = getrandom(buf, len, 0);
if (x < 0) {
if (errno == EINTR)
continue;
os_printf("getrandom failed: %s", strerror(errno));
abort();
}
if ((size_t)x == len)
return;
buf = (void *)((unsigned char *)buf + x);
len -= (size_t)x;
}
}
#else
static int urandom;
static void open_urandom(void) {
urandom = open("/dev/urandom", O_RDONLY);
if (urandom < 0) {
os_printf("Failed to open /dev/urandom\n");
abort();
}
static void
open_urandom(void)
{
urandom = open("/dev/urandom", O_RDONLY);
if (urandom < 0) {
os_printf("Failed to open /dev/urandom\n");
abort();
}
}
void random_buf(void *buf, size_t len) {
static pthread_once_t open_once = PTHREAD_ONCE_INIT;
pthread_once(&open_once, open_urandom);
void
random_buf(void *buf, size_t len)
{
static pthread_once_t open_once = PTHREAD_ONCE_INIT;
pthread_once(&open_once, open_urandom);
if ((size_t)read(urandom, buf, len) != len) {
os_printf("Short read on /dev/urandom\n");
abort();
}
if ((size_t)read(urandom, buf, len) != len) {
os_printf("Short read on /dev/urandom\n");
abort();
}
}
#endif
@ -72,15 +82,17 @@ void random_buf(void *buf, size_t len) {
// arc4random() until it lies within the range [2^k % upper, 2^k). As
// this range has length k * upper, we can safely obtain a number
// without any modulo bias.
uintmax_t random_uniform(uintmax_t upper) {
// Compute 2^k % upper
// == (2^k - upper) % upper
// == -upper % upper.
uintmax_t lower = -upper % upper;
for (;;) {
uintmax_t value;
random_buf(&value, sizeof(value));
if (value >= lower)
return value % upper;
}
uintmax_t
random_uniform(uintmax_t upper)
{
// Compute 2^k % upper
// == (2^k - upper) % upper
// == -upper % upper.
uintmax_t lower = -upper % upper;
for (;;) {
uintmax_t value;
random_buf(&value, sizeof(value));
if (value >= lower)
return value % upper;
}
}

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -12,7 +14,8 @@
#ifndef RANDOM_H
#define RANDOM_H
void random_buf(void *, size_t);
void
random_buf(void *, size_t);
uintmax_t random_uniform(uintmax_t);
#endif

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -46,8 +48,8 @@ refcount_acquire(struct refcount *r) PRODUCES(*r)
static inline bool
refcount_release(struct refcount *r) CONSUMES(*r)
{
int old = (int)atomic_fetch_sub_explicit(&r->count, 1,
memory_order_release);
int old =
(int)atomic_fetch_sub_explicit(&r->count, 1, memory_order_release);
bh_assert(old != 0 && "Reference count becoming negative");
return old == 1;
}

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -12,6 +14,8 @@
#ifndef RIGHTS_H
#define RIGHTS_H
/* clang-format off */
#define RIGHTS_ALL \
(__WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_READ | \
__WASI_RIGHT_FD_SEEK | __WASI_RIGHT_FD_FDSTAT_SET_FLAGS | \
@ -80,4 +84,6 @@
__WASI_RIGHT_POLL_FD_READWRITE)
#define RIGHTS_TTY_INHERITING 0
/* clang-format on */
#endif

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -12,6 +14,7 @@
#ifndef SIGNALS_H
#define SIGNALS_H
void signals_init(void);
void
signals_init(void);
#endif

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -14,7 +16,8 @@
#include <stdlib.h>
#if defined(__FreeBSD__) || defined(__APPLE__) || (defined(ANDROID) && __ANDROID_API__ < 28)
#if defined(__FreeBSD__) || defined(__APPLE__) \
|| (defined(ANDROID) && __ANDROID_API__ < 28)
#define CONFIG_HAS_ARC4RANDOM_BUF 1
#else
#define CONFIG_HAS_ARC4RANDOM_BUF 0
@ -22,10 +25,9 @@
// On Linux, prefer to use getrandom, though it isn't available in
// GLIBC before 2.25.
#if defined(__linux__) && \
(!defined(__GLIBC__) || \
__GLIBC__ > 2 || \
(__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))
#if defined(__linux__) \
&& (!defined(__GLIBC__) || __GLIBC__ > 2 \
|| (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))
#define CONFIG_HAS_GETRANDOM 1
#else
#define CONFIG_HAS_GETRANDOM 0

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -27,7 +29,8 @@ bh_strndup(const char *s, size_t n)
}
char *
str_nullterminate(const char *s, size_t len) {
str_nullterminate(const char *s, size_t len)
{
/* Copy string */
char *ret = bh_strndup(s, len);
@ -40,5 +43,5 @@ str_nullterminate(const char *s, size_t len) {
errno = EILSEQ;
return NULL;
}
return ret;
return ret;
}

View File

@ -1,5 +1,7 @@
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license information.
// Part of the Wasmtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See
// https://github.com/bytecodealliance/wasmtime/blob/main/LICENSE for license
// information.
//
// Significant parts of this file are derived from cloudabi-utils. See
// https://github.com/bytecodealliance/wasmtime/blob/main/lib/wasi/sandboxed-system-primitives/src/LICENSE
@ -14,6 +16,7 @@
#include "ssp_config.h"
char *str_nullterminate(const char *, size_t);
char *
str_nullterminate(const char *, size_t);
#endif