Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys PR/9901: mycroft: make select guts partially visible...



details:   https://anonhg.NetBSD.org/src/rev/59321deb7afc
branches:  trunk
changeset: 485022:59321deb7afc
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Apr 16 23:12:13 2000 +0000

description:
PR/9901: mycroft: make select guts partially visible for X/Open 5.

diffstat:

 sys/sys/types.h |  54 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 40 insertions(+), 14 deletions(-)

diffs (80 lines):

diff -r e0795995625b -r 59321deb7afc sys/sys/types.h
--- a/sys/sys/types.h   Sun Apr 16 22:17:03 2000 +0000
+++ b/sys/sys/types.h   Sun Apr 16 23:12:13 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.42 1999/12/30 15:51:35 eeh Exp $   */
+/*     $NetBSD: types.h,v 1.43 2000/04/16 23:12:13 christos Exp $      */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993, 1994
@@ -170,8 +170,23 @@
 #undef _BSD_USECONDS_T_
 #endif
 
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define        NBBY    8               /* number of bits in a byte */
+#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
+    (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
+    (_XOPEN_SOURCE - 0) >= 500
+
+/*
+ * Implementation dependent defines, hidden from user space. X/Open does not
+ * specify them.
+ */
+#define        __NBBY  8               /* number of bits in a byte */
+typedef int32_t        __fd_mask;
+#define __NFDBITS      (sizeof(__fd_mask) * __NBBY)    /* bits per mask */
+
+#ifndef howmany
+#define        __howmany(x, y) (((x) + ((y) - 1)) / (y))
+#else
+#define __howmany(x, y) howmany(x, y)
+#endif
 
 /*
  * Select uses bit masks of file descriptors in longs.  These macros
@@ -183,22 +198,33 @@
 #define        FD_SETSIZE      256
 #endif
 
-typedef int32_t        fd_mask;
-#define NFDBITS        (sizeof(fd_mask) * NBBY)        /* bits per mask */
+typedef        struct fd_set {
+       __fd_mask       fds_bits[__howmany(FD_SETSIZE, __NFDBITS)];
+} fd_set;
 
+#define        FD_SET(n, p)    \
+    ((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS)))
+#define        FD_CLR(n, p)    \
+    ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS)))
+#define        FD_ISSET(n, p)  \
+    ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS)))
+#define        FD_ZERO(p)      (void)memset((p), 0, sizeof(*(p)))
+
+/*
+ * Expose our internals if we are not required to hide them.
+ */
+#ifndef _XOPEN_SOURCE
+
+#define NBBY __NBBY
+#define fd_mask __fd_mask
+#define NFDBITS __NFDBITS
 #ifndef howmany
-#define        howmany(x, y)   (((x) + ((y) - 1)) / (y))
+#define howmany(a, b) __howmany(a, b)
 #endif
 
-typedef        struct fd_set {
-       fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
-} fd_set;
+#define        FD_COPY(f, t)   (void)memcpy((t), (f), sizeof(*(f)))
 
-#define        FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
-#define        FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
-#define        FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
-#define        FD_COPY(f, t)   (void)memcpy((t), (f), sizeof(*(f)))
-#define        FD_ZERO(p)      (void)memset((p), 0, sizeof(*(p)))
+#endif
 
 #if defined(__STDC__) && defined(_KERNEL)
 /*



Home | Main Index | Thread Index | Old Index