diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-30 21:32:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-30 21:32:10 +0000 |
commit | 3415075bda4992dcef7ea51e29126b4a6b2f001c (patch) | |
tree | 80018eff689be498766c83870bcf161095837c7a /src | |
parent | 77c03065a39f869a188b4e2e8cd6a88dc7a02fc8 (diff) | |
download | gnunet-3415075bda4992dcef7ea51e29126b4a6b2f001c.tar.gz gnunet-3415075bda4992dcef7ea51e29126b4a6b2f001c.zip |
-improve byteorder macro checks for FreeBSD
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_tun_lib.h | 12 | ||||
-rw-r--r-- | src/util/common_endian.c | 14 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 5bac236d9..f11a3af3e 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h | |||
@@ -70,12 +70,14 @@ struct GNUNET_TUN_Layer2PacketHeader | |||
70 | */ | 70 | */ |
71 | struct GNUNET_TUN_IPv4Header | 71 | struct GNUNET_TUN_IPv4Header |
72 | { | 72 | { |
73 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 73 | #if __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN |
74 | unsigned int header_length:4 GNUNET_PACKED; | 74 | unsigned int header_length:4 GNUNET_PACKED; |
75 | unsigned int version:4 GNUNET_PACKED; | 75 | unsigned int version:4 GNUNET_PACKED; |
76 | #elif __BYTE_ORDER == __BIG_ENDIAN | 76 | #elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN |
77 | unsigned int version:4 GNUNET_PACKED; | 77 | unsigned int version:4 GNUNET_PACKED; |
78 | unsigned int header_length:4 GNUNET_PACKED; | 78 | unsigned int header_length:4 GNUNET_PACKED; |
79 | #else | ||
80 | #error byteorder undefined | ||
79 | #endif | 81 | #endif |
80 | uint8_t diff_serv; | 82 | uint8_t diff_serv; |
81 | 83 | ||
@@ -125,15 +127,17 @@ struct GNUNET_TUN_IPv4Header | |||
125 | */ | 127 | */ |
126 | struct GNUNET_TUN_IPv6Header | 128 | struct GNUNET_TUN_IPv6Header |
127 | { | 129 | { |
128 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 130 | #if __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN |
129 | unsigned int traffic_class_h:4 GNUNET_PACKED; | 131 | unsigned int traffic_class_h:4 GNUNET_PACKED; |
130 | unsigned int version:4 GNUNET_PACKED; | 132 | unsigned int version:4 GNUNET_PACKED; |
131 | unsigned int traffic_class_l:4 GNUNET_PACKED; | 133 | unsigned int traffic_class_l:4 GNUNET_PACKED; |
132 | unsigned int flow_label:20 GNUNET_PACKED; | 134 | unsigned int flow_label:20 GNUNET_PACKED; |
133 | #elif __BYTE_ORDER == __BIG_ENDIAN | 135 | #elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN |
134 | unsigned int version:4 GNUNET_PACKED; | 136 | unsigned int version:4 GNUNET_PACKED; |
135 | unsigned int traffic_class:8 GNUNET_PACKED; | 137 | unsigned int traffic_class:8 GNUNET_PACKED; |
136 | unsigned int flow_label:20 GNUNET_PACKED; | 138 | unsigned int flow_label:20 GNUNET_PACKED; |
139 | #else | ||
140 | #error byteorder undefined | ||
137 | #endif | 141 | #endif |
138 | /** | 142 | /** |
139 | * Length of the payload, excluding this header. | 143 | * Length of the payload, excluding this header. |
diff --git a/src/util/common_endian.c b/src/util/common_endian.c index 56aa7b0c4..1867ba01d 100644 --- a/src/util/common_endian.c +++ b/src/util/common_endian.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other contributing authors) | 3 | (C) 2001, 2002, 2003, 2004, 2006, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -32,20 +32,24 @@ | |||
32 | uint64_t | 32 | uint64_t |
33 | GNUNET_ntohll (uint64_t n) | 33 | GNUNET_ntohll (uint64_t n) |
34 | { | 34 | { |
35 | #if __BYTE_ORDER == __BIG_ENDIAN | 35 | #if __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN |
36 | return n; | 36 | return n; |
37 | #else | 37 | #elif __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN |
38 | return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32); | 38 | return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32); |
39 | #else | ||
40 | #error byteorder undefined | ||
39 | #endif | 41 | #endif |
40 | } | 42 | } |
41 | 43 | ||
42 | uint64_t | 44 | uint64_t |
43 | GNUNET_htonll (uint64_t n) | 45 | GNUNET_htonll (uint64_t n) |
44 | { | 46 | { |
45 | #if __BYTE_ORDER == __BIG_ENDIAN | 47 | #if __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN |
46 | return n; | 48 | return n; |
47 | #else | 49 | #elif __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN |
48 | return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32); | 50 | return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32); |
51 | #else | ||
52 | #error byteorder undefined | ||
49 | #endif | 53 | #endif |
50 | } | 54 | } |
51 | 55 | ||