From ee73abf25e8431f4ea8c95629622cf23515c1d07 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 9 Sep 2021 01:44:24 -0400 Subject: [PATCH] sim: drop old O_NDELAY & FNBLOCK support We use these older names inconsistently in the sim codebase, and time has moved on long ago, so drop support for these non-standard names. POSIX provides O_NONBLOCK for us, so use it everywhere. --- sim/common/dv-sockser.c | 22 ++-------------------- sim/common/sim-io.c | 4 ++-- sim/ppc/main.c | 6 +++--- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c index 7950943d366..477e8f681af 100644 --- a/sim/common/dv-sockser.c +++ b/sim/common/dv-sockser.c @@ -49,24 +49,6 @@ along with this program. If not, see . */ #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif - -/* Get definitions for both O_NONBLOCK and O_NDELAY. */ - -#ifndef O_NDELAY -#ifdef FNDELAY -#define O_NDELAY FNDELAY -#else /* ! defined (FNDELAY) */ -#define O_NDELAY 0 -#endif /* ! defined (FNDELAY) */ -#endif /* ! defined (O_NDELAY) */ - -#ifndef O_NONBLOCK -#ifdef FNBLOCK -#define O_NONBLOCK FNBLOCK -#else /* ! defined (FNBLOCK) */ -#define O_NONBLOCK 0 -#endif /* ! defined (FNBLOCK) */ -#endif /* ! defined (O_NONBLOCK) */ /* Compromise between eating cpu and properly busy-waiting. @@ -274,9 +256,9 @@ connected_p (SIM_DESC sd) return 0; /* Set non-blocking i/o. */ -#ifdef F_GETFL +#if defined(F_GETFL) && defined(O_NONBLOCK) flags = fcntl (sockser_fd, F_GETFL); - flags |= O_NONBLOCK | O_NDELAY; + flags |= O_NONBLOCK; if (fcntl (sockser_fd, F_SETFL, flags) == -1) { sim_io_eprintf (sd, "unable to set nonblocking i/o"); diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c index d1c2be6bfe3..a5a7ff17b06 100644 --- a/sim/common/sim-io.c +++ b/sim/common/sim-io.c @@ -350,7 +350,7 @@ sim_io_poll_read (SIM_DESC sd, char *buf, int sizeof_buf) { -#if defined(O_NDELAY) && defined(F_GETFL) && defined(F_SETFL) +#if defined(O_NONBLOCK) && defined(F_GETFL) && defined(F_SETFL) int fd = STATE_CALLBACK (sd)->fdmap[sim_io_fd]; int flags; int status; @@ -365,7 +365,7 @@ sim_io_poll_read (SIM_DESC sd, return 0; } /* temp, disable blocking IO */ - status = fcntl (fd, F_SETFL, flags | O_NDELAY); + status = fcntl (fd, F_SETFL, flags | O_NONBLOCK); if (status == -1) { perror ("sim_io_read_stdin"); diff --git a/sim/ppc/main.c b/sim/ppc/main.c index 2d4d7e40275..3b82c88db06 100644 --- a/sim/ppc/main.c +++ b/sim/ppc/main.c @@ -40,7 +40,7 @@ #include #include -#if !defined(O_NDELAY) || !defined(F_GETFL) || !defined(F_SETFL) +#if !defined(O_NONBLOCK) || !defined(F_GETFL) || !defined(F_SETFL) #undef WITH_STDIO #define WITH_STDIO DO_USE_STDIO #endif @@ -150,7 +150,7 @@ sim_io_read_stdin(char *buf, return sim_io_eof; break; case DONT_USE_STDIO: -#if defined(O_NDELAY) && defined(F_GETFL) && defined(F_SETFL) +#if defined(O_NONBLOCK) && defined(F_GETFL) && defined(F_SETFL) { /* check for input */ int flags; @@ -164,7 +164,7 @@ sim_io_read_stdin(char *buf, return sim_io_eof; } /* temp, disable blocking IO */ - status = fcntl(0, F_SETFL, flags | O_NDELAY); + status = fcntl(0, F_SETFL, flags | O_NONBLOCK); if (status == -1) { perror("sim_io_read_stdin"); return sim_io_eof; -- 2.30.2