@@ -157,82 +157,82 @@ inline bool read_obj(T& obj, const void*& pBuf, uint& buf_size, bool buffer_is_l
157
157
}
158
158
159
159
#if defined(_MSC_VER)
160
- static CRNLIB_FORCE_INLINE uint16 swap16 (uint16 x) {
160
+ extern CRNLIB_FORCE_INLINE uint16 swap16 (uint16 x) {
161
161
return _byteswap_ushort (x);
162
162
}
163
- static CRNLIB_FORCE_INLINE uint32 swap32 (uint32 x) {
163
+ extern CRNLIB_FORCE_INLINE uint32 swap32 (uint32 x) {
164
164
return _byteswap_ulong (x);
165
165
}
166
- static CRNLIB_FORCE_INLINE uint64 swap64 (uint64 x) {
166
+ extern CRNLIB_FORCE_INLINE uint64 swap64 (uint64 x) {
167
167
return _byteswap_uint64 (x);
168
168
}
169
169
#elif defined(__GNUC__)
170
- static CRNLIB_FORCE_INLINE uint16 swap16 (uint16 x) {
170
+ extern CRNLIB_FORCE_INLINE uint16 swap16 (uint16 x) {
171
171
return static_cast <uint16>((x << 8U ) | (x >> 8U ));
172
172
}
173
- static CRNLIB_FORCE_INLINE uint32 swap32 (uint32 x) {
173
+ extern CRNLIB_FORCE_INLINE uint32 swap32 (uint32 x) {
174
174
return __builtin_bswap32 (x);
175
175
}
176
- static CRNLIB_FORCE_INLINE uint64 swap64 (uint64 x) {
176
+ extern CRNLIB_FORCE_INLINE uint64 swap64 (uint64 x) {
177
177
return __builtin_bswap64 (x);
178
178
}
179
179
#else
180
- static CRNLIB_FORCE_INLINE uint16 swap16 (uint16 x) {
180
+ extern CRNLIB_FORCE_INLINE uint16 swap16 (uint16 x) {
181
181
return static_cast <uint16>((x << 8U ) | (x >> 8U ));
182
182
}
183
- static CRNLIB_FORCE_INLINE uint32 swap32 (uint32 x) {
183
+ extern CRNLIB_FORCE_INLINE uint32 swap32 (uint32 x) {
184
184
return ((x << 24U ) | ((x << 8U ) & 0x00FF0000U ) | ((x >> 8U ) & 0x0000FF00U ) | (x >> 24U ));
185
185
}
186
- static CRNLIB_FORCE_INLINE uint64 swap64 (uint64 x) {
186
+ extern CRNLIB_FORCE_INLINE uint64 swap64 (uint64 x) {
187
187
return (static_cast <uint64>(swap32 (static_cast <uint32>(x))) << 32ULL ) | swap32 (static_cast <uint32>(x >> 32U ));
188
188
}
189
189
#endif
190
190
191
191
// Assumes x has been read from memory as a little endian value, converts to native endianness for manipulation.
192
- CRNLIB_FORCE_INLINE uint16 swap_le16_to_native (uint16 x) {
192
+ extern CRNLIB_FORCE_INLINE uint16 swap_le16_to_native (uint16 x) {
193
193
return c_crnlib_little_endian_platform ? x : swap16 (x);
194
194
}
195
- CRNLIB_FORCE_INLINE uint32 swap_le32_to_native (uint32 x) {
195
+ extern CRNLIB_FORCE_INLINE uint32 swap_le32_to_native (uint32 x) {
196
196
return c_crnlib_little_endian_platform ? x : swap32 (x);
197
197
}
198
- CRNLIB_FORCE_INLINE uint64 swap_le64_to_native (uint64 x) {
198
+ extern CRNLIB_FORCE_INLINE uint64 swap_le64_to_native (uint64 x) {
199
199
return c_crnlib_little_endian_platform ? x : swap64 (x);
200
200
}
201
201
202
202
// Assumes x has been read from memory as a big endian value, converts to native endianness for manipulation.
203
- CRNLIB_FORCE_INLINE uint16 swap_be16_to_native (uint16 x) {
203
+ extern CRNLIB_FORCE_INLINE uint16 swap_be16_to_native (uint16 x) {
204
204
return c_crnlib_big_endian_platform ? x : swap16 (x);
205
205
}
206
- CRNLIB_FORCE_INLINE uint32 swap_be32_to_native (uint32 x) {
206
+ extern CRNLIB_FORCE_INLINE uint32 swap_be32_to_native (uint32 x) {
207
207
return c_crnlib_big_endian_platform ? x : swap32 (x);
208
208
}
209
- CRNLIB_FORCE_INLINE uint64 swap_be64_to_native (uint64 x) {
209
+ extern CRNLIB_FORCE_INLINE uint64 swap_be64_to_native (uint64 x) {
210
210
return c_crnlib_big_endian_platform ? x : swap64 (x);
211
211
}
212
212
213
- CRNLIB_FORCE_INLINE uint32 read_le32 (const void * p) {
213
+ extern CRNLIB_FORCE_INLINE uint32 read_le32 (const void * p) {
214
214
return swap_le32_to_native (*static_cast <const uint32*>(p));
215
215
}
216
- CRNLIB_FORCE_INLINE void write_le32 (void * p, uint32 x) {
216
+ extern CRNLIB_FORCE_INLINE void write_le32 (void * p, uint32 x) {
217
217
*static_cast <uint32*>(p) = swap_le32_to_native (x);
218
218
}
219
- CRNLIB_FORCE_INLINE uint64 read_le64 (const void * p) {
219
+ extern CRNLIB_FORCE_INLINE uint64 read_le64 (const void * p) {
220
220
return swap_le64_to_native (*static_cast <const uint64*>(p));
221
221
}
222
- CRNLIB_FORCE_INLINE void write_le64 (void * p, uint64 x) {
222
+ extern CRNLIB_FORCE_INLINE void write_le64 (void * p, uint64 x) {
223
223
*static_cast <uint64*>(p) = swap_le64_to_native (x);
224
224
}
225
225
226
- CRNLIB_FORCE_INLINE uint32 read_be32 (const void * p) {
226
+ extern CRNLIB_FORCE_INLINE uint32 read_be32 (const void * p) {
227
227
return swap_be32_to_native (*static_cast <const uint32*>(p));
228
228
}
229
- CRNLIB_FORCE_INLINE void write_be32 (void * p, uint32 x) {
229
+ extern CRNLIB_FORCE_INLINE void write_be32 (void * p, uint32 x) {
230
230
*static_cast <uint32*>(p) = swap_be32_to_native (x);
231
231
}
232
- CRNLIB_FORCE_INLINE uint64 read_be64 (const void * p) {
232
+ extern CRNLIB_FORCE_INLINE uint64 read_be64 (const void * p) {
233
233
return swap_be64_to_native (*static_cast <const uint64*>(p));
234
234
}
235
- CRNLIB_FORCE_INLINE void write_be64 (void * p, uint64 x) {
235
+ extern CRNLIB_FORCE_INLINE void write_be64 (void * p, uint64 x) {
236
236
*static_cast <uint64*>(p) = swap_be64_to_native (x);
237
237
}
238
238
0 commit comments