|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH] lib/nolibc: Introduce fd_set operation macros
Port FD_CLR, FD_ISSET, FD_SET, and FD_ZERO macros from FreeBSD.
Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
lib/nolibc/include/sys/select.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/nolibc/include/sys/select.h b/lib/nolibc/include/sys/select.h
index f7949ee7..e981b7c0 100644
--- a/lib/nolibc/include/sys/select.h
+++ b/lib/nolibc/include/sys/select.h
@@ -28,6 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+/* Derived from FreeBSD commit 4736ccf (Nov 20, 2017) */
#ifndef __SYS_SELECT_H__
#define __SYS_SELECT_H__
@@ -60,6 +61,20 @@ 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))
+#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] &
__fdset_mask(n)) != 0)
+#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |=
__fdset_mask(n))
+#define FD_ZERO(p) do { \
+ fd_set *_p; \
+ __ssz _n; \
+ \
+ _p = (p); \
+ _n = howmany(FD_SETSIZE, _NFDBITS); \
+ while (_n > 0) \
+ _p->__fds_bits[--_n] = 0; \
+} while (0)
+
#ifdef __cplusplus
}
#endif
--
2.17.2 (Apple Git-113)
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |