]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libphobos/libdruntime/core/sys/posix/sys/select.d
libphobos: Merge upstream druntime 94686651
[thirdparty/gcc.git] / libphobos / libdruntime / core / sys / posix / sys / select.d
index e2d282492848eabb03e59ff0fe87a34c62f2cdc5..2508366d69c7d097be386597528477bc2d85a1bf 100644 (file)
@@ -270,6 +270,53 @@ else version (NetBSD)
     int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
+else version (OpenBSD)
+{
+    private
+    {
+        alias uint __fd_mask;
+        enum _NFDBITS = __fd_mask.sizeof * 8;
+    }
+
+    enum uint FD_SETSIZE = 1024;
+
+    struct fd_set
+    {
+        __fd_mask[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS] __fds_bits;
+    }
+
+    extern (D) __fd_mask __fdset_mask(uint n) pure
+    {
+        return cast(__fd_mask) 1 << (n % _NFDBITS);
+    }
+
+    extern (D) void FD_CLR(int n, fd_set* p) pure
+    {
+        p.__fds_bits[n / _NFDBITS] &= ~__fdset_mask(n);
+    }
+
+    extern (D) bool FD_ISSET(int n, const(fd_set)* p) pure
+    {
+        return (p.__fds_bits[n / _NFDBITS] & __fdset_mask(n)) != 0;
+    }
+
+    extern (D) void FD_SET(int n, fd_set* p) pure
+    {
+        p.__fds_bits[n / _NFDBITS] |= __fdset_mask(n);
+    }
+
+    extern (D) void FD_ZERO(fd_set* p) pure
+    {
+        fd_set *_p = p;
+        size_t _n = (FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS;
+
+        while (_n > 0)
+            _p.__fds_bits[--_n] = 0;
+    }
+
+    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+}
 else version (DragonFlyBSD)
 {
     private