NetBSD-Bugs archive

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

Re: PR/57809



The following reply was made to PR lib/57809; it has been noted by GNATS.

From: nia <nia%NetBSD.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: PR/57809
Date: Mon, 26 May 2025 11:13:20 +0000

 --+U+4QbQFsSI8vxg4
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 And here is the patch I ended up with.
 
 --+U+4QbQFsSI8vxg4
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="fd_set.diff"
 
 Index: sys/sys/fd_set.h
 ===================================================================
 RCS file: /cvsroot/src/sys/sys/fd_set.h,v
 retrieving revision 1.8
 diff -u -p -r1.8 fd_set.h
 --- sys/sys/fd_set.h	12 May 2024 10:34:56 -0000	1.8
 +++ sys/sys/fd_set.h	26 May 2025 11:12:06 -0000
 @@ -67,24 +67,44 @@ typedef	struct fd_set {
  	__fd_mask	fds_bits[__NFD_SIZE];
  } fd_set;
  
 -#define	FD_SET(n, p)	\
 -    ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] |= (1U << ((n) & __NFDMASK)))
 -#define	FD_CLR(n, p)	\
 -    ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] &= ~(1U << ((n) & __NFDMASK)))
  #define	FD_ISSET(n, p)	\
      ((p)->fds_bits[(unsigned)(n) >> __NFDSHIFT] & (1U << ((n) & __NFDMASK)))
 +
 +static inline void __FD_SET(int n, fd_set *p)
 +{
 +	p->fds_bits[(unsigned)n >> __NFDSHIFT] |= (1U << (n & __NFDMASK));
 +}
 +
 +static inline void __FD_CLR(int n, fd_set *p)
 +{
 +	p->fds_bits[(unsigned)n >> __NFDSHIFT] &= ~(1U << (n & __NFDMASK));
 +}
 +
 +
  #if __GNUC_PREREQ__(2, 95)
 -#define	FD_ZERO(p)	(void)__builtin_memset((p), 0, sizeof(*(p)))
 +static inline void __FD_ZERO(fd_set *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 < __NFD_SIZE; __i++)				\
 -		__fds->fds_bits[__i] = 0;				\
 -	} while (0)
 +static inline void __FD_ZERO(fd_set *p)
 +{
 +	unsigned int i;
 +
 +	for (i = 0; i < NFD_SIZE; i++)
 +		p->fds_bits[i] = 0;
 +}
  #endif /* GCC 2.95 */
  
  /*
 + * Some software expects them defined as macros and uses
 + * #ifdef to test their presence.
 + */
 +#define FD_SET __FD_SET
 +#define FD_CLR __FD_CLR
 +#define FD_ZERO __FD_ZERO
 +
 +/*
   * Expose our internals if we are not required to hide them.
   */
  #if defined(_NETBSD_SOURCE)
 
 --+U+4QbQFsSI8vxg4--
 


Home | Main Index | Thread Index | Old Index