aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--bits/select.h23
-rw-r--r--sysdeps/generic/bits/select.h23
-rw-r--r--sysdeps/i386/bits/select.h72
4 files changed, 102 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 6802171646..5845254a28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1998-10-27 Ulrich Drepper <drepper@cygnus.com>
+
+ * 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 <keys@yikes.com>.
+
1998-10-27 Philip Blundell <pb@nexus.co.uk>
* elf/elf.h: Update ARM definitions.
diff --git a/bits/select.h b/bits/select.h
index 98f1002b01..f886aec210 100644
--- a/bits/select.h
+++ b/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/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 */