summaryrefslogtreecommitdiff
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-10-12 09:16:31 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-10-12 09:19:44 -0700
commiteb17d6f575de81dbbc113e474d28db0396c12714 (patch)
tree3bb16bd4385dc247018e09b1048de46e7535dd76 /src/process.c
parent40c426a150c5d885d8a2509358831c9bb1e1c6ad (diff)
downloademacs-eb17d6f575de81dbbc113e474d28db0396c12714.tar.gz
Port --enable-gcc-warnings to GCC 6.2.1
Backport from master. * src/conf_post.h (GNUC_PREREQ): New macro. * src/keyboard.c: Use it to work around GCC bug 54561. * src/process.c (would_block): New function. (server_accept_connection, wait_reading_process_output, send_process): Use it.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/process.c b/src/process.c
index 7ab92b0102c..e6ea2fbe8f7 100644
--- a/src/process.c
+++ b/src/process.c
@@ -151,6 +151,18 @@ bool inhibit_sentinels;
# define SOCK_CLOEXEC 0
#endif
+/* True if ERRNUM represents an error where the system call would
+ block if a blocking variant were used. */
+static bool
+would_block (int errnum)
+{
+#ifdef EWOULDBLOCK
+ if (EWOULDBLOCK != EAGAIN && errnum == EWOULDBLOCK)
+ return true;
+#endif
+ return errnum == EAGAIN;
+}
+
#ifndef HAVE_ACCEPT4
/* Emulate GNU/Linux accept4 and socket well enough for this module. */
@@ -4262,15 +4274,7 @@ server_accept_connection (Lisp_Object server, int channel)
if (s < 0)
{
int code = errno;
-
- if (code == EAGAIN)
- return;
-#ifdef EWOULDBLOCK
- if (code == EWOULDBLOCK)
- return;
-#endif
-
- if (!NILP (ps->log))
+ if (!would_block (code) && !NILP (ps->log))
call3 (ps->log, server, Qnil,
concat3 (build_string ("accept failed with code"),
Fnumber_to_string (make_number (code)),
@@ -4687,12 +4691,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
int nread = read_process_output (proc, wait_proc->infd);
if (nread < 0)
{
- if (errno == EIO || errno == EAGAIN)
- break;
-#ifdef EWOULDBLOCK
- if (errno == EWOULDBLOCK)
- break;
-#endif
+ if (errno == EIO || would_block (errno))
+ break;
}
else
{
@@ -5073,11 +5073,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
if (do_display)
redisplay_preserve_echo_area (12);
}
-#ifdef EWOULDBLOCK
- else if (nread == -1 && errno == EWOULDBLOCK)
- ;
-#endif
- else if (nread == -1 && errno == EAGAIN)
+ else if (nread == -1 && would_block (errno))
;
#ifdef WINDOWSNT
/* FIXME: Is this special case still needed? */
@@ -5801,11 +5797,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
if (rv < 0)
{
- if (errno == EAGAIN
-#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
-#endif
- )
+ if (would_block (errno))
/* Buffer is full. Wait, accepting input;
that may allow the program
to finish doing output and read more. */