mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
nolibc: fix fd_set type
The kernel uses unsigned long for the fd_set bitmap, but nolibc use u32. This works fine on little endian machines, but fails on big endian. Convert to unsigned long to fix this. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
1b929c02af
commit
feaf756587
1 changed files with 30 additions and 23 deletions
|
@ -89,39 +89,46 @@
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1
|
||||||
|
|
||||||
|
#define FD_SETIDXMASK (8 * sizeof(unsigned long))
|
||||||
|
#define FD_SETBITMASK (8 * sizeof(unsigned long)-1)
|
||||||
|
|
||||||
/* for select() */
|
/* for select() */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t fd32[(FD_SETSIZE + 31) / 32];
|
unsigned long fds[(FD_SETSIZE + FD_SETBITMASK) / FD_SETIDXMASK];
|
||||||
} fd_set;
|
} fd_set;
|
||||||
|
|
||||||
#define FD_CLR(fd, set) do { \
|
#define FD_CLR(fd, set) do { \
|
||||||
fd_set *__set = (set); \
|
fd_set *__set = (set); \
|
||||||
int __fd = (fd); \
|
int __fd = (fd); \
|
||||||
if (__fd >= 0) \
|
if (__fd >= 0) \
|
||||||
__set->fd32[__fd / 32] &= ~(1U << (__fd & 31)); \
|
__set->fds[__fd / FD_SETIDXMASK] &= \
|
||||||
|
~(1U << (__fd & FX_SETBITMASK)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define FD_SET(fd, set) do { \
|
#define FD_SET(fd, set) do { \
|
||||||
fd_set *__set = (set); \
|
fd_set *__set = (set); \
|
||||||
int __fd = (fd); \
|
int __fd = (fd); \
|
||||||
if (__fd >= 0) \
|
if (__fd >= 0) \
|
||||||
__set->fd32[__fd / 32] |= 1U << (__fd & 31); \
|
__set->fds[__fd / FD_SETIDXMASK] |= \
|
||||||
|
1 << (__fd & FD_SETBITMASK); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define FD_ISSET(fd, set) ({ \
|
#define FD_ISSET(fd, set) ({ \
|
||||||
fd_set *__set = (set); \
|
fd_set *__set = (set); \
|
||||||
int __fd = (fd); \
|
int __fd = (fd); \
|
||||||
int __r = 0; \
|
int __r = 0; \
|
||||||
if (__fd >= 0) \
|
if (__fd >= 0) \
|
||||||
__r = !!(__set->fd32[__fd / 32] & 1U << (__fd & 31)); \
|
__r = !!(__set->fds[__fd / FD_SETIDXMASK] & \
|
||||||
__r; \
|
1U << (__fd & FD_SET_BITMASK)); \
|
||||||
|
__r; \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define FD_ZERO(set) do { \
|
#define FD_ZERO(set) do { \
|
||||||
fd_set *__set = (set); \
|
fd_set *__set = (set); \
|
||||||
int __idx; \
|
int __idx; \
|
||||||
for (__idx = 0; __idx < (FD_SETSIZE+31) / 32; __idx ++) \
|
int __size = (FD_SETSIZE+FD_SETBITMASK) / FD_SETIDXMASK;\
|
||||||
__set->fd32[__idx] = 0; \
|
for (__idx = 0; __idx < __size; __idx++) \
|
||||||
|
__set->fds[__idx] = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* for poll() */
|
/* for poll() */
|
||||||
|
|
Loading…
Add table
Reference in a new issue