Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Nov 2002 11:21:28 -0500
From:      Mike Barcroft <mike@FreeBSD.org>
To:        Marc Recht <marc@informatik.uni-bremen.de>
Cc:        Garrett Wollman <wollman@lcs.mit.edu>, current@FreeBSD.ORG
Subject:   Re: addition to cdefs
Message-ID:  <20021111112128.G52940@espresso.q9media.com>
In-Reply-To: <1037029019.779.87.camel@leeloo.intern.geht.de>; from marc@informatik.uni-bremen.de on Mon, Nov 11, 2002 at 04:36:58PM %2B0100
References:  <1037017897.779.20.camel@leeloo.intern.geht.de> <20021111095458.F52940@espresso.q9media.com> <1037029019.779.87.camel@leeloo.intern.geht.de>

next in thread | previous in thread | raw e-mail | index | archive | help

--tqI+Z3u+9OQ7kwn0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Marc Recht <marc@informatik.uni-bremen.de> writes:
> Thanks!
> 
> > It looks like <unistd.h> has some XSI bugs.  Is _XOPEN_SOURCE defined
> > anywhere?  If so, try the attached patch.  If not, this is a bug in
> Yes, _XOPEN_SOURCE is defined. So, it solves some of the problems.
> 
> > Python (since POSIX doesn't specify chroot()) and should be fixed at
> > their end and in the ports collection.
> But, there still some problems left. Like fd_set being not defined in
> sys/select if _BSD_VISIBLE isn't given.

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.

> > _BSD_SOURCE provides mostly the same visibility as not defining any
> > standards constants, so it isn't very useful.
> IMO it would be nice to have a clean way to toggle __BSD_VISIBLE from
> the outside. In the default environment I have
> #define  __POSIX_VISIBLE      200112
> #define  __XSI_VISIBLE     600
> #define  __BSD_VISIBLE     1
> #define  __ISO_C_VISIBLE      1999
> 
> But, Python for example, wants _POSIX_C_SOURCE 199506,_XOPEN_SOURCE 500
> _and_ __BSD_VISIBLE 1. I know, I could also just do a -D__BSD_VISIBLE=1,
> but I think thats not The Right Thing to do.

The whole point of the standards constants is to specify a strict
environment.  If you want a BSD environment don't specify a particular
standard, it's simple.

Best regards,
Mike Barcroft

--tqI+Z3u+9OQ7kwn0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="select.diff"

Index: select.h
===================================================================
RCS file: /work/repo/src/sys/sys/select.h,v
retrieving revision 1.15
diff -u -r1.15 select.h
--- select.h	5 Oct 2002 05:40:48 -0000	1.15
+++ select.h	21 Oct 2002 21:49:23 -0000
@@ -79,18 +79,30 @@
 #endif
 
 typedef	struct fd_set {
+#if __BSD_VISIBLE || __XSI_VISIBLE <= 500
 	__fd_mask	fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
+#else
+	__fd_mask	__fds_bits[_howmany(FD_SETSIZE, _NFDBITS)];
+#endif
 } fd_set;
 
-#define	__fdset_mask(n)	((fd_mask)1 << ((n) % _NFDBITS))
+#define	__fdset_mask(n)	((__fd_mask)1 << ((n) % _NFDBITS))
 #define	FD_CLR(n, p)	((p)->fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
 #if __BSD_VISIBLE
-/* XXX bcopy() not in scope, so <strings.h> is required; see also FD_ZERO(). */
-#define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
+#define	FD_COPY(f, t)	(void)(*(t) = *(f))
 #endif
 #define	FD_ISSET(n, p)	((p)->fds_bits[(n)/_NFDBITS] & __fdset_mask(n))
 #define	FD_SET(n, p)	((p)->fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
-#define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
+#define	FD_ZERO(p)	__fd_zero((p), FD_SETSIZE)
+
+static __inline void
+__fd_zero(fd_set *p, __size_t n)
+{
+
+        n = _howmany(n, _NFDBITS);
+        while (n > 0)
+                p->fds_bits[n--] = 0;
+}
 
 #ifndef _KERNEL
 struct timeval;

--tqI+Z3u+9OQ7kwn0--

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?20021111112128.G52940>