summaryrefslogtreecommitdiff
path: root/src/sysselect.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysselect.h')
-rw-r--r--src/sysselect.h43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/sysselect.h b/src/sysselect.h
index 0a4f7e3ad96..244f0f7c067 100644
--- a/src/sysselect.h
+++ b/src/sysselect.h
@@ -16,14 +16,47 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
+#ifndef EMACS_SYSSELECT_H
+#define EMACS_SYSSELECT_H
+
#ifndef DOS_NT
#include <sys/select.h>
#endif
-/* The w32 build defines select stuff in w32.h, which is included
- where w32 needs it, but not where sysselect.h is included. The w32
- definitions in w32.h are incompatible with the below. */
-#ifndef WINDOWSNT
+#ifdef WINDOWSNT
+
+/* File descriptor set emulation. */
+
+/* MSVC runtime library has limit of 64 descriptors by default */
+#define FD_SETSIZE 64
+typedef struct {
+ unsigned int bits[FD_SETSIZE / 32];
+} fd_set;
+
+/* standard access macros */
+#define FD_SET(n, p) \
+ do { \
+ if ((n) < FD_SETSIZE) { \
+ (p)->bits[(n)/32] |= (1 << (n)%32); \
+ } \
+ } while (0)
+#define FD_CLR(n, p) \
+ do { \
+ if ((n) < FD_SETSIZE) { \
+ (p)->bits[(n)/32] &= ~(1 << (n)%32); \
+ } \
+ } while (0)
+#define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
+#define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
+
+#define SELECT_TYPE fd_set
+
+#include "systime.h"
+extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
+ EMACS_TIME *, sigset_t *);
+
+#else /* not WINDOWSNT */
+
#ifdef FD_SET
#ifdef FD_SETSIZE
#define MAXDESC FD_SETSIZE
@@ -50,3 +83,5 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef MSDOS
#define pselect sys_select
#endif
+
+#endif /* EMACS_SYSSELECT_H */