OSDN Git Service

* include/cygwin/in.h: Drop including stdint.h. Move definition
authorcorinna <corinna>
Sat, 31 Dec 2005 13:07:42 +0000 (13:07 +0000)
committercorinna <corinna>
Sat, 31 Dec 2005 13:07:42 +0000 (13:07 +0000)
of in_port_t and in_addr_t to top of file and use throughout. Use
sa_family_t type where appropriate.
(struct in6_addr): Change `unsigned char' to `uint8_t'.
(struct sockaddr_in6): Add sin6_scope_id member. Add comments.
* include/cygwin/socket.h: Include stdint.h.  Move definition of
socklen_t to top of file.  Define sa_family_t.  Define struct
sockaddr_storage as per SUSv3.
* include/sys/un.h: Include cygwin/socket.h.  Use sa_family_t type.

winsup/cygwin/ChangeLog
winsup/cygwin/include/cygwin/in.h
winsup/cygwin/include/cygwin/socket.h
winsup/cygwin/include/sys/un.h

index 51eb486..ad8008f 100644 (file)
@@ -1,3 +1,15 @@
+2005-12-31  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/in.h: Drop including stdint.h.  Move definition
+       of in_port_t and in_addr_t to top of file and use throughout. Use
+       sa_family_t type where appropriate.
+       (struct in6_addr): Change `unsigned char' to `uint8_t'.
+       (struct sockaddr_in6): Add sin6_scope_id member. Add comments.
+       * include/cygwin/socket.h: Include stdint.h.  Move definition of
+       socklen_t to top of file.  Define sa_family_t.  Define struct
+       sockaddr_storage as per SUSv3.
+       * include/sys/un.h: Include cygwin/socket.h.  Use sa_family_t type.
+
 2005-12-29  Christopher Faylor  <cgf@timesys.com>
 
        * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Use
index e2482c8..a932ec6 100644 (file)
 #ifndef _CYGWIN_IN_H
 #define _CYGWIN_IN_H
 
-#include <stdint.h>
 #include <cygwin/socket.h>
 
+typedef uint16_t in_port_t;
+typedef uint32_t in_addr_t;
+
 /* Standard well-defined IP protocols.  If you ever add one here, don't
    forget to define it below. */
 enum
@@ -50,7 +52,6 @@ enum
 #define IPPROTO_IDP IPPROTO_IDP
 #define IPPROTO_RAW IPPROTO_RAW
 
-typedef uint16_t in_port_t;
 /* Standard well-known ports.  *//* from winsup/include/netinet/in.h */
 enum
 {
@@ -91,11 +92,10 @@ enum
   IPPORT_USERRESERVED = 5000
 };
 
-typedef uint32_t in_addr_t;
 /* Internet address. */
 struct in_addr
 {
-  unsigned int s_addr;
+  in_addr_t s_addr;
 };
 
 /* Request struct for multicast socket ops */
@@ -111,8 +111,8 @@ struct ip_mreq
 #define __SOCK_SIZE__  16              /* sizeof(struct sockaddr)      */
 struct sockaddr_in
 {
-  short int sin_family;        /* Address family               */
-  unsigned short int sin_port; /* Port number                  */
+  sa_family_t   sin_family;    /* Address family               */
+  in_port_t     sin_port;      /* Port number                  */
   struct in_addr sin_addr;     /* Internet address             */
 
   /* Pad to size of `struct sockaddr'. */
@@ -190,15 +190,16 @@ struct sockaddr_in
    a beginning dont get excited 8) */
 struct in6_addr
 {
-  unsigned char s6_addr[16];
+  uint8_t        s6_addr[16];
 };
 
 struct sockaddr_in6
 {
-  unsigned short sin6_family;
-  unsigned short sin6_port;
-  unsigned long sin6_flowinfo;
-  struct in6_addr sin6_addr;
+  sa_family_t    sin6_family;          /* AF_INET6 */
+  in_port_t      sin6_port;            /* Port number. */
+  uint32_t       sin6_flowinfo;        /* Traffic class and flow inf. */
+  struct in6_addr sin6_addr;           /* IPv6 address. */
+  uint32_t       sin6_scope_id;        /* Set of interfaces for a scope. */
 };
 #endif
 #endif /* _CYGWIN_IN_H */
index 7597e81..865c388 100644 (file)
@@ -15,11 +15,33 @@ details. */
 extern "C" {
 #endif /* __cplusplus */
 
+#include <stdint.h>
+
+#ifndef socklen_t
+#define socklen_t int                  /* Not unsigned for backward compat. */
+#endif
+
+typedef uint16_t sa_family_t;
+
 struct sockaddr {
-  unsigned short       sa_family;      /* address family, AF_xxx       */
+  sa_family_t          sa_family;      /* address family, AF_xxx       */
   char                 sa_data[14];    /* 14 bytes of protocol address */
 };
 
+/* Definition of sockaddr_storage according to SUSv3. */
+#define _SS_MAXSIZE 128                        /* Maximum size. */
+#define _SS_ALIGNSIZE (sizeof (int64_t))/* Desired alignment. */
+#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t))
+#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t) \
+                     + _SS_PAD1SIZE + _SS_ALIGNSIZE))
+
+struct sockaddr_storage {
+  sa_family_t          ss_familiy;
+  char                 _ss_pad1[_SS_PAD1SIZE];
+  int64_t              __ss_align;
+  char                 _ss_pad2[_SS_PAD2SIZE];
+};
+
 #include <asm/socket.h>                        /* arch-dependent defines       */
 #include <cygwin/sockios.h>            /* the SIOCxxx I/O controls     */
 #include <cygwin/uio.h>                        /* iovec support                */
@@ -36,10 +58,6 @@ struct linger {
   unsigned short       l_linger;       /* How long to linger for       */
 };
 
-#ifndef socklen_t
-#define socklen_t int
-#endif
-
 struct msghdr
 {
   void *               msg_name;       /* Socket name                  */
index 4e3eee8..2bd107d 100644 (file)
@@ -1,6 +1,6 @@
 /* sys/un.h
 
-   Copyright 1999, 2001 Red Hat, Inc.
+   Copyright 1999, 2001, 2005 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -11,11 +11,13 @@ details. */
 #ifndef _SYS_UN_H
 #define _SYS_UN_H
 
+#include <cygwin/socket.h>
+
 /* POSIX requires only at least 100 bytes */
 #define UNIX_PATH_LEN   108
 
 struct sockaddr_un {
-  unsigned short sun_family;              /* address family AF_LOCAL/AF_UNIX */
+  sa_family_t   sun_family;              /* address family AF_LOCAL/AF_UNIX */
   char          sun_path[UNIX_PATH_LEN]; /* 108 bytes of socket address     */
 };