From owner-freebsd-standards Sun Sep 22 21: 6:37 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 115C837B401 for ; Sun, 22 Sep 2002 21:06:33 -0700 (PDT) Received: from espresso.q9media.com (espresso.q9media.com [65.39.129.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id A068743E3B for ; Sun, 22 Sep 2002 21:06:32 -0700 (PDT) (envelope-from mike@espresso.q9media.com) Received: by espresso.q9media.com (Postfix, from userid 1002) id C23F79C11; Sun, 22 Sep 2002 23:59:43 -0400 (EDT) Date: Sun, 22 Sep 2002 23:59:43 -0400 From: Mike Barcroft To: standards@FreeBSD.org Cc: Josef Karthauser Subject: select.diff for review Message-ID: <20020922235943.G91924@espresso.q9media.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="RIYY1s2vRbPFwWeW" Content-Disposition: inline Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --RIYY1s2vRbPFwWeW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached is a patch which makes much more conformant by bringing over components from . Comments appreciated. Best regards, Mike Barcroft --RIYY1s2vRbPFwWeW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="select.diff" o Move select() helper macros from to . o Include from in the __BSD_VISIBLE case, so applications and base software can be slowly updated. o Prototype select() in . It was previously only prototyped in . o Add some XXX's to . Index: include/unistd.h =================================================================== RCS file: /work/repo/src/include/unistd.h,v retrieving revision 1.58 diff -u -r1.58 unistd.h --- include/unistd.h 21 Sep 2002 02:08:32 -0000 1.58 +++ include/unistd.h 23 Sep 2002 00:32:15 -0000 @@ -489,7 +489,12 @@ int rresvport_af(int *, int); int ruserok(const char *, int, const char *, const char *); void *sbrk(intptr_t); +#if __BSD_VISIBLE +#ifndef _SELECT_DECLARED +#define _SELECT_DECLARED int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#endif +#endif int setdomainname(const char *, int); int setgroups(int, const gid_t *); void sethostid(long); Index: sys/sys/select.h =================================================================== RCS file: /work/repo/src/sys/sys/select.h,v retrieving revision 1.13 diff -u -r1.13 select.h --- sys/sys/select.h 16 Jun 2002 18:40:16 -0000 1.13 +++ sys/sys/select.h 23 Sep 2002 03:49:52 -0000 @@ -43,23 +43,61 @@ #include /* + * XXX * Other things required for this header which we do not presently implement: * * struct timeval (with suseconds_t) - * fd_set - * FD_* macros - * - * Temporarily get all of these things from , which has too - * much pollution to be used here but will do for now. (Eventually, the - * latter two will move to this file and be included *from* - * in the BSD namespace.) */ -#include /* XXX dependency reversed */ + +typedef unsigned long __fd_mask; +#if __BSD_VISIBLE +typedef __fd_mask fd_mask; +#endif + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 1024U +#endif + +#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */ +#if __BSD_VISIBLE +#define NFDBITS _NFDBITS +#endif + +#ifndef _howmany +#define _howmany(x, y) (((x) + ((y) - 1U)) / (y)) +#endif + +typedef struct fd_set { + __fd_mask fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; +} fd_set; + +#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 is required; see also FD_ZERO(). */ +#define FD_COPY(f, t) bcopy(f, t, sizeof(*(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))) #ifndef _KERNEL +struct timeval; + __BEGIN_DECLS int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict); +#ifndef _SELECT_DECLARED +#define _SELECT_DECLARED +/* XXX missing restrict type-qualifier */ +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#endif __END_DECLS #endif /* !_KERNEL */ Index: sys/sys/types.h =================================================================== RCS file: /work/repo/src/sys/sys/types.h,v retrieving revision 1.70 diff -u -r1.70 types.h --- sys/sys/types.h 17 Sep 2002 05:05:14 -0000 1.70 +++ sys/sys/types.h 23 Sep 2002 00:33:48 -0000 @@ -255,41 +255,28 @@ #define _TIMER_T_DECLARED #endif -#if __BSD_VISIBLE -#define NBBY 8 /* number of bits in a byte */ - /* - * Select uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. + * The following are all things that really shouldn't exist in this header, + * since its purpose is to provide typedefs, not miscellaneous doodads. */ -#ifndef FD_SETSIZE -#define FD_SETSIZE 1024U -#endif +#if __BSD_VISIBLE -typedef unsigned long fd_mask; -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +#include +/* XXX should be moved to . */ +#define NBBY 8 /* number of bits in a byte */ + +/* XXX should be removed, since has this. */ #ifndef howmany #define howmany(x, y) (((x) + ((y) - 1U)) / (y)) #endif -typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} fd_set; - -#define _fdset_mask(n) ((fd_mask)1 << ((n) % NFDBITS)) -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= _fdset_mask(n)) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~_fdset_mask(n)) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & _fdset_mask(n)) -#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) -#define FD_ZERO(p) bzero(p, sizeof(*(p))) - /* * These declarations belong elsewhere, but are repeated here and in * to give broken programs a better chance of working with * 64-bit off_t's. + * + * XXX is this still needed? */ #ifndef _KERNEL __BEGIN_DECLS --RIYY1s2vRbPFwWeW-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message