From 861f0d2ec80c271ccf0856161579dfaaa40944d0 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 9 May 2019 10:32:40 -0700 Subject: [PATCH] Define O_TTY_INIT. Define it to 0, as several popular operating systems ignore this flag. This fixes a part of src/api/fcntl.c. --- expected/wasm32-wasi/predefined-macros.txt | 1 + libc-bottom-half/headers/public/__header_fcntl.h | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasi/predefined-macros.txt index ef6de5c..efe4195 100644 --- a/expected/wasm32-wasi/predefined-macros.txt +++ b/expected/wasm32-wasi/predefined-macros.txt @@ -1628,6 +1628,7 @@ #define O_SEARCH (0x08000000) #define O_SYNC __WASI_FDFLAG_SYNC #define O_TRUNC (__WASI_O_TRUNC << 12) +#define O_TTY_INIT (0) #define O_WRONLY (0x10000000) #define PACKETSZ NS_PACKETSZ #define PACKET_ADD_MEMBERSHIP 1 diff --git a/libc-bottom-half/headers/public/__header_fcntl.h b/libc-bottom-half/headers/public/__header_fcntl.h index af720ea..c5d5a0c 100644 --- a/libc-bottom-half/headers/public/__header_fcntl.h +++ b/libc-bottom-half/headers/public/__header_fcntl.h @@ -20,7 +20,17 @@ #define O_SEARCH (0x08000000) #define O_WRONLY (0x10000000) +/* + * O_CLOEXEC is defined to be zero, as WASI has no exec-style functions. + */ #define O_CLOEXEC (0) + +/* + * O_TTY_INIT is defined to be zero, meaning that WASI implementations are + * expected to always initialize a terminal the first time it's opened. + */ +#define O_TTY_INIT (0) + #define O_NOCTTY (0) #define O_RDWR (O_RDONLY | O_WRONLY)