From c5de1304d041aecc00391dffb5f6807fed10e737 Mon Sep 17 00:00:00 2001 From: Grzegorz Placzek Date: Mon, 11 Sep 2023 14:32:32 +0200 Subject: [PATCH] [#48828] Move constants declarations to .c source --- c_lib/wasi_ext_lib.c | 11 +++++++++++ c_lib/wasi_ext_lib.h | 16 ++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/c_lib/wasi_ext_lib.c b/c_lib/wasi_ext_lib.c index 416bef2..392ff46 100644 --- a/c_lib/wasi_ext_lib.c +++ b/c_lib/wasi_ext_lib.c @@ -19,6 +19,17 @@ #define SYSCALL_LENGTH 256 #define SYSCALL_ARGS_LENGTH 2048 +const __wasi_fdflags_t WASI_EXT_FDFLAG_CTRL_BIT = 0x0020; +const __wasi_fdflags_t WASI_EXT_FDFLAG_MASK = 0xffc0; +const __wasi_fdflags_t WASI_EXT_FDFLAG_CLOEXEC = 0x0040; + +const unsigned int TIOCGWINSZ = _IOR(1, 0, 8); +const unsigned int TIOCSRAW = _IOW(1, 1, 4); +const unsigned int TIOCSECHO = _IOW(1, 2, 4); + +const int STDIN = 0; +const int STDOUT = 1; + int __syscall(const char *command, char *args, uint8_t *output_buf, size_t output_buf_len) { char *ptr; diff --git a/c_lib/wasi_ext_lib.h b/c_lib/wasi_ext_lib.h index 5bf054f..b36b8e7 100644 --- a/c_lib/wasi_ext_lib.h +++ b/c_lib/wasi_ext_lib.h @@ -40,20 +40,20 @@ #include // Ioctl magic numbers -const unsigned int TIOCGWINSZ = _IOR(1, 0, 8); -const unsigned int TIOCSRAW = _IOW(1, 1, 4); -const unsigned int TIOCSECHO = _IOW(1, 2, 4); +extern const unsigned int TIOCGWINSZ; +extern const unsigned int TIOCSRAW; +extern const unsigned int TIOCSECHO; // Fnctl commands enum FcntlCommand { F_MVFD, F_GETFD, F_SETFD }; // Extended fs_fdflags -const __wasi_fdflags_t WASI_EXT_FDFLAG_CTRL_BIT = 0x0020; -const __wasi_fdflags_t WASI_EXT_FDFLAG_MASK = 0xffc0; -const __wasi_fdflags_t WASI_EXT_FDFLAG_CLOEXEC = 0x0040; +extern const __wasi_fdflags_t WASI_EXT_FDFLAG_CTRL_BIT; +extern const __wasi_fdflags_t WASI_EXT_FDFLAG_MASK; +extern const __wasi_fdflags_t WASI_EXT_FDFLAG_CLOEXEC; -const int STDIN = 0; -const int STDOUT = 1; +extern const int STDIN; +extern const int STDOUT; enum RedirectType { READ,