From 41c8fcb7704b09f308ccf0dd5029cf3edb7919c8 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 12 Sep 2020 13:05:58 -0700 Subject: [PATCH] remove dependence on _stream_peek and _socket_peek macros Related to #1422 an #1521. --- configure.ac | 4 ++-- lib/sfio/sfhdr.h | 10 ---------- lib/sfio/sfpkrd.c | 16 ++++++++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 6c99463fd..644d44770 100644 --- a/configure.ac +++ b/configure.ac @@ -445,9 +445,9 @@ dnl Checks for header files # AC_HEADER_STDC AC_CHECK_HEADERS( \ - fcntl.h search.h termios.h \ + fcntl.h search.h stropts.h termios.h \ unistd.h strings.h stat.h vfork.h \ - sys/time.h sys/types.h sys/select.h \ + sys/time.h sys/types.h sys/select.h sys/socket.h \ sys/stat.h sys/mman.h sys/vfork.h \ sys/ioctl.h sys/inotify.h crt_externs.h) diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index 9cda8a815..16ef69d81 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -100,16 +100,6 @@ extern "C" { #define POOLMTXSTART(p) #define POOLMTXRETURN(p,v) { return(v); } -/* functions for polling readiness of streams */ - -#if _stream_peek -#include -#endif - -#if _socket_peek -#include -#endif - /* to test for executable access mode of a file */ #ifndef X_OK #define X_OK 01 diff --git a/lib/sfio/sfpkrd.c b/lib/sfio/sfpkrd.c index 09fc074b3..401373448 100644 --- a/lib/sfio/sfpkrd.c +++ b/lib/sfio/sfpkrd.c @@ -12,10 +12,14 @@ *************************************************************************/ #include -#ifndef FIONREAD #ifdef HAVE_SYS_IOCTL_H #include #endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_STROPTS_H +#include #endif /* Read/Peek a record from an unseekable device @@ -47,16 +51,16 @@ ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm, return read(fd, buf, n); t = (action > 0 || rc >= 0) ? (STREAM_PEEK | SOCKET_PEEK) : 0; -#if !_stream_peek +#ifndef I_PEEK t &= ~STREAM_PEEK; #endif -#if !_socket_peek +#ifndef MSG_PEEK t &= ~SOCKET_PEEK; #endif for (ntry = 0; ntry < 2; ++ntry) { r = -1; -#if _stream_peek +#ifdef I_PEEK if ((t & STREAM_PEEK) && (ntry == 1 || tm < 0)) { struct strpeek pbuf; pbuf.flags = 0; @@ -84,7 +88,7 @@ ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm, break; } } -#endif /* stream_peek */ +#endif if (ntry == 1) break; @@ -160,7 +164,7 @@ ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm, break; } -#if _socket_peek +#ifdef MSG_PEEK if (t & SOCKET_PEEK) { while ((r = recv(fd, (char *) buf, n, MSG_PEEK)) < 0) { if (errno == EINTR) -- 2.40.0