Date: Wed, 13 Nov 2002 07:31:43 -0500 From: Mike Barcroft <mike@FreeBSD.org> To: standards@FreeBSD.org Cc: Archie Cobbs <archie@dellroad.org> Subject: select.diff for review Message-ID: <20021113073143.A98651@espresso.q9media.com>
next in thread | raw e-mail | index | archive | help
--bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I plan on committing the attached patch to <sys/select.h> soon. Comments appreciated. Best regards, Mike Barcroft --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="select.diff" 1. Hide the internals of struct fd_set in standard namespaces. 2. Avoid referencing bcopy() and bzero(), since they may not be in scope. Request by: bde (1) Submitted by: wollman (2) Index: select.h =================================================================== RCS file: /work/repo/src/sys/sys/select.h,v retrieving revision 1.15 diff -u -r1.15 select.h --- select.h 5 Oct 2002 05:40:48 -0000 1.15 +++ select.h 13 Nov 2002 12:30:23 -0000 @@ -79,18 +79,29 @@ #endif typedef struct fd_set { - __fd_mask fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; + __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; } fd_set; +#if __BSD_VISIBLE +#define fds_bits __fds_bits +#endif -#define __fdset_mask(n) ((fd_mask)1 << ((n) % _NFDBITS)) +#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) #define FD_CLR(n, p) ((p)->fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) #if __BSD_VISIBLE -/* XXX bcopy() not in scope, so <strings.h> is required; see also FD_ZERO(). */ -#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) +#define FD_COPY(f, t) (void)(*(t) = *(f)) #endif #define FD_ISSET(n, p) ((p)->fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) #define FD_SET(n, p) ((p)->fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) -#define FD_ZERO(p) bzero(p, sizeof(*(p))) +#define FD_ZERO(p) __fd_zero((p), FD_SETSIZE) + +static __inline void +__fd_zero(fd_set *_p, __size_t _n) +{ + + _n = _howmany(_n, _NFDBITS); + while (_n > 0) + _p->__fds_bits[--_n] = 0; +} #ifndef _KERNEL struct timeval; --bg08WKrSYDhXBjb5-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021113073143.A98651>