From 1b68dd91cf5a3a2642f2bdb09065dc59a884028b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 31 Dec 2005 13:07:43 +0000 Subject: [PATCH] * 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. --- winsup/cygwin/ChangeLog | 12 ++++++++++++ winsup/cygwin/include/cygwin/in.h | 23 +++++++++++----------- winsup/cygwin/include/cygwin/socket.h | 28 ++++++++++++++++++++++----- winsup/cygwin/include/sys/un.h | 6 ++++-- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 51eb4860a..ad8008f50 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2005-12-31 Corinna Vinschen + + * 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 * fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Use diff --git a/winsup/cygwin/include/cygwin/in.h b/winsup/cygwin/include/cygwin/in.h index e2482c820..a932ec6bf 100644 --- a/winsup/cygwin/include/cygwin/in.h +++ b/winsup/cygwin/include/cygwin/in.h @@ -18,9 +18,11 @@ #ifndef _CYGWIN_IN_H #define _CYGWIN_IN_H -#include #include +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 */ diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h index 7597e813e..865c3887a 100644 --- a/winsup/cygwin/include/cygwin/socket.h +++ b/winsup/cygwin/include/cygwin/socket.h @@ -15,11 +15,33 @@ details. */ extern "C" { #endif /* __cplusplus */ +#include + +#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 /* arch-dependent defines */ #include /* the SIOCxxx I/O controls */ #include /* 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 */ diff --git a/winsup/cygwin/include/sys/un.h b/winsup/cygwin/include/sys/un.h index 4e3eee82b..2bd107d50 100644 --- a/winsup/cygwin/include/sys/un.h +++ b/winsup/cygwin/include/sys/un.h @@ -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 + /* 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 */ };