aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-10-12 09:16:31 -0700
committerPaul Eggert2016-10-12 09:19:44 -0700
commiteb17d6f575de81dbbc113e474d28db0396c12714 (patch)
tree3bb16bd4385dc247018e09b1048de46e7535dd76 /src
parent40c426a150c5d885d8a2509358831c9bb1e1c6ad (diff)
downloademacs-eb17d6f575de81dbbc113e474d28db0396c12714.tar.gz
emacs-eb17d6f575de81dbbc113e474d28db0396c12714.zip
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')
-rw-r--r--src/conf_post.h11
-rw-r--r--src/keyboard.c5
-rw-r--r--src/process.c42
3 files changed, 33 insertions, 25 deletions
diff --git a/src/conf_post.h b/src/conf_post.h
index 209f60792cf..f83965bf8b1 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -34,6 +34,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34 34
35#include <stdbool.h> 35#include <stdbool.h>
36 36
37/* GNUC_PREREQ (V, W, X) is true if this is GNU C version V.W.X or later.
38 It can be used in a preprocessor expression. */
39#ifndef __GNUC_MINOR__
40# define GNUC_PREREQ(v, w, x) false
41#elif ! defined __GNUC_PATCHLEVEL__
42# define GNUC_PREREQ(v, w, x) ((v) < __GNUC__ + ((w) <= __GNUC_MINOR__))
43#else
44# define GNUC_PREREQ(v, w, x) \
45 ((v) < __GNUC__ + ((w) <= __GNUC_MINOR__ + ((x) <= __GNUC_PATCHLEVEL__)))
46#endif
47
37/* The type of bool bitfields. Needed to compile Objective-C with 48/* The type of bool bitfields. Needed to compile Objective-C with
38 standard GCC. It was also needed to port to pre-C99 compilers, 49 standard GCC. It was also needed to port to pre-C99 compilers,
39 although we don't care about that any more. */ 50 although we don't care about that any more. */
diff --git a/src/keyboard.c b/src/keyboard.c
index 918424630f3..f24d86e8833 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -70,6 +70,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
70#include TERM_HEADER 70#include TERM_HEADER
71#endif /* HAVE_WINDOW_SYSTEM */ 71#endif /* HAVE_WINDOW_SYSTEM */
72 72
73/* Work around GCC bug 54561. */
74#if GNUC_PREREQ (4, 3, 0)
75# pragma GCC diagnostic ignored "-Wclobbered"
76#endif
77
73/* Variables for blockinput.h: */ 78/* Variables for blockinput.h: */
74 79
75/* Positive if interrupt input is blocked right now. */ 80/* Positive if interrupt input is blocked right now. */
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;
151# define SOCK_CLOEXEC 0 151# define SOCK_CLOEXEC 0
152#endif 152#endif
153 153
154/* True if ERRNUM represents an error where the system call would
155 block if a blocking variant were used. */
156static bool
157would_block (int errnum)
158{
159#ifdef EWOULDBLOCK
160 if (EWOULDBLOCK != EAGAIN && errnum == EWOULDBLOCK)
161 return true;
162#endif
163 return errnum == EAGAIN;
164}
165
154#ifndef HAVE_ACCEPT4 166#ifndef HAVE_ACCEPT4
155 167
156/* Emulate GNU/Linux accept4 and socket well enough for this module. */ 168/* Emulate GNU/Linux accept4 and socket well enough for this module. */
@@ -4262,15 +4274,7 @@ server_accept_connection (Lisp_Object server, int channel)
4262 if (s < 0) 4274 if (s < 0)
4263 { 4275 {
4264 int code = errno; 4276 int code = errno;
4265 4277 if (!would_block (code) && !NILP (ps->log))
4266 if (code == EAGAIN)
4267 return;
4268#ifdef EWOULDBLOCK
4269 if (code == EWOULDBLOCK)
4270 return;
4271#endif
4272
4273 if (!NILP (ps->log))
4274 call3 (ps->log, server, Qnil, 4278 call3 (ps->log, server, Qnil,
4275 concat3 (build_string ("accept failed with code"), 4279 concat3 (build_string ("accept failed with code"),
4276 Fnumber_to_string (make_number (code)), 4280 Fnumber_to_string (make_number (code)),
@@ -4687,12 +4691,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4687 int nread = read_process_output (proc, wait_proc->infd); 4691 int nread = read_process_output (proc, wait_proc->infd);
4688 if (nread < 0) 4692 if (nread < 0)
4689 { 4693 {
4690 if (errno == EIO || errno == EAGAIN) 4694 if (errno == EIO || would_block (errno))
4691 break; 4695 break;
4692#ifdef EWOULDBLOCK
4693 if (errno == EWOULDBLOCK)
4694 break;
4695#endif
4696 } 4696 }
4697 else 4697 else
4698 { 4698 {
@@ -5073,11 +5073,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5073 if (do_display) 5073 if (do_display)
5074 redisplay_preserve_echo_area (12); 5074 redisplay_preserve_echo_area (12);
5075 } 5075 }
5076#ifdef EWOULDBLOCK 5076 else if (nread == -1 && would_block (errno))
5077 else if (nread == -1 && errno == EWOULDBLOCK)
5078 ;
5079#endif
5080 else if (nread == -1 && errno == EAGAIN)
5081 ; 5077 ;
5082#ifdef WINDOWSNT 5078#ifdef WINDOWSNT
5083 /* FIXME: Is this special case still needed? */ 5079 /* FIXME: Is this special case still needed? */
@@ -5801,11 +5797,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5801 5797
5802 if (rv < 0) 5798 if (rv < 0)
5803 { 5799 {
5804 if (errno == EAGAIN 5800 if (would_block (errno))
5805#ifdef EWOULDBLOCK
5806 || errno == EWOULDBLOCK
5807#endif
5808 )
5809 /* Buffer is full. Wait, accepting input; 5801 /* Buffer is full. Wait, accepting input;
5810 that may allow the program 5802 that may allow the program
5811 to finish doing output and read more. */ 5803 to finish doing output and read more. */