o Move select() helper macros from <sys/types.h> to <sys/select.h>.
o Include <sys/select.h> from <sys/types.h> in the __BSD_VISIBLE case, so applications and base software can be slowly updated. o Prototype select() in <sys/select.h>. It was previously only prototyped in <unistd.h>. o Add some XXX's to <sys/types.h>. Reviewed by: -standards
This commit is contained in:
parent
58eab4797a
commit
56144d5a4d
@ -489,7 +489,12 @@ int rresvport(int *);
|
||||
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);
|
||||
|
@ -43,23 +43,61 @@
|
||||
#include <sys/timespec.h>
|
||||
|
||||
/*
|
||||
* 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 <sys/types.h>, 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* <sys/types.h>
|
||||
* in the BSD namespace.)
|
||||
*/
|
||||
#include <sys/types.h> /* 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) - 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_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)))
|
||||
#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 */
|
||||
|
||||
|
@ -255,37 +255,22 @@ typedef __timer_t timer_t;
|
||||
#define _TIMER_T_DECLARED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following are all things that really shouldn't exist in this header,
|
||||
* since its purpose is to provide typedefs, not miscellaneous doodads.
|
||||
*/
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
#include <sys/select.h>
|
||||
|
||||
/* XXX should be moved to <sys/param.h>. */
|
||||
#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.
|
||||
*/
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 1024U
|
||||
#endif
|
||||
|
||||
typedef unsigned long fd_mask;
|
||||
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
|
||||
|
||||
/* XXX should be removed, since <sys/param.h> 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
|
||||
* <stdio.h> to give broken programs a better chance of working with
|
||||
|
Loading…
Reference in New Issue
Block a user