diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-21 09:40:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-21 09:40:15 +0000 |
commit | c4f0fe3ea5a5ca3ce1f7dfecef719da631e4c6ac (patch) | |
tree | 02e313a83c4416f07fadf650d33aff09dfe46130 /src/include | |
parent | 40e5092e9a5db88b4c9b62cb341596fbf6ce1cf8 (diff) | |
download | gnunet-c4f0fe3ea5a5ca3ce1f7dfecef719da631e4c6ac.tar.gz gnunet-c4f0fe3ea5a5ca3ce1f7dfecef719da631e4c6ac.zip |
fixing 2012: network structure alignment now forced to be correct even on W32 using #pragma pack from gcc 4.x
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/block_dns.h | 2 | ||||
-rw-r--r-- | src/include/block_fs.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_ats_service.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_bandwidth_lib.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_common.h | 34 | ||||
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_time_lib.h | 3 |
7 files changed, 48 insertions, 7 deletions
diff --git a/src/include/block_dns.h b/src/include/block_dns.h index 1c01754de..21dcc7acb 100644 --- a/src/include/block_dns.h +++ b/src/include/block_dns.h | |||
@@ -13,6 +13,7 @@ enum GNUNET_DNS_ServiceTypes | |||
13 | GNUNET_DNS_SERVICE_TYPE_TCP = 2 | 13 | GNUNET_DNS_SERVICE_TYPE_TCP = 2 |
14 | }; | 14 | }; |
15 | 15 | ||
16 | GNUNET_NETWORK_STRUCT_BEGIN | ||
16 | 17 | ||
17 | /** | 18 | /** |
18 | * This is the structure describing an dns-record such as www.gnunet. | 19 | * This is the structure describing an dns-record such as www.gnunet. |
@@ -57,5 +58,6 @@ struct GNUNET_DNS_Record | |||
57 | */ | 58 | */ |
58 | uint32_t service_type GNUNET_PACKED; | 59 | uint32_t service_type GNUNET_PACKED; |
59 | }; | 60 | }; |
61 | GNUNET_NETWORK_STRUCT_END | ||
60 | 62 | ||
61 | #endif | 63 | #endif |
diff --git a/src/include/block_fs.h b/src/include/block_fs.h index 9dc22e57f..aae741e60 100644 --- a/src/include/block_fs.h +++ b/src/include/block_fs.h | |||
@@ -139,6 +139,8 @@ struct NBlock | |||
139 | }; | 139 | }; |
140 | 140 | ||
141 | 141 | ||
142 | GNUNET_NETWORK_STRUCT_BEGIN | ||
143 | |||
142 | /** | 144 | /** |
143 | * @brief index block (indexing a DBlock that | 145 | * @brief index block (indexing a DBlock that |
144 | * can be obtained directly from reading | 146 | * can be obtained directly from reading |
@@ -160,6 +162,6 @@ struct OnDemandBlock | |||
160 | uint64_t offset GNUNET_PACKED; | 162 | uint64_t offset GNUNET_PACKED; |
161 | 163 | ||
162 | }; | 164 | }; |
163 | 165 | GNUNET_NETWORK_STRUCT_END | |
164 | 166 | ||
165 | #endif | 167 | #endif |
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 898857af8..88cab0d9b 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h | |||
@@ -403,6 +403,8 @@ enum GNUNET_ATS_Property | |||
403 | }; | 403 | }; |
404 | 404 | ||
405 | 405 | ||
406 | GNUNET_NETWORK_STRUCT_BEGIN | ||
407 | |||
406 | /** | 408 | /** |
407 | * struct used to communicate the transport's properties like cost and | 409 | * struct used to communicate the transport's properties like cost and |
408 | * quality of service as well as high-level constraints on resource | 410 | * quality of service as well as high-level constraints on resource |
@@ -433,7 +435,7 @@ struct GNUNET_ATS_Information | |||
433 | */ | 435 | */ |
434 | uint32_t value GNUNET_PACKED; | 436 | uint32_t value GNUNET_PACKED; |
435 | }; | 437 | }; |
436 | 438 | GNUNET_NETWORK_STRUCT_END | |
437 | 439 | ||
438 | 440 | ||
439 | /* ******************************** Scheduling API ***************************** */ | 441 | /* ******************************** Scheduling API ***************************** */ |
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 75f71b32c..fabe47bea 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -38,6 +38,8 @@ extern "C" | |||
38 | #include "gnunet_common.h" | 38 | #include "gnunet_common.h" |
39 | #include "gnunet_time_lib.h" | 39 | #include "gnunet_time_lib.h" |
40 | 40 | ||
41 | GNUNET_NETWORK_STRUCT_BEGIN | ||
42 | |||
41 | /** | 43 | /** |
42 | * 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. | 44 | * 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. |
43 | */ | 45 | */ |
@@ -48,7 +50,7 @@ struct GNUNET_BANDWIDTH_Value32NBO | |||
48 | */ | 50 | */ |
49 | uint32_t value__ GNUNET_PACKED; | 51 | uint32_t value__ GNUNET_PACKED; |
50 | }; | 52 | }; |
51 | 53 | GNUNET_NETWORK_STRUCT_END | |
52 | 54 | ||
53 | /** | 55 | /** |
54 | * Struct to track available bandwidth. Combines a time stamp with a | 56 | * Struct to track available bandwidth. Combines a time stamp with a |
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 665697a97..134543c46 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -116,9 +116,37 @@ | |||
116 | */ | 116 | */ |
117 | #define GNUNET_UNUSED __attribute__((unused)) | 117 | #define GNUNET_UNUSED __attribute__((unused)) |
118 | 118 | ||
119 | #if __GNUC__ > 3 | ||
120 | /** | ||
121 | * gcc 4.x-ism to pack structures even on W32 (to be used before structs) | ||
122 | */ | ||
123 | #define GNUNET_NETWORK_STRUCT_BEGIN \ | ||
124 | _Pragma("pack(push)") \ | ||
125 | _Pragma("pack(1)") | ||
126 | |||
127 | /** | ||
128 | * gcc 4.x-ism to pack structures even on W32 (to be used after structs) | ||
129 | */ | ||
130 | #define GNUNET_NETWORK_STRUCT_END _Pragma("pack(pop)") | ||
131 | #else | ||
132 | #ifdef MINGW | ||
133 | #error gcc 4.x or higher required on W32 systems | ||
134 | #endif | ||
135 | /** | ||
136 | * Good luck, GNUNET_PACKED should suffice, but this won't work on W32 | ||
137 | */ | ||
138 | #define GNUNET_NETWORK_STRUCT_BEGIN | ||
139 | |||
140 | /** | ||
141 | * Good luck, GNUNET_PACKED should suffice, but this won't work on W32 | ||
142 | */ | ||
143 | #define GNUNET_NETWORK_STRUCT_END | ||
144 | #endif | ||
119 | 145 | ||
120 | /* ************************ super-general types *********************** */ | 146 | /* ************************ super-general types *********************** */ |
121 | 147 | ||
148 | GNUNET_NETWORK_STRUCT_BEGIN | ||
149 | |||
122 | /** | 150 | /** |
123 | * Header for all communications. | 151 | * Header for all communications. |
124 | */ | 152 | */ |
@@ -137,7 +165,7 @@ struct GNUNET_MessageHeader | |||
137 | uint16_t type GNUNET_PACKED; | 165 | uint16_t type GNUNET_PACKED; |
138 | 166 | ||
139 | }; | 167 | }; |
140 | 168 | GNUNET_NETWORK_STRUCT_END | |
141 | 169 | ||
142 | /** | 170 | /** |
143 | * @brief 512-bit hashcode | 171 | * @brief 512-bit hashcode |
@@ -149,6 +177,8 @@ typedef struct | |||
149 | GNUNET_HashCode; | 177 | GNUNET_HashCode; |
150 | 178 | ||
151 | 179 | ||
180 | GNUNET_NETWORK_STRUCT_BEGIN | ||
181 | |||
152 | /** | 182 | /** |
153 | * The identity of the host (basically the SHA-512 hashcode of | 183 | * The identity of the host (basically the SHA-512 hashcode of |
154 | * it's public key). | 184 | * it's public key). |
@@ -157,7 +187,7 @@ struct GNUNET_PeerIdentity | |||
157 | { | 187 | { |
158 | GNUNET_HashCode hashPubKey GNUNET_PACKED; | 188 | GNUNET_HashCode hashPubKey GNUNET_PACKED; |
159 | }; | 189 | }; |
160 | 190 | GNUNET_NETWORK_STRUCT_END | |
161 | 191 | ||
162 | /** | 192 | /** |
163 | * Function called with a filename. | 193 | * Function called with a filename. |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 53137c179..76806d432 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -121,6 +121,8 @@ struct GNUNET_CRYPTO_RsaSignature | |||
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
124 | GNUNET_NETWORK_STRUCT_BEGIN | ||
125 | |||
124 | /** | 126 | /** |
125 | * @brief header of what an RSA signature signs | 127 | * @brief header of what an RSA signature signs |
126 | * this must be followed by "size - 8" bytes of | 128 | * this must be followed by "size - 8" bytes of |
@@ -197,7 +199,7 @@ struct GNUNET_CRYPTO_AesSessionKey | |||
197 | */ | 199 | */ |
198 | uint32_t crc32 GNUNET_PACKED; | 200 | uint32_t crc32 GNUNET_PACKED; |
199 | }; | 201 | }; |
200 | 202 | GNUNET_NETWORK_STRUCT_END | |
201 | 203 | ||
202 | /** | 204 | /** |
203 | * @brief IV for sym cipher | 205 | * @brief IV for sym cipher |
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index f8afdae41..7090c33a1 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -61,6 +61,7 @@ struct GNUNET_TIME_Relative | |||
61 | uint64_t rel_value; | 61 | uint64_t rel_value; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | GNUNET_NETWORK_STRUCT_BEGIN | ||
64 | 65 | ||
65 | /** | 66 | /** |
66 | * Time for relative time used by GNUnet, in milliseconds and in network byte order. | 67 | * Time for relative time used by GNUnet, in milliseconds and in network byte order. |
@@ -84,7 +85,7 @@ struct GNUNET_TIME_AbsoluteNBO | |||
84 | */ | 85 | */ |
85 | uint64_t abs_value__ GNUNET_PACKED; | 86 | uint64_t abs_value__ GNUNET_PACKED; |
86 | }; | 87 | }; |
87 | 88 | GNUNET_NETWORK_STRUCT_END | |
88 | 89 | ||
89 | /** | 90 | /** |
90 | * Relative time zero. | 91 | * Relative time zero. |