From 2898c3a51449ade24995c6711d27858218efbd4c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 27 Oct 1998 10:27:11 +0000 Subject: Update. 1998-10-27 Ulrich Drepper * sysdeps/i386/bits/select.h [!__USE_XOPEN]: Add special version of __FD_* macros which use __fds_bits. * sysdeps/generic/bits/select.h: Likewise. Reported by Matt McLean . --- sysdeps/generic/bits/select.h | 23 +++++++++++--- sysdeps/i386/bits/select.h | 72 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 77 insertions(+), 18 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/generic/bits/select.h b/sysdeps/generic/bits/select.h index 98f1002..f886aec 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 f21407f..2e31f3b 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 */ -- cgit v1.1