diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/bits/select.h | 23 | ||||
-rw-r--r-- | sysdeps/i386/bits/select.h | 72 |
2 files changed, 77 insertions, 18 deletions
diff --git a/sysdeps/generic/bits/select.h b/sysdeps/generic/bits/select.h index 98f1002b01..f886aec210 100644 --- a/sysdeps/generic/bits/select.h +++ b/sysdeps/generic/bits/select.h @@ -23,13 +23,26 @@ /* We don't use `memset' because this would require a prototype and the array isn't too big. */ -#define __FD_ZERO(set) \ +#ifdef __USE_XOPEN +# define __FD_ZERO(s) \ do { \ unsigned int __i; \ - __fd_set *__arr = (set); \ + __fd_set *__arr = (s); \ for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \ __arr->fds_bits[__i] = '\0'; \ } while (0) -#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) -#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) -#define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0) +# define __FD_SET(d, s) ((s)->fds_bits[__FDELT(d)] |= __FDMASK(d)) +# define __FD_CLR(d, s) ((s)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) +# define __FD_ISSET(d, s) (((s)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0) +#else +# define __FD_ZERO(s) \ + do { \ + unsigned int __i; \ + __fd_set *__arr = (s); \ + for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \ + __arr->__fds_bits[__i] = '\0'; \ + } while (0) +# define __FD_SET(d, s) ((s)->__fds_bits[__FDELT(d)] |= __FDMASK(d)) +# define __FD_CLR(d, s) ((s)->__fds_bits[__FDELT(d)] &= ~__FDMASK(d)) +# define __FD_ISSET(d, s) (((s)->__fds_bits[__FDELT(d)] & __FDMASK(d)) != 0) +#endif diff --git a/sysdeps/i386/bits/select.h b/sysdeps/i386/bits/select.h index f21407f81f..2e31f3bc59 100644 --- a/sysdeps/i386/bits/select.h +++ b/sysdeps/i386/bits/select.h @@ -23,51 +23,97 @@ #if defined __GNUC__ && __GNUC__ >= 2 -# define __FD_ZERO(fdsetp) \ +# ifdef __USE_XOPEN +# define __FD_ZERO(fdsp) \ do { \ int __d0, __d1; \ __asm__ __volatile__ ("cld; rep; stosl" \ - : "=m" ((fdsetp)->fds_bits[__FDELT (__FD_SETSIZE)]),\ + : "=m" ((fdsp)->fds_bits[__FDELT (__FD_SETSIZE)]), \ "=&c" (__d0), "=&D" (__d1) \ : "a" (0), "1" (sizeof (__fd_set) \ / sizeof (__fd_mask)), \ - "2" (&(fdsetp)->fds_bits[0]) \ + "2" (&(fdsp)->fds_bits[0]) \ : "memory"); \ } while (0) -# define __FD_SET(fd, fdsetp) \ +# define __FD_SET(fd, fdsp) \ __asm__ __volatile__ ("btsl %1,%0" \ - : "=m" ((fdsetp)->fds_bits[__FDELT (fd)]) \ + : "=m" ((fdsp)->fds_bits[__FDELT (fd)]) \ : "r" (((int) (fd)) % __NFDBITS) \ : "cc","memory") -# define __FD_CLR(fd, fdsetp) \ +# define __FD_CLR(fd, fdsp) \ __asm__ __volatile__ ("btrl %1,%0" \ - : "=m" ((fdsetp)->fds_bits[__FDELT (fd)]) \ + : "=m" ((fdsp)->fds_bits[__FDELT (fd)]) \ : "r" (((int) (fd)) % __NFDBITS) \ : "cc","memory") -# define __FD_ISSET(fd, fdsetp) \ +# define __FD_ISSET(fd, fdsp) \ (__extension__ \ ({register char __result; \ __asm__ __volatile__ ("btl %1,%2 ; setcb %b0" \ : "=q" (__result) \ : "r" (((int) (fd)) % __NFDBITS), \ - "m" ((fdsetp)->fds_bits[__FDELT (fd)]) \ + "m" ((fdsp)->fds_bits[__FDELT (fd)]) \ : "cc"); \ __result; })) +# else +# define __FD_ZERO(fdsp) \ + do { \ + int __d0, __d1; \ + __asm__ __volatile__ ("cld; rep; stosl" \ + : "=m" ((fdsp)->__fds_bits[__FDELT (__FD_SETSIZE)]),\ + "=&c" (__d0), "=&D" (__d1) \ + : "a" (0), "1" (sizeof (__fd_set) \ + / sizeof (__fd_mask)), \ + "2" (&(fdsp)->__fds_bits[0]) \ + : "memory"); \ + } while (0) + +# define __FD_SET(fd, fdsp) \ + __asm__ __volatile__ ("btsl %1,%0" \ + : "=m" ((fdsp)->__fds_bits[__FDELT (fd)]) \ + : "r" (((int) (fd)) % __NFDBITS) \ + : "cc","memory") +# define __FD_CLR(fd, fdsp) \ + __asm__ __volatile__ ("btrl %1,%0" \ + : "=m" ((fdsp)->__fds_bits[__FDELT (fd)]) \ + : "r" (((int) (fd)) % __NFDBITS) \ + : "cc","memory") +# define __FD_ISSET(fd, fdsp) \ + (__extension__ \ + ({register char __result; \ + __asm__ __volatile__ ("btl %1,%2 ; setcb %b0" \ + : "=q" (__result) \ + : "r" (((int) (fd)) % __NFDBITS), \ + "m" ((fdsp)->__fds_bits[__FDELT (fd)]) \ + : "cc"); \ + __result; })) +# endif #else /* ! GNU CC */ /* We don't use `memset' because this would require a prototype and the array isn't too big. */ -# define __FD_ZERO(set) \ +# ifdef __USE_XOPEN +# define __FD_ZERO(set) \ do { \ unsigned int __i; \ __fd_set *__arr = (set); \ for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \ __arr->fds_bits[__i] = 0; \ } while (0) -# define __FD_SET(d, set) ((set)->fds_bits[__FDELT (d)] |= __FDMASK (d)) -# define __FD_CLR(d, set) ((set)->fds_bits[__FDELT (d)] &= ~__FDMASK (d)) -# define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT (d)] & __FDMASK (d)) +# define __FD_SET(d, set) ((set)->fds_bits[__FDELT (d)] |= __FDMASK (d)) +# define __FD_CLR(d, set) ((set)->fds_bits[__FDELT (d)] &= ~__FDMASK (d)) +# define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT (d)] & __FDMASK (d)) +# else + do { \ + unsigned int __i; \ + __fd_set *__arr = (set); \ + for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \ + __arr->__fds_bits[__i] = 0; \ + } while (0) +# define __FD_SET(d, set) ((set)->__fds_bits[__FDELT (d)] |= __FDMASK (d)) +# define __FD_CLR(d, set) ((set)->__fds_bits[__FDELT (d)] &= ~__FDMASK (d)) +# define __FD_ISSET(d, set) ((set)->__fds_bits[__FDELT (d)] & __FDMASK (d)) +# endif #endif /* GNU CC */ |