Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/sys/sys Apply patch (requested by kleink in ticket #342):



details:   https://anonhg.NetBSD.org/src/rev/a799af729a48
branches:  netbsd-3
changeset: 575914:a799af729a48
user:      tron <tron%NetBSD.org@localhost>
date:      Sat May 28 13:36:29 2005 +0000

description:
Apply patch (requested by kleink in ticket #342):
Instead of including <string.h> for memset()/memcpy() (or adding their
declarations locally), make FD_ZERO()/FD_COPY() use GCC builtins if
available, or define them inline otherwise.
This fixes PRs kern/5076 and lib/30166.

diffstat:

 sys/sys/types.h |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 5c0549dca854 -r a799af729a48 sys/sys/types.h
--- a/sys/sys/types.h   Sat May 28 13:15:39 2005 +0000
+++ b/sys/sys/types.h   Sat May 28 13:36:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.66 2005/03/05 19:48:39 kleink Exp $        */
+/*     $NetBSD: types.h,v 1.66.2.1 2005/05/28 13:36:29 tron Exp $      */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993, 1994
@@ -329,7 +329,16 @@
     ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS)))
 #define        FD_ISSET(n, p)  \
     ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS)))
-#define        FD_ZERO(p)      (void)memset((p), 0, sizeof(*(p)))
+#if __GNUC_PREREQ__(2, 95)
+#define        FD_ZERO(p)      (void)__builtin_memset((p), 0, sizeof(*(p)))
+#else
+#define        FD_ZERO(p)      do {                                            \
+       fd_set *__fds = (p);                                            \
+       unsigned int __i;                                               \
+       for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++)    \
+               __fds->fds_bits[__i] = 0;                               \
+       } while (/* CONSTCOND */ 0)
+#endif /* GCC 2.95 */
 
 /*
  * Expose our internals if we are not required to hide them.
@@ -343,7 +352,16 @@
 #define howmany(a, b) __howmany(a, b)
 #endif
 
-#define        FD_COPY(f, t)   (void)memcpy((t), (f), sizeof(*(f)))
+#if __GNUC_PREREQ__(2, 95)
+#define        FD_COPY(f, t)   (void)__builtin_memcpy((t), (f), sizeof(*(f)))
+#else
+#define        FD_COPY(f, t)   do {                                            \
+       fd_set *__f = (f), *__t = (t);                                  \
+       unsigned int __i;                                               \
+       for (__i = 0; __i < __howmany(FD_SETSIZE, __NFDBITS); __i++)    \
+               __t->fds_bits[__i] = __f->fds_bits[__i];                \
+       } while (/* CONSTCOND */ 0)
+#endif /* GCC 2.95 */
 
 #endif
 



Home | Main Index | Thread Index | Old Index