aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-10 01:16:32 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-10 01:16:32 +0000
commitdcd8a05e6d0300019f351c60d1488c15aa2d5a42 (patch)
tree986d3ae4dc4a9f66cbd076deb2e546dab61f94c1 /include
parent85d139c11e4f8ad98ce1113e63d10ffb7c9ee4de (diff)
Merged revisions 285889 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r285889 | tilghman | 2010-09-09 19:13:45 -0500 (Thu, 09 Sep 2010) | 7 lines Fix Mac OS X build. This also fixes a rather grievous calculation error for the offset of ast_fdset, which was masked on Linux and FreeBSD, because these platforms check the first 256 FDs regardless of the bitmask setting (due to backwards compatibility). ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@285930 f38db490-d61c-443f-a65b-d21fe96a405b
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); \
} \