From: Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] sim: dv-sockser: use gnulib to set nonblocking mode
Date: Sat, 4 Sep 2021 03:49:34 -0400 [thread overview]
Message-ID: <20210904074934.21309-2-vapier@gentoo.org> (raw)
In-Reply-To: <20210904074934.21309-1-vapier@gentoo.org>
---
sim/common/dv-sockser.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index d47d428d535d..ad4fc229a923 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -42,6 +42,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/select.h>
#include <sys/socket.h>
+#include "nonblocking.h"
+
#include "sim-assert.h"
#include "sim-options.h"
@@ -51,7 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
typedef int socklen_t;
#endif
-/* Get definitions for both O_NONBLOCK and O_NDELAY. */
+/* Get definitions for O_NDELAY. */
#ifndef O_NDELAY
#ifdef FNDELAY
@@ -60,14 +62,6 @@ typedef int socklen_t;
#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) */
\f
/* Compromise between eating cpu and properly busy-waiting.
@@ -279,13 +273,15 @@ connected_p (SIM_DESC sd)
flags = fcntl (sockser_fd, F_GETFL);
flags |= O_NONBLOCK | O_NDELAY;
if (fcntl (sockser_fd, F_SETFL, flags) == -1)
+#else
+ if (set_nonblocking_flag (sockser_fd, false))
+#endif
{
sim_io_eprintf (sd, "unable to set nonblocking i/o");
close (sockser_fd);
sockser_fd = -1;
return 0;
}
-#endif
return 1;
}
--
2.31.1
prev parent reply other threads:[~2021-09-04 2:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-04 7:49 [PATCH 1/2] gnulib: import nonblocking module Mike Frysinger via Gdb-patches
2021-09-04 7:49 ` Mike Frysinger via Gdb-patches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210904074934.21309-2-vapier@gentoo.org \
--to=gdb-patches@sourceware.org \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox