Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 2002 01:13:13 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Archie Cobbs <archie@dellroad.org>
Cc:        Mike Barcroft <mike@FreeBSD.ORG>, Marc Recht <marc@informatik.uni-bremen.de>, Garrett Wollman <wollman@lcs.mit.edu>, <current@FreeBSD.ORG>
Subject:   Re: addition to cdefs
Message-ID:  <20021114010436.O5042-100000@gamplex.bde.org>
In-Reply-To: <200211122349.gACNn5cX017668@arch20m.dellroad.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 12 Nov 2002, Archie Cobbs wrote:

> > Marc Recht <marc@informatik.uni-bremen.de> writes:
> > I've had the attached patch in my tree for a while.  I'll try and get
> > it and the <unistd.h> patch committed today.
>
>     static __inline void
>     __fd_zero(fd_set *p, __size_t n)
>     {
> 	    n = _howmany(n, _NFDBITS);
> 	    while (n > 0)
> 		    p->fds_bits[n--] = 0;
>     }
>
> That looks broken. Maybe you meant this:
>
>     static __inline void
>     __fd_zero(fd_set *p, __size_t n)
>     {
> 	    n = _howmany(n, _NFDBITS);
> 	    while (n > 0)
> 		    p->fds_bits[--n] = 0;
>     }

Both have large namespace pollution (p and n are in the application
namespace).  Both give huge code wih a copy of the function in every
object file whose source file(s) include this header if inline functions
are not actually inline (which happens if the compiler is gcc -O0 or
non-gcc).

> But why not just this?
>
>     static __inline void
>     __fd_zero(fd_set *p, __size_t n)
>     {
> 	    memset(p->fds_bits, 0, _howmany(n, _NFDBITS));
>     }

As already pointed out in another reply, memset() gives the same namespace
problems as this function exists to avoid.  __builtin_memset() could be
used if the compiler is gcc.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021114010436.O5042-100000>