From f21961cc1427faad65abf36df217a8c888cae7fa Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 5 Sep 2013 00:10:19 +0200 Subject: [PATCH] ntdll: Add a configure check for the tcdrain function. Also remove the tcgetattr check that is no longer used. --- configure | 2 +- configure.ac | 2 +- dlls/ntdll/file.c | 9 +-------- dlls/ntdll/ntdll_misc.h | 1 + dlls/ntdll/serial.c | 26 ++++++++++++++++++++++++++ include/config.h.in | 4 ++-- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 56c983f4d51..6b2c2c833a9 100755 --- a/configure +++ b/configure @@ -13436,7 +13436,7 @@ for ac_func in \ strtoll \ strtoull \ symlink \ - tcgetattr \ + tcdrain \ thr_kill2 \ timegm \ usleep \ diff --git a/configure.ac b/configure.ac index 3a0007cc524..7c1cb1c30c1 100644 --- a/configure.ac +++ b/configure.ac @@ -2063,7 +2063,7 @@ AC_CHECK_FUNCS(\ strtoll \ strtoull \ symlink \ - tcgetattr \ + tcdrain \ thr_kill2 \ timegm \ usleep \ diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 83e286e26a1..9420df5093f 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -2777,14 +2777,7 @@ NTSTATUS WINAPI NtFlushBuffersFile( HANDLE hFile, IO_STATUS_BLOCK* IoStatusBlock if (!ret && type == FD_TYPE_SERIAL) { - while (tcdrain( fd ) == -1) - { - if (errno != EINTR) - { - ret = FILE_GetNtStatus(); - break; - } - } + ret = COMM_FlushBuffersFile( fd ); } else { diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 3d9264d9f0c..a13c55b8d9f 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -142,6 +142,7 @@ extern NTSTATUS TAPE_DeviceIoControl(HANDLE hDevice, ULONG IoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize) DECLSPEC_HIDDEN; +extern NTSTATUS COMM_FlushBuffersFile( int fd ) DECLSPEC_HIDDEN; /* file I/O */ struct stat; diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c index b4f9aa9ee26..07ba6338fcb 100644 --- a/dlls/ntdll/serial.c +++ b/dlls/ntdll/serial.c @@ -1342,3 +1342,29 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice, lpOutBuffer, nOutBufferSize); return status; } + +NTSTATUS COMM_FlushBuffersFile( int fd ) +{ +#ifdef HAVE_TCDRAIN + while (tcdrain( fd ) == -1) + { + if (errno != EINTR) return FILE_GetNtStatus(); + } + return STATUS_SUCCESS; +#elif defined(TIOCDRAIN) + while (ioctl( fd, TIOCDRAIN ) == -1) + { + if (errno != EINTR) return FILE_GetNtStatus(); + } + return STATUS_SUCCESS; +#elif defined(TCSBRK) + while (ioctl( fd, TCSBRK, 1 ) == -1) + { + if (errno != EINTR) return FILE_GetNtStatus(); + } + return STATUS_SUCCESS; +#else + ERR( "not supported\n" ); + return STATUS_NOT_IMPLEMENTED; +#endif +} diff --git a/include/config.h.in b/include/config.h.in index aac10a5933d..44b34ce373d 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1068,8 +1068,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_WAIT_H -/* Define to 1 if you have the `tcgetattr' function. */ -#undef HAVE_TCGETATTR +/* Define to 1 if you have the `tcdrain' function. */ +#undef HAVE_TCDRAIN /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H