1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

src: conditionally exclude cfmakeraw/termios.h on WIN32

The GNULIB termios module ensures termios.h exists (but
is none the less empty) when building for Windows. We
already exclude usage of the functions that would exist
in a real termios.h, so having an empty termios.h is
not especially useful.

It is simpler to just put all use of termios.h related
functions behind a "#ifndef WIN32" conditional.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-01-09 13:18:50 +00:00
parent fa434739a0
commit 7c828af858
7 changed files with 12 additions and 24 deletions

View File

@ -353,7 +353,6 @@ AC_CHECK_SIZEOF([long])
dnl Availability of various common functions (non-fatal if missing), dnl Availability of various common functions (non-fatal if missing),
dnl and various less common threadsafe functions dnl and various less common threadsafe functions
AC_CHECK_FUNCS_ONCE([\ AC_CHECK_FUNCS_ONCE([\
cfmakeraw \
fallocate \ fallocate \
geteuid \ geteuid \
getgid \ getgid \

View File

@ -31,7 +31,9 @@
# include <sys/un.h> # include <sys/un.h>
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>
#ifndef WIN32
# include <termios.h> # include <termios.h>
#endif
#include "virfdstream.h" #include "virfdstream.h"
#include "virerror.h" #include "virerror.h"
@ -1361,7 +1363,7 @@ int virFDStreamCreateFile(virStreamPtr st,
false, false); false, false);
} }
#ifdef HAVE_CFMAKERAW #ifndef WIN32
int virFDStreamOpenPTY(virStreamPtr st, int virFDStreamOpenPTY(virStreamPtr st,
const char *path, const char *path,
unsigned long long offset, unsigned long long offset,
@ -1401,7 +1403,7 @@ int virFDStreamOpenPTY(virStreamPtr st,
virFDStreamClose(st); virFDStreamClose(st);
return -1; return -1;
} }
#else /* !HAVE_CFMAKERAW */ #else /* WIN32 */
int virFDStreamOpenPTY(virStreamPtr st, int virFDStreamOpenPTY(virStreamPtr st,
const char *path, const char *path,
unsigned long long offset, unsigned long long offset,
@ -1413,7 +1415,7 @@ int virFDStreamOpenPTY(virStreamPtr st,
oflags | O_CREAT, 0, oflags | O_CREAT, 0,
false, false); false, false);
} }
#endif /* !HAVE_CFMAKERAW */ #endif /* WIN32 */
int virFDStreamOpenBlockDevice(virStreamPtr st, int virFDStreamOpenBlockDevice(virStreamPtr st,
const char *path, const char *path,

View File

@ -27,7 +27,9 @@
#include <passfd.h> #include <passfd.h>
#include <fcntl.h> #include <fcntl.h>
#ifndef WIN32
# include <termios.h> # include <termios.h>
#endif /* !WIN32 */
#ifdef HAVE_PTY_H #ifdef HAVE_PTY_H
/* Linux openpty */ /* Linux openpty */
# include <pty.h> # include <pty.h>

View File

@ -35,7 +35,6 @@
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#include <termios.h>
#if WITH_DEVMAPPER #if WITH_DEVMAPPER
# include <libdevmapper.h> # include <libdevmapper.h>

View File

@ -23,7 +23,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <termios.h>
#include "internal.h" #include "internal.h"
#include "virerror.h" #include "virerror.h"

View File

@ -1928,21 +1928,6 @@ vshTTYRestore(vshControl *ctl G_GNUC_UNUSED)
} }
#if !defined(WIN32) && !defined(HAVE_CFMAKERAW)
/* provide fallback in case cfmakeraw isn't available */
static void
cfmakeraw(struct termios *attr)
{
attr->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON);
attr->c_oflag &= ~OPOST;
attr->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
attr->c_cflag &= ~(CSIZE | PARENB);
attr->c_cflag |= CS8;
}
#endif /* !WIN32 && !HAVE_CFMAKERAW */
int int
vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED, vshTTYMakeRaw(vshControl *ctl G_GNUC_UNUSED,
bool report_errors G_GNUC_UNUSED) bool report_errors G_GNUC_UNUSED)

View File

@ -23,7 +23,9 @@
#include <stdarg.h> #include <stdarg.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef WIN32
# include <termios.h> # include <termios.h>
#endif
#include "internal.h" #include "internal.h"
#include "virerror.h" #include "virerror.h"