[Xorg-commit] xc/include Xpoll.h,1.1.4.1.2.1,1.1.4.1.2.2

Alexander Gottwald xorg-commit at pdx.freedesktop.org
Wed May 9 17:30:30 EEST 2007


Committed by: ago

Update of /cvs/xorg/xc/include
In directory pdx:/tmp/cvs-serv6877

Modified Files:
      Tag: CYGWIN
	Xpoll.h 
Log Message:
- replace int i; with int __i__; in all XFD_*SET macros
- use howmany(x,y) instead of FD_SETSIZE in XFD_ANYSET. this will work on
  64bit machines too.
- add comment to the XFD_ANYSET macro


Index: Xpoll.h
===================================================================
RCS file: /cvs/xorg/xc/include/Xpoll.h,v
retrieving revision 1.1.4.1.2.1
retrieving revision 1.1.4.1.2.2
diff -u -d -r1.1.4.1.2.1 -r1.1.4.1.2.2
--- Xpoll.h	3 Feb 2004 17:29:50 -0000	1.1.4.1.2.1
+++ Xpoll.h	3 Feb 2004 20:46:02 -0000	1.1.4.1.2.2
@@ -117,35 +117,40 @@
 #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
 #endif
 
+/*
+ * The howmany(FD_SETSIZE, NFDBITS) computes the number of elements in the
+ * array. before accessing an element in the array we check it exists.
+ * If it does not exist then the compiler discards the code to access it. 
+ */
 #define XFD_ANYSET(p) \
-        ((FD_SETSIZE > 0 && (p)->fds_bits[0]) || \
-        (FD_SETSIZE > 32 && (p)->fds_bits[1]) || \
-        (FD_SETSIZE > 64 && (p)->fds_bits[2]) || \
-        (FD_SETSIZE > 96 && (p)->fds_bits[3]) || \
-        (FD_SETSIZE > 128 && (p)->fds_bits[4]) || \
-        (FD_SETSIZE > 160 && (p)->fds_bits[5]) || \
-        (FD_SETSIZE > 192 && (p)->fds_bits[6]) || \
-        (FD_SETSIZE > 224 && (p)->fds_bits[7]))
+        ((howmany(FD_SETSIZE, NFDBITS) > 0 && (p)->fds_bits[0]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 1 && (p)->fds_bits[1]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 2 && (p)->fds_bits[2]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 3 && (p)->fds_bits[3]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 4 && (p)->fds_bits[4]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 5 && (p)->fds_bits[5]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 6 && (p)->fds_bits[6]) || \
+        (howmany(FD_SETSIZE, NFDBITS) > 7 && (p)->fds_bits[7]))
 
 #define XFD_COPYSET(src,dst) { \
-        int i; \
-		for (i = 0; i < howmany(FD_SETSIZE, NFDBITS); i++) \
-            (dst)->fds_bits[i] = (src)->fds_bits[i]; \
+        int __i__; \
+		for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
+            (dst)->fds_bits[__i__] = (src)->fds_bits[__i__]; \
         }
 #define XFD_ANDSET(dst,b1,b2) { \
-        int i; \
-        for (i = 0; i < howmany(FD_SETSIZE, NFDBITS); i++) \
-            (dst)->fds_bits[i] = ((b1)->fds_bits[i] & (b2)->fds_bits[i]); \
+        int __i__; \
+        for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
+            (dst)->fds_bits[__i__] = ((b1)->fds_bits[__i__] & (b2)->fds_bits[__i__]); \
         }
 #define XFD_ORSET(dst,b1,b2) { \
-        int i; \
-        for (i = 0; i < howmany(FD_SETSIZE, NFDBITS); i++) \
-		    (dst)->fds_bits[i] = ((b1)->fds_bits[i] | (b2)->fds_bits[i]); \
+        int __i__; \
+        for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
+		    (dst)->fds_bits[__i__] = ((b1)->fds_bits[__i__] | (b2)->fds_bits[__i__]); \
         }        
 #define XFD_UNSET(dst,b1) { \
-        int i; \
-        for (i = 0; i < howmany(FD_SETSIZE, NFDBITS); i++) \
-		(dst)->fds_bits[i] &= ~((b1)->fds_bits[i]); \
+        int __i__; \
+        for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \
+    		(dst)->fds_bits[__i__] &= ~((b1)->fds_bits[__i__]); \
         }
 
 #else /* USE_POLL */





More information about the xorg-commit mailing list