delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/05/12/15:18:57

From: newsham AT lava DOT net (Tim Newsham)
Subject: include files
12 May 1998 15:18:57 -0700 :
Message-ID: <m0yZN4r-00117DC.cygnus.cygwin32.developers@malasada.lava.net>
Mime-Version: 1.0
To: cygwin32-developers AT cygnus DOT com

Hi,

    I went over the includes and made some minor additions and some
notes on more major changes.  Here they are.  

General notes:

   - There is both an asm and a machine subdirectory for what seems
     to be the same purpose -- machine/arch dependant definitions.
     Probably should merge these two into a single directory (I noticed
     there are only i386 definitions here, aren't there other cygwin
     ports?)

   - <sys/param.h> should probably include <sys/types.h> (and possibly
     pull in machine specific defines from {machine,asm}/param.h).

   - <sys/types.h> has all sorts of cruft in it that is not relevant
     to cygwin.  Is it necessary to share these includes with other
     systems, or can the cruft be taken out?  Without all the cruft,
     this file can be quite simple.

Specific notes:

   - Windows32/Sockets.h does not have all of the winsock definitions
     that are defined.  For example the setsockopt options are missing.
     Here are some missing defines:

+/* socket options for {set,get}sockopt() */
+#define SO_DEBUG               0x0001
+#define SO_ACCEPTCONN          0x0002
+#define SO_REUSEADDR           0x0004
+#define SO_KEEPALIVE           0x0008
+#define SO_DONTROUTE           0x0010
+#define SO_BROADCAST           0x0020
+#define SO_USELOOPBACK         0x0040
+#define SO_LINGER              0x0080
+#define SO_OOBINLINE           0x0100
+
+#define SO_DONTLINGER          (u_int)(~SO_LINGER)
+
+#define SO_SNDBUF              0x1001
+#define SO_RCVBUF              0x1002
+#define SO_SNDLOWAT            0x1003  /* unsup */
+#define SO_RCVLOWAT            0x1004  /* unsup */
+#define SO_SNDTIMEO            0x1005  /* unsup */
+#define SO_RCVTIMEO            0x1006  /* unsup */
+#define SO_ERROR               0x1007
+#define SO_TYPE                        0x1008

   - several machine-dependant types are not defined,  probably should
     go in {asm,machine}/types.h and be included by sys/types.h.  These
     are (possibly not all necessary):

+typedef unsigned long vm_offset_t;
+typedef unsigned long vm_size_t;
+
+#define __BIT_TYPES_DEFINED__
+typedef char                   int8_t;
+typedef unsigned char          u_int8_t;
+typedef short                  int16_t;
+typedef unsigned short         u_int16_t;
+typedef int                    int32_t;
+typedef unsinged int           u_int32_t;
+typedef long long              int64_t;
+typedef unsigned long long     u_int64_t;
+
+typedef int32_t                register_t;

   - some common sys/cdefs.h macros are missing:

+#define __P(x)         x
+#define __CONCAT(x,y)  x ## y
+#define __STRING(x)    #x
+
+/* XXX __{const,volatile,etc..} ? */


   - sys/param.h does not define NULL, does not define a cygwin version,
     does not define NOFILE_MAX.  It doesn't include <sys/signal.h> as
     is often done (why? dunno).  It doesn't define several common macros.
     It does define some endian things which should probably be in a
     {asm,machine}/endian.h file and included from <sys/types.h> instead
     (with <sys/types.h> included by <sys/param.h>)

+#include <machine/param.h>
+#include <sys/types.h>
+
+#define CYGWIN         199804
+#define CYGWINb_19     1
+
+#ifndef NULL
+#define NULL 0
+#endif
[...]
+#define NOFILE_MAX     NOFILE
[...]
+#include <sys/signal.h>
+
+/* bitmap macros */
+#define setbit(a,i)    ((a)[(i)/NBBY] |= 1 << ((i) % NBBY))
+#define clrbit(a,i)    ((a)[(i)/NBBY] ^= ~(1 << ((i) % NBBY)))
+#define isset(a,i)     ((a)[(i)/NBBY] & (1 << ((i) % NBBY)))
+#define isclr(a,i)     (((a)[(i)/NBBY] & (1 << ((i) % NBBY))) == 0)
+
+#ifndef howmany
+#define howmany(x,y)   (((x) + ((y) - 1)) / (y))
+#endif
+#define roundup(x,y)   ((((x) + ((y) - 1)) / (y)) * (y))
+#define powerof2(x)    ((((x) - 1) & (x)) == 0)
+
+#define MIN(a,b)       (((a) < (b)) ? (a) : (b))
+#define MAX(a,b)       (((a) > (b)) ? (a) : (b))

   - sys/time.h does not define the POSIX timespec structure or operations
     on it, and does not define the CLOCK_{RELTIME,VIRTUAL,PROF} constants.
     It is also missing some common timeval macros:

 +/* timeval operations */
+#define timerclear(tvp)                (tvp)->tv_sec = 0; (tvp)->tv_usec = 0
+#define timerisset(tvp)                ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp)                        \
+       (((tvp)->tv_sec == (uvp)->tv_sec) ?     \
+         ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+         ((tvp)->tv_sec cmp (uvp->tv_sec))
+#define timeradd(tvp, uvp, vvp)                                        \
+       do {                                                    \
+         (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;        \
+         (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;     \
+         if((vvp)->tv_usec >= 1000000) {                       \
+           (vvp)->tv_sec ++;                                   \
+           (vvp)->tv_usec -= 1000000;                          \
+         }                                                     \
+       } while(0)
+#define timersub(tvp, uvp, vvp)                                        \
+       do {
+         (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;        \
+         (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;     \
+         if((vvp)->tv_usec < 0) {                              \
+           (vvp)->tv_sec --;                                   \
+           (vvp)->tv_usec += 1000000;                          \
+         }                                                     \
+       } while(0)


   - sys/types is missing the "unchar" and "ulong" definitions in
     the System V compatibility section.  It also does not have
     U_quad_t,quad_t and quaddr_t definitions:

+typedef unsigned char  unchar;         /* System V compatibility */
+typedef unsigned long  ulong;          /* System V compatibility */
+/* XXX these were outside of !POSIX in BSD - is this right? */
+typedef u_int64_t      u_quad_t;
+typedef int64_t                quad_t;
+typedef quad_t *       quaddr_t;


This is just a start, but it makes a big difference.  After these few
changes most software I compile will compile clean except for some network
definitions (which I will attack next).

                                          Tim N.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019