[comp.windows.x] Small problem with lib/Xt/fd.h and 4.3BSD + FIX

casey@lll-crg.llnl.gov (Casey Leedom) (01/05/89)

  I haven't seen this mentioned before, so I'll post it.  The problem
occurred on a VAX 785 running 4.3BSD + all BSD patches + 1988 April
networking code.  I've checked the stock 4.3BSD source code and you'd run
into the problem there too.

  Essentially fd.h and <sys/types.h> both define the typedef fd_set.  My
patch uses a test of the defined status of NFDBITS to determine whether
or not fd_set has been typedef'd.  Unfortunately C doesn't provide a
mechanism to test for the existence of typedef's.  I don't like my fix,
but I think it should work on most systems.  Fd_set and NFDBITS came into
existence at the same time.

Casey

-----
*** fd.h-dist	Tue Sep  6 13:29:39 1988
--- fd.h	Wed Jan  4 23:57:44 1989
***************
*** 42,49 ****
--- 42,51 ----
  #define	FD_SETSIZE	256
  #endif
  
+ #ifndef NFDBITS
  typedef long fd_mask;
  #define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
+ #endif
  #ifndef howmany
  #define	howmany(x, y)	(((x)+((y)-1))/(y))
  #endif

swick@ATHENA.MIT.EDU (Ralph R. Swick) (01/05/89)

> Essentially fd.h and <sys/types.h> both define the typedef fd_set.

This was fixed in X11R3 by renaming the type (in lib/Xt/fd.h) used
internally by Xt.

casey@GAUSS.LLNL.GOV (01/05/89)

| From: Ralph R. Swick <swick@ATHENA.MIT.EDU>
| 
| > Essentially fd.h and <sys/types.h> both define the typedef fd_set.
| 
| This was fixed in X11R3 by renaming the type (in lib/Xt/fd.h) used
| internally by Xt.

  I assume that you're talking about the type "Fd_set" which would have
conflicted with the type "fd_set" defined in <sys/types.h>.  However,
that still leaves the problem of the type "fd_mask".  This isn't a
problem on any 4.2BSD based machine because NFDBITS, fs_set, FD_SET,
FD_CLR, etc. were all brought out with 4.3BSD.  "fd_set" was brought out
in a later release of 4.1BSD (I believe release c).  If you like I can
send you the specific versions of types.h for each of the above systems.

  Also, I should point out, my fix really isn't as good as it should be
since the definitions of FD_SET, FD_CRL, FD)ISSET, and FD_ZERO should
also be similarly ifdefed.  I didn't see that till now when I sat down
and looked closely at all the different versions of types.h ...

Casey