From 939ff8e169ebf8be159d09da3d3d7bba700c06e0 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Thu, 2 Oct 2003 17:41:31 +0000 Subject: [PATCH] Simplify FD_SET etc. use. * include/am_defs.h (FD_SET, FD_ISSET, FD_CLR, FD_ZERO): Provide if missing. (rpc_pending_now, run_rpc): Use them. * configure.in: Check for fds_bits field in fd_set. * amd/nfs_start.c (run_rpc): Use it. --- ChangeLog | 10 ++++++++++ amd/nfs_start.c | 30 ++++++++---------------------- configure.in | 3 ++- include/am_defs.h | 12 +++++++++++- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index dff70bd..73c4316 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-10-02 Rainer Orth + + Simplify FD_SET etc. use. + + * include/am_defs.h (FD_SET, FD_ISSET, FD_CLR, FD_ZERO): Provide + if missing. + (rpc_pending_now, run_rpc): Use them. + * configure.in: Check for fds_bits field in fd_set. + * amd/nfs_start.c (run_rpc): Use it. + 2003-10-02 Rainer Orth Improve RPC XID handling. diff --git a/amd/nfs_start.c b/amd/nfs_start.c index a2d4d26..8885f90 100644 --- a/amd/nfs_start.c +++ b/amd/nfs_start.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: nfs_start.c,v 1.19 2003/07/30 06:56:09 ib42 Exp $ + * $Id: nfs_start.c,v 1.20 2003/10/02 17:41:32 ro Exp $ * */ @@ -169,26 +169,17 @@ rpc_pending_now(void) { struct timeval tvv; int nsel; -#ifdef FD_SET fd_set readfds; FD_ZERO(&readfds); FD_SET(fwd_sock, &readfds); -#else /* not FD_SET */ - int readfds = (1 << fwd_sock); -#endif /* not FD_SET */ tvv.tv_sec = tvv.tv_usec = 0; nsel = select(FD_SETSIZE, &readfds, (fd_set *) 0, (fd_set *) 0, &tvv); if (nsel < 1) return (0); -#ifdef FD_SET if (FD_ISSET(fwd_sock, &readfds)) return (1); -#else /* not FD_SET */ - if (readfds & (1 << fwd_sock)) - return (1); -#endif /* not FD_SET */ return (0); } @@ -223,14 +214,14 @@ run_rpc(void) memmove(&readfds, &svc_fdset, sizeof(svc_fdset)); FD_SET(fwd_sock, &readfds); #else /* not HAVE_SVC_GETREQSET */ -# ifdef FD_SET fd_set readfds; FD_ZERO(&readfds); +# ifdef HAVE_FD_SET_FDS_BITS readfds.fds_bits[0] = svc_fds; +# else /* not HAVE_FD_SET_FDS_BITS */ + readfds = svc_fds; +# endif /* not HAVE_FD_SET_FDS_BITS */ FD_SET(fwd_sock, &readfds); -# else /* not FD_SET */ - int readfds = svc_fds | (1 << fwd_sock); -# endif /* not FD_SET */ #endif /* not HAVE_SVC_GETREQSET */ checkup(); @@ -287,13 +278,8 @@ run_rpc(void) * Read all pending NFS responses at once to avoid having responses * queue up as a consequence of retransmissions. */ -#ifdef FD_SET if (FD_ISSET(fwd_sock, &readfds)) { FD_CLR(fwd_sock, &readfds); -#else /* not FD_SET */ - if (readfds & (1 << fwd_sock)) { - readfds &= ~(1 << fwd_sock); -#endif /* not FD_SET */ --nsel; do { fwd_reply(); @@ -313,11 +299,11 @@ run_rpc(void) #ifdef HAVE_SVC_GETREQSET svc_getreqset(&readfds); #else /* not HAVE_SVC_GETREQSET */ -# ifdef FD_SET +# ifdef HAVE_FD_SET_FDS_BITS svc_getreq(readfds.fds_bits[0]); -# else /* not FD_SET */ +# else /* not HAVE_FD_SET_FDS_BITS */ svc_getreq(readfds); -# endif /* not FD_SET */ +# endif /* not HAVE_FD_SET_FDS_BITS */ #endif /* not HAVE_SVC_GETREQSET */ } break; diff --git a/configure.in b/configure.in index 88d31af..98d3914 100644 --- a/configure.in +++ b/configure.in @@ -53,7 +53,7 @@ AH_BOTTOM([ dnl dnl AC_CONFIG_AUX_DIR(m4) AC_PREREQ(2.52) -AC_REVISION($Revision: 1.62 $) +AC_REVISION($Revision: 1.63 $) AC_COPYRIGHT([Copyright (c) 1997-2003 Erez Zadok]) dnl find out system type AC_MSG_NOTICE(*** SYSTEM TYPES ***) @@ -732,6 +732,7 @@ dnl ********* dnl ###################################################################### AC_MSG_NOTICE(*** FIELDS WITHIN STRUCTURES ***) +AMU_CHECK_FIELD(fd_set.fds_bits) AMU_CHECK_FIELD(mntent_t.mnt_cnode) AMU_CHECK_FIELD(mntent_t.mnt_ro) AMU_CHECK_FIELD(mntent_t.mnt_time) diff --git a/include/am_defs.h b/include/am_defs.h index 35e042d..8408342 100644 --- a/include/am_defs.h +++ b/include/am_defs.h @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: am_defs.h,v 1.44 2003/09/26 20:15:13 ro Exp $ + * $Id: am_defs.h,v 1.45 2003/10/02 17:41:32 ro Exp $ * */ @@ -1367,6 +1367,16 @@ typedef struct _am_mntent { # endif /* not HAVE_STRUCT_MNTTAB */ #endif /* not HAVE_STRUCT_MNTENT */ +/* + * Provide FD_* macros for systems that lack them. + */ +#ifndef FD_SET +# define FD_SET(fd, set) (*(set) |= (1 << (fd))) +# define FD_ISSET(fd, set) (*(set) & (1 << (fd))) +# define FD_CLR(fd, set) (*(set) &= ~(1 << (fd))) +# define FD_ZERO(set) (*(set) = 0) +#endif /* not FD_SET */ + /* * Complete external definitions missing from some systems. -- 2.43.0