From 4f99d7a068e223d2e61a1dc4cc96f39cc1f39e33 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Wed, 28 May 2008 10:35:11 +0000 Subject: [PATCH] Move definition of fd_set to sys/fd_set.h. --- sys/sys/{select.h => fd_set.h} | 59 ++++++++++++++-------------------- sys/sys/select.h | 37 ++------------------- 2 files changed, 27 insertions(+), 69 deletions(-) copy sys/sys/{select.h => fd_set.h} (72%) diff --git a/sys/sys/select.h b/sys/sys/fd_set.h similarity index 72% copy from sys/sys/select.h copy to sys/sys/fd_set.h index b2e7ffa8e8..3e99c03a4a 100644 --- a/sys/sys/select.h +++ b/sys/sys/fd_set.h @@ -32,20 +32,11 @@ * * @(#)select.h 8.2 (Berkeley) 1/4/94 * $FreeBSD: src/sys/sys/select.h,v 1.6.2.1 2000/05/05 03:50:02 jlemon Exp $ - * $DragonFly: src/sys/sys/select.h,v 1.10 2008/01/10 22:30:28 nth Exp $ + * $DragonFly: src/sys/sys/fd_set.h,v 1.1 2008/05/28 10:35:11 corecode Exp $ */ -#ifndef _SYS_SELECT_H_ -#define _SYS_SELECT_H_ - -#include - -#ifndef _SYS_SIGNAL_H_ -#include -#endif -#ifndef _SYS_TIME_H_ -#include -#endif +#ifndef _SYS_FD_SET_H_ +#define _SYS_FD_SET_H_ /* * Select uses bit masks of file descriptors in longs. These macros @@ -57,39 +48,39 @@ #define FD_SETSIZE 1024 #endif -#ifndef NBBY -#define NBBY 8 -#endif +#define __NBBY 8 /* number of bits in a byte */ -typedef unsigned long fd_mask; -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +typedef unsigned long __fd_mask; +#define __NFDBITS ((unsigned int)sizeof(__fd_mask) * __NBBY) /* bits per mask */ -#ifndef howmany -#define howmany(x, y) (((x) + ((y) - 1)) / (y)) +#ifndef __howmany +#define __howmany(x, y) (((x) + ((y) - 1)) / (y)) #endif typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; + __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))) +#define FD_ZERO(p) __builtin_memset((p), 0, sizeof(*(p))) + -__BEGIN_DECLS -#ifndef _SELECT_DECLARED -#define _SELECT_DECLARED -struct timeval; -int select(int, fd_set * __restrict, fd_set * __restrict, - fd_set * __restrict, struct timeval * __restrict); -struct timespec; -int pselect(int, fd_set * __restrict, fd_set * __restrict, - fd_set * __restrict, const struct timespec * __restrict, - const sigset_t * __restrict); +/* + * Expose classic BSD names if we're not running in conformance mode. + */ +#ifdef __BSD_VISIBLE + +#define fd_mask __fd_mask +#define NFDBITS __NFDBITS +#ifndef howmany +#define howmany(a, b) __howmany(a, b) #endif -__END_DECLS -#endif /* !_SYS_SELECT_H_ */ +#define FD_COPY(f, t) __builtin_memcpy((t), (f), sizeof(*(f))) + +#endif /* __BSD_VISIBLE */ + +#endif /* _SYS_FD_SET_H_ */ diff --git a/sys/sys/select.h b/sys/sys/select.h index b2e7ffa8e8..77796b8209 100644 --- a/sys/sys/select.h +++ b/sys/sys/select.h @@ -32,7 +32,7 @@ * * @(#)select.h 8.2 (Berkeley) 1/4/94 * $FreeBSD: src/sys/sys/select.h,v 1.6.2.1 2000/05/05 03:50:02 jlemon Exp $ - * $DragonFly: src/sys/sys/select.h,v 1.10 2008/01/10 22:30:28 nth Exp $ + * $DragonFly: src/sys/sys/select.h,v 1.11 2008/05/28 10:35:11 corecode Exp $ */ #ifndef _SYS_SELECT_H_ @@ -47,41 +47,9 @@ #include #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 1024 -#endif - -#ifndef NBBY -#define NBBY 8 -#endif - -typedef unsigned long fd_mask; -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ - -#ifndef howmany -#define howmany(x, y) (((x) + ((y) - 1)) / (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))) +#include __BEGIN_DECLS -#ifndef _SELECT_DECLARED -#define _SELECT_DECLARED struct timeval; int select(int, fd_set * __restrict, fd_set * __restrict, fd_set * __restrict, struct timeval * __restrict); @@ -89,7 +57,6 @@ struct timespec; int pselect(int, fd_set * __restrict, fd_set * __restrict, fd_set * __restrict, const struct timespec * __restrict, const sigset_t * __restrict); -#endif __END_DECLS #endif /* !_SYS_SELECT_H_ */ -- 2.41.0