diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-09-10 00:13:45 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-09-10 00:13:45 +0000 |
commit | b4e92938be35a3ec6221931a81c32cf5104f4d9a (patch) | |
tree | b74bf3bd5545175b3979483c1c1c71a9d70b8ce9 /include | |
parent | a35868c2670ebbb59914d610c99bdfb1e20cb6dd (diff) |
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.4@285889 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/autoconfig.h.in | 12 | ||||
-rw-r--r-- | include/asterisk/select.h | 11 |
2 files changed, 18 insertions, 5 deletions
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 418d1d85b..a99ffa774 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -701,9 +701,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. @@ -721,6 +730,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); \ } \ |