On Tue, 12 Nov 2002, Archie Cobbs wrote:
> > Marc Recht <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message