diff options
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 34 |
1 files changed, 32 insertions, 2 deletions
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. |