* include/endian.h: Move definitions of __BIG_ENDIAN, __LITTLE_ENDIAN,

and __BYTE_ORDER into ...
	* include/bits/endian.h: New file.
	* include/arpa/nameser_compat.h: Include endian.h rather than defining
	BYTE_ORDER here.
	* include/asm/byteorder.h: Include bits/endian.h.  Drop definition of
	__LITTLE_ENDIAN.
	* include/netinet/ip.h: Include bits/endian.h.  Drop definitions of
	BIG_ENDIAN, LITTLE_ENDIAN, and BYTE_ORDER.  Use underscored variants
	of aforementioned constants.
	* include/netinet/tcp.h: Ditto.
	* include/sys/param.h: Drop disabled definitions of BIG_ENDIAN,
	LITTLE_ENDIAN, and BYTE_ORDER.

	* include/netinet/ip.h: Reformat.  Define setsockopt IP_TOS options
	matching recent RFCs.  Tweak comments.
This commit is contained in:
Corinna Vinschen 2011-02-11 12:42:30 +00:00
parent 96b998db51
commit 7be671075d
8 changed files with 199 additions and 180 deletions

View File

@ -1,3 +1,22 @@
2011-02-11 Corinna Vinschen <corinna@vinschen.de>
* include/endian.h: Move definitions of __BIG_ENDIAN, __LITTLE_ENDIAN,
and __BYTE_ORDER into ...
* include/bits/endian.h: New file.
* include/arpa/nameser_compat.h: Include endian.h rather than defining
BYTE_ORDER here.
* include/asm/byteorder.h: Include bits/endian.h. Drop definition of
__LITTLE_ENDIAN.
* include/netinet/ip.h: Include bits/endian.h. Drop definitions of
BIG_ENDIAN, LITTLE_ENDIAN, and BYTE_ORDER. Use underscored variants
of aforementioned constants.
* include/netinet/tcp.h: Ditto.
* include/sys/param.h: Drop disabled definitions of BIG_ENDIAN,
LITTLE_ENDIAN, and BYTE_ORDER.
* include/netinet/ip.h: Reformat. Define setsockopt IP_TOS options
matching recent RFCs. Tweak comments.
2011-02-10 Eric Blake <eblake@redhat.com>
* errno.cc (includes): Avoid compilation failure if <string.h>

View File

@ -40,50 +40,7 @@
#define __BIND 19950621 /* (DEAD) interface version stamp. */
#ifndef BYTE_ORDER
#if (BSD >= 199103)
# include <machine/endian.h>
#else
#ifdef linux
# include <endian.h>
#else
#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
defined(__alpha__) || defined(__alpha) || \
(defined(__Lynx__) && defined(__x86__))
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
defined(__hppa) || defined(__hp9000) || \
defined(__hp9000s300) || defined(__hp9000s700) || \
defined(__hp3000s900) || defined(MPE) || \
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || \
(defined(__Lynx__) && \
(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif /* linux */
#endif /* BSD */
#endif /* BYTE_ORDER */
#if !defined(BYTE_ORDER) || \
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
BYTE_ORDER != PDP_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
error "Undefined or invalid BYTE_ORDER";
#endif
#include <endian.h>
/*
* Structure for query header. The order of the fields is machine- and

View File

@ -1,6 +1,6 @@
/* asm/byteorder.h
Copyright 1996, 1998, 2001, 2006, 2009 Red Hat, Inc.
Copyright 1996, 1998, 2001, 2006, 2009, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -13,15 +13,12 @@ details. */
#include <_ansi.h>
#include <stdint.h>
#include <bits/endian.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __LITTLE_ENDIAN_BITFIELD
#define __LITTLE_ENDIAN_BITFIELD
#endif

View File

@ -0,0 +1,25 @@
/* bits/endian.h
Copyright 2011 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _BITS_ENDIAN_H_
#define _BITS_ENDIAN_H_
#ifndef __BIG_ENDIAN
# define __BIG_ENDIAN 4321
#endif
#ifndef __LITTLE_ENDIAN
# define __LITTLE_ENDIAN 1234
#endif
#ifndef __BYTE_ORDER
# define __BYTE_ORDER __LITTLE_ENDIAN
#endif
#endif /* _BITS_ENDIAN_H_ */

View File

@ -1,6 +1,6 @@
/* endian.h
Copyright 2005, 2010 Red Hat, Inc.
Copyright 2005, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin.
@ -12,17 +12,7 @@ details. */
#define _ENDIAN_H_
#include <sys/config.h>
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
#endif
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __BYTE_ORDER
# define __BYTE_ORDER __LITTLE_ENDIAN
#endif
#include <bits/endian.h>
/*#ifdef __USE_BSD*/
# define LITTLE_ENDIAN __LITTLE_ENDIAN

View File

@ -39,15 +39,7 @@
#include <netinet/in_systm.h>
#include <netinet/in.h>
/* Added by Wu Yongwei */
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#endif
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#include <bits/endian.h>
/*
* Definitions for internet protocol version 4.
@ -62,11 +54,11 @@ struct ip {
#ifdef _IP_VHL
u_char ip_vhl; /* version << 4 | header length >> 2 */
#else
#if BYTE_ORDER == LITTLE_ENDIAN
#if __BYTE_ORDER == __LITTLE_ENDIAN
u_int ip_hl:4, /* header length */
ip_v:4; /* version */
#endif
#if BYTE_ORDER == BIG_ENDIAN
#if __BYTE_ORDER == __BIG_ENDIAN
u_int ip_v:4, /* version */
ip_hl:4; /* header length */
#endif
@ -95,7 +87,66 @@ struct ip {
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
* Definitions for IP type of service (ip_tos)
* Definitions for DiffServ Codepoints as per RFC2474
*/
#define IPTOS_DSCP_CS0 0x00
#define IPTOS_DSCP_CS1 0x20
#define IPTOS_DSCP_AF11 0x28
#define IPTOS_DSCP_AF12 0x30
#define IPTOS_DSCP_AF13 0x38
#define IPTOS_DSCP_CS2 0x40
#define IPTOS_DSCP_AF21 0x48
#define IPTOS_DSCP_AF22 0x50
#define IPTOS_DSCP_AF23 0x58
#define IPTOS_DSCP_CS3 0x60
#define IPTOS_DSCP_AF31 0x68
#define IPTOS_DSCP_AF32 0x70
#define IPTOS_DSCP_AF33 0x78
#define IPTOS_DSCP_CS4 0x80
#define IPTOS_DSCP_AF41 0x88
#define IPTOS_DSCP_AF42 0x90
#define IPTOS_DSCP_AF43 0x98
#define IPTOS_DSCP_CS5 0xa0
#define IPTOS_DSCP_EF 0xb8
#define IPTOS_DSCP_CS6 0xc0
#define IPTOS_DSCP_CS7 0xe0
/*
* Definitions for DiffServ Class Selector Codepoints as defined by Linux.
* Linux uses different names than OpenBSD, unfortunately.
*/
#define IPTOS_CLASS_CS0 0x00
#define IPTOS_CLASS_CS1 0x20
#define IPTOS_CLASS_CS2 0x40
#define IPTOS_CLASS_CS3 0x60
#define IPTOS_CLASS_CS4 0x80
#define IPTOS_CLASS_CS5 0xa0
#define IPTOS_CLASS_CS6 0xc0
#define IPTOS_CLASS_CS7 0xe0
#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
/* Linux also defined masks and access macros. */
#define IPTOS_CLASS_MASK 0xe0
#define IPTOS_CLASS(cs) ((cs) & IPTOS_CLASS_MASK)
#define IPTOS_DSCP_MASK 0xfc
#define IPTOS_DSCP(cp) ((cp) & IPTOS_DSCP_MASK)
/*
* ECN (Explicit Congestion Notification) codepoints in RFC3168
* mapped to the lower 2 bits of the TOS field.
*/
#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */
#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */
#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */
#define IPTOS_ECN_CE 0x03 /* congestion experienced */
#define IPTOS_ECN_MASK 0x03 /* ECN field mask */
/* Linux also defined an access macro.
* The name of IPTOS_ECN_NOTECT differs, too, unfortunately. */
#define IPTOS_ECN(cn) ((cn) & IPTOS_ECN_MASK)
#define IPTOS_ECN_NOT_ECT 0x00
/*
* Definitions for IP type of service per RFC1349 (ip_tos)
* DEPRECATED
*/
#ifndef IPTOS_LOWDELAY
#define IPTOS_LOWDELAY 0x10
@ -103,13 +154,12 @@ struct ip {
#define IPTOS_RELIABILITY 0x04
#endif
#define IPTOS_MINCOST 0x02
/* ECN bits proposed by Sally Floyd */
/* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */
#define IPTOS_CE 0x01 /* congestion experienced */
#define IPTOS_ECT 0x02 /* ECN-capable transport */
/*
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
* Definitions for IP precedence per RFC1195 (also in ip_tos) (hopefully unused)
*/
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
@ -120,6 +170,7 @@ struct ip {
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/*
* Definitions for options.
*/
@ -158,11 +209,11 @@ struct ip_timestamp {
u_char ipt_code; /* IPOPT_TS */
u_char ipt_len; /* size of structure (variable) */
u_char ipt_ptr; /* index of current entry */
#if BYTE_ORDER == LITTLE_ENDIAN
#if __BYTE_ORDER == __LITTLE_ENDIAN
u_int ipt_flg:4, /* flags, see below */
ipt_oflw:4; /* overflow counter */
#endif
#if BYTE_ORDER == BIG_ENDIAN
#if __BYTE_ORDER == __BIG_ENDIAN
u_int ipt_oflw:4, /* overflow counter */
ipt_flg:4; /* flags, see below */
#endif

View File

@ -37,14 +37,7 @@
#ifndef _NETINET_TCP_H
#define _NETINET_TCP_H
/* Added by Wu Yongwei */
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#endif
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#include <bits/endian.h>
typedef u_int32_t tcp_seq;
typedef u_int32_t tcp_cc; /* connection count per rfc1644 */
@ -61,11 +54,11 @@ struct tcphdr {
u_short th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
#if BYTE_ORDER == LITTLE_ENDIAN
#if __BYTE_ORDER == __LITTLE_ENDIAN
u_int th_x2:4, /* (unused) */
th_off:4; /* data offset */
#endif
#if BYTE_ORDER == BIG_ENDIAN
#if __BYTE_ORDER == __BIG_ENDIAN
u_int th_off:4, /* data offset */
th_x2:4; /* (unused) */
#endif

View File

@ -1,6 +1,6 @@
/* sys/param.h
Copyright 2001, 2003, 2007 Red Hat, Inc.
Copyright 2001, 2003, 2007,2 2011 Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
@ -37,19 +37,6 @@
BSD variant of this constant. */
#define DEV_BSIZE 1024
#if 0 /* defined in endian.h */
/* Some autoconf'd packages check for endianness. When cross-building we
can't run programs on the target. Fortunately, autoconf supports the
definition of byte order in sys/param.h (that's us!).
The values here are the same as used in gdb/defs.h (are the more
appropriate values?). */
#define BIG_ENDIAN 4321
#define LITTLE_ENDIAN 1234
/* All known win32 systems are little endian. */
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#ifndef NULL
#define NULL 0L
#endif