[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master f5090b9 3/4: Use tcdrain, not fdatasync, to drain t
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master f5090b9 3/4: Use tcdrain, not fdatasync, to drain ttys |
Date: |
Mon, 3 Dec 2018 02:55:07 -0500 (EST) |
branch: master
commit f5090b91299cbd36901bef7b94aeef618b1bc6d8
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Use tcdrain, not fdatasync, to drain ttys
fdatasync is for storage devices, not ttys.
* admin/merge-gnulib (GNULIB_MODULES): Remove fdatasync.
* lib/fdatasync.c, m4/fdatasync.m4: Remove.
* lib-src/Makefile.in (LIB_FDATASYNC):
* src/Makefile.in (LIB_FDATASYNC):
Remove. All uses removed.
* lib-src/emacsclient.c [!DOS_NT]:
Include <termios.h>, for tcdrain.
* lib-src/emacsclient.c (flush_stdout):
* src/sysdep.c (reset_sys_modes): On ttys, use tcdrain instead
of fdatasync (except don’t use either function if DOS_NT).
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
---
admin/merge-gnulib | 2 +-
lib-src/Makefile.in | 6 ++----
lib-src/emacsclient.c | 8 +++++++-
lib/fdatasync.c | 27 ---------------------------
lib/gnulib.mk.in | 13 -------------
m4/fdatasync.m4 | 32 --------------------------------
m4/gnulib-comp.m4 | 8 --------
src/Makefile.in | 3 +--
src/sysdep.c | 8 ++++----
9 files changed, 15 insertions(+), 92 deletions(-)
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 84dcb0b..ab0d34e 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -32,7 +32,7 @@ GNULIB_MODULES='
crypto/md5-buffer crypto/sha1-buffer crypto/sha256-buffer
crypto/sha512-buffer
d-type diffseq dosname dtoastr dtotimespec dup2
environ execinfo explicit_bzero faccessat
- fcntl fcntl-h fdatasync fdopendir
+ fcntl fcntl-h fdopendir
filemode filevercmp flexmember fpieee fstatat fsusage fsync
getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile lstat
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index ecb9208..0015193 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -204,8 +204,6 @@ address@hidden@
address@hidden@
## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
-## empty or -lrt or -lposix4 if HAVE_FDATASYNC
-LIB_FDATASYNC = @LIB_FDATASYNC@
## empty or -lwsock2 for MinGW
address@hidden@
@@ -396,12 +394,12 @@ pop.o: ${srcdir}/pop.c ${srcdir}/pop.h
${srcdir}/../lib/min-max.h $(config_h)
emacsclient${EXEEXT}: ${srcdir}/emacsclient.c $(NTLIB) $(config_h)
$(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< \
- -DVERSION="\"${version}\"" $(NTLIB) $(LOADLIBES) $(LIB_FDATASYNC) \
+ -DVERSION="\"${version}\"" $(NTLIB) $(LOADLIBES) \
$(LIB_WSOCK32) $(LIBS_ECLIENT) -o $@
emacsclientw${EXEEXT}: ${srcdir}/emacsclient.c $(NTLIB) $(CLIENTRES)
$(config_h)
$(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $(CLIENTRES) -mwindows $< \
- -DVERSION="\"${version}\"" $(LOADLIBES) $(LIB_FDATASYNC) \
+ -DVERSION="\"${version}\"" $(LOADLIBES) \
$(LIB_WSOCK32) $(LIBS_ECLIENT) -o $@
NTINC = ${srcdir}/../nt/inc
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index df44bc4..1c62c09 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -65,6 +65,10 @@ char *w32_getenv (const char *);
#endif /* !WINDOWSNT */
+#ifndef DOS_NT
+# include <termios.h>
+#endif
+
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
@@ -1722,8 +1726,10 @@ static void
flush_stdout (HSOCKET emacs_socket)
{
fflush (stdout);
- while (fdatasync (STDOUT_FILENO) != 0 && errno == EINTR)
+#ifndef DOS_NT
+ while (tcdrain (STDOUT_FILENO) != 0 && errno == EINTR)
act_on_signals (emacs_socket);
+#endif
}
int
diff --git a/lib/fdatasync.c b/lib/fdatasync.c
deleted file mode 100644
index c474e3d..0000000
--- a/lib/fdatasync.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Emulate fdatasync on platforms that lack it.
-
- Copyright (C) 2011-2018 Free Software Foundation, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-#include <unistd.h>
-
-int
-fdatasync (int fd)
-{
- /* This does more work than strictly necessary, but is the best we
- can do portably. */
- return fsync (fd);
-}
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index eca073d..aa32dcc 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -92,7 +92,6 @@
# faccessat \
# fcntl \
# fcntl-h \
-# fdatasync \
# fdopendir \
# filemode \
# filevercmp \
@@ -731,7 +730,6 @@ LIB_ACL = @LIB_ACL@
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
LIB_EACCESS = @LIB_EACCESS@
LIB_EXECINFO = @LIB_EXECINFO@
-LIB_FDATASYNC = @LIB_FDATASYNC@
LIB_MATH = @LIB_MATH@
LIB_PTHREAD = @LIB_PTHREAD@
LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
@@ -1586,17 +1584,6 @@ EXTRA_DIST += fcntl.in.h
endif
## end gnulib module fcntl-h
-## begin gnulib module fdatasync
-ifeq (,$(OMIT_GNULIB_MODULE_fdatasync))
-
-
-EXTRA_DIST += fdatasync.c
-
-EXTRA_libgnu_a_SOURCES += fdatasync.c
-
-endif
-## end gnulib module fdatasync
-
## begin gnulib module fdopendir
ifeq (,$(OMIT_GNULIB_MODULE_fdopendir))
diff --git a/m4/fdatasync.m4 b/m4/fdatasync.m4
deleted file mode 100644
index fd8e432..0000000
--- a/m4/fdatasync.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-# fdatasync.m4 serial 4
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_FDATASYNC],
-[
- AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-
- dnl Using AC_CHECK_FUNCS_ONCE would break our subsequent AC_SEARCH_LIBS
- AC_CHECK_DECLS_ONCE([fdatasync])
- LIB_FDATASYNC=
- AC_SUBST([LIB_FDATASYNC])
-
- if test $ac_cv_have_decl_fdatasync = no; then
- HAVE_DECL_FDATASYNC=0
- dnl Mac OS X 10.7 has fdatasync but does not declare it.
- AC_CHECK_FUNCS([fdatasync])
- if test $ac_cv_func_fdatasync = no; then
- HAVE_FDATASYNC=0
- fi
- else
- dnl Solaris <= 2.6 has fdatasync() in libposix4.
- dnl Solaris 7..10 has it in librt.
- gl_saved_libs=$LIBS
- AC_SEARCH_LIBS([fdatasync], [rt posix4],
- [test "$ac_cv_search_fdatasync" = "none required" ||
- LIB_FDATASYNC=$ac_cv_search_fdatasync])
- LIBS=$gl_saved_libs
- fi
-])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index a4dddba..d31dd5d 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -81,7 +81,6 @@ AC_DEFUN([gl_EARLY],
# Code from module faccessat:
# Code from module fcntl:
# Code from module fcntl-h:
- # Code from module fdatasync:
# Code from module fdopendir:
# Code from module filemode:
# Code from module filevercmp:
@@ -241,11 +240,6 @@ AC_DEFUN([gl_INIT],
fi
gl_FCNTL_MODULE_INDICATOR([fcntl])
gl_FCNTL_H
- gl_FUNC_FDATASYNC
- if test $HAVE_FDATASYNC = 0; then
- AC_LIBOBJ([fdatasync])
- fi
- gl_UNISTD_MODULE_INDICATOR([fdatasync])
gl_FUNC_FDOPENDIR
if test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1; then
AC_LIBOBJ([fdopendir])
@@ -880,7 +874,6 @@ AC_DEFUN([gl_FILE_LIST], [
lib/faccessat.c
lib/fcntl.c
lib/fcntl.in.h
- lib/fdatasync.c
lib/fdopendir.c
lib/filemode.c
lib/filemode.h
@@ -1028,7 +1021,6 @@ AC_DEFUN([gl_FILE_LIST], [
m4/fcntl-o.m4
m4/fcntl.m4
m4/fcntl_h.m4
- m4/fdatasync.m4
m4/fdopendir.m4
m4/filemode.m4
m4/flexmember.m4
diff --git a/src/Makefile.in b/src/Makefile.in
index 2dba102..6b2e54a 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -141,7 +141,6 @@ M17N_FLT_LIBS = @M17N_FLT_LIBS@
address@hidden@
address@hidden@
address@hidden@
address@hidden@
address@hidden@
DBUS_CFLAGS = @DBUS_CFLAGS@
@@ -496,7 +495,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE)
$(LIBIMAGE) \
$(LIBX_OTHER) $(LIBSOUND) \
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(LIB_CLOCK_GETTIME) \
$(WEBKIT_LIBS) \
- $(LIB_EACCESS) $(LIB_FDATASYNC) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
+ $(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
$(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \
$(XDBE_LIBS) \
$(LIBXML2_LIBS) $(LIBGPM) $(LIBS_SYSTEM) $(CAIRO_LIBS) \
diff --git a/src/sysdep.c b/src/sysdep.c
index ddcb594..b054839 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1519,19 +1519,19 @@ reset_sys_modes (struct tty_display_info *tty_out)
if (tty_out->terminal->reset_terminal_modes_hook)
tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal);
+#ifndef DOS_NT
/* Avoid possible loss of output when changing terminal modes. */
- while (fdatasync (fileno (tty_out->output)) != 0 && errno == EINTR)
+ while (tcdrain (fileno (tty_out->output)) != 0 && errno == EINTR)
continue;
-#ifndef DOS_NT
-#ifdef F_SETOWN
+# ifdef F_SETOWN
if (interrupt_input)
{
reset_sigio (fileno (tty_out->input));
fcntl (fileno (tty_out->input), F_SETOWN,
old_fcntl_owner[fileno (tty_out->input)]);
}
-#endif /* F_SETOWN */
+# endif /* F_SETOWN */
fcntl (fileno (tty_out->input), F_SETFL,
fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NONBLOCK);
#endif