aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/autoconfig.h.in12
-rw-r--r--include/asterisk/select.h11
2 files changed, 18 insertions, 5 deletions
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 2936b96dd..c7252d34b 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -965,9 +965,18 @@
release 3. */
#undef SETVBUF_REVERSED
+/* The size of `fd_set.fds_bits', as computed by sizeof. */
+#undef SIZEOF_FD_SET_FDS_BITS
+
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
@@ -985,6 +994,9 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
+/* Define to a type of the same size as fd_set.fds_bits[[0]] */
+#undef TYPEOF_FD_SET_FDS_BITS
+
/* Define to 1 if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
diff --git a/include/asterisk/select.h b/include/asterisk/select.h
index fea8c7aff..773b0a54e 100644
--- a/include/asterisk/select.h
+++ b/include/asterisk/select.h
@@ -23,6 +23,7 @@
#ifndef __AST_SELECT_H
#define __AST_SELECT_H
+#include "asterisk/autoconfig.h"
#include <sys/select.h>
#include <errno.h>
#include "asterisk/utils.h"
@@ -37,24 +38,24 @@ extern unsigned int ast_FD_SETSIZE;
#define ast_fdset fd_set
#else
typedef struct {
- long fds_bits[4096 / sizeof(long)]; /* 32768 bits */
+ TYPEOF_FD_SET_FDS_BITS fds_bits[4096 / SIZEOF_FD_SET_FDS_BITS]; /* 32768 bits */
} ast_fdset;
#undef FD_ZERO
#define FD_ZERO(a) \
do { \
- long *bytes = (long *) a; \
+ TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) a; \
int i; \
- for (i = 0; i < sizeof(*(a)) / sizeof(long); i++) { \
+ for (i = 0; i < sizeof(*(a)) / SIZEOF_FD_SET_FDS_BITS; i++) { \
bytes[i] = 0; \
} \
} while (0)
#undef FD_SET
#define FD_SET(fd, fds) \
do { \
- long *bytes = (long *) fds; \
+ TYPEOF_FD_SET_FDS_BITS *bytes = (TYPEOF_FD_SET_FDS_BITS *) fds; \
if (fd / sizeof(*bytes) + ((fd + 1) % sizeof(*bytes) ? 1 : 0) < sizeof(*(fds))) { \
- bytes[fd / (sizeof(*bytes))] |= 1L << (fd % sizeof(*bytes)); \
+ bytes[fd / (sizeof(*bytes) * 8)] |= ((TYPEOF_FD_SET_FDS_BITS) 1) << (fd % (sizeof(*bytes) * 8)); \
} else { \
ast_log(LOG_ERROR, "FD %d exceeds the maximum size of ast_fdset!\n", fd); \
} \