Merged revisions 285931 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r285931 | tilghman | 2010-09-09 20:25:50 -0500 (Thu, 09 Sep 2010) | 21 lines
  
  Merged revisions 285930 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r285930 | tilghman | 2010-09-09 20:16:32 -0500 (Thu, 09 Sep 2010) | 14 lines
    
    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: https://origsvn.digium.com/svn/asterisk/trunk@285932 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2010-09-10 01:27:44 +00:00
parent 73c22a15b9
commit 336d2a1abd
5 changed files with 32804 additions and 7636 deletions

View File

@@ -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); \
} \