diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 9 | ||||
-rw-r--r-- | include/platform.h | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/include/libbb.h b/include/libbb.h index 9ece2f9ec..0ea7700f2 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <termios.h> | 37 | #include <termios.h> |
38 | #include <time.h> | 38 | #include <time.h> |
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | /* Try to pull in PATH_MAX */ | ||
41 | #include <limits.h> | ||
42 | #include <sys/param.h> | 40 | #include <sys/param.h> |
43 | #ifdef HAVE_MNTENT_H | 41 | #ifdef HAVE_MNTENT_H |
44 | # include <mntent.h> | 42 | # include <mntent.h> |
@@ -265,6 +263,11 @@ extern int *const bb_errno; | |||
265 | #define errno (*bb_errno) | 263 | #define errno (*bb_errno) |
266 | #endif | 264 | #endif |
267 | 265 | ||
266 | #if !(ULONG_MAX > 0xffffffff) | ||
267 | /* Only 32-bit CPUs need this, 64-bit ones use inlined version */ | ||
268 | uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; | ||
269 | #endif | ||
270 | |||
268 | unsigned long long monotonic_ns(void) FAST_FUNC; | 271 | unsigned long long monotonic_ns(void) FAST_FUNC; |
269 | unsigned long long monotonic_us(void) FAST_FUNC; | 272 | unsigned long long monotonic_us(void) FAST_FUNC; |
270 | unsigned long long monotonic_ms(void) FAST_FUNC; | 273 | unsigned long long monotonic_ms(void) FAST_FUNC; |
@@ -1557,7 +1560,7 @@ typedef struct md5_ctx_t { | |||
1557 | uint32_t C; | 1560 | uint32_t C; |
1558 | uint32_t D; | 1561 | uint32_t D; |
1559 | uint64_t total64; | 1562 | uint64_t total64; |
1560 | char wbuffer[64]; | 1563 | char wbuffer[64]; /* NB: always correctly aligned for uint64_t */ |
1561 | } md5_ctx_t; | 1564 | } md5_ctx_t; |
1562 | #else | 1565 | #else |
1563 | /* libbb/md5prime.c uses a bit different one: */ | 1566 | /* libbb/md5prime.c uses a bit different one: */ |
diff --git a/include/platform.h b/include/platform.h index ed8c137e1..c20d2aef6 100644 --- a/include/platform.h +++ b/include/platform.h | |||
@@ -160,6 +160,7 @@ | |||
160 | 160 | ||
161 | /* ---- Endian Detection ------------------------------------ */ | 161 | /* ---- Endian Detection ------------------------------------ */ |
162 | 162 | ||
163 | #include <limits.h> | ||
163 | #if defined(__digital__) && defined(__unix__) | 164 | #if defined(__digital__) && defined(__unix__) |
164 | # include <sex.h> | 165 | # include <sex.h> |
165 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ | 166 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ |
@@ -207,6 +208,10 @@ | |||
207 | # error "Can't determine endianness" | 208 | # error "Can't determine endianness" |
208 | #endif | 209 | #endif |
209 | 210 | ||
211 | #if ULONG_MAX > 0xffffffff | ||
212 | # define bb_bswap_64(x) bswap_64(x) | ||
213 | #endif | ||
214 | |||
210 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ | 215 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ |
211 | #if BB_BIG_ENDIAN | 216 | #if BB_BIG_ENDIAN |
212 | # define SWAP_BE16(x) (x) | 217 | # define SWAP_BE16(x) (x) |
@@ -214,13 +219,13 @@ | |||
214 | # define SWAP_BE64(x) (x) | 219 | # define SWAP_BE64(x) (x) |
215 | # define SWAP_LE16(x) bswap_16(x) | 220 | # define SWAP_LE16(x) bswap_16(x) |
216 | # define SWAP_LE32(x) bswap_32(x) | 221 | # define SWAP_LE32(x) bswap_32(x) |
217 | # define SWAP_LE64(x) bswap_64(x) | 222 | # define SWAP_LE64(x) bb_bswap_64(x) |
218 | # define IF_BIG_ENDIAN(...) __VA_ARGS__ | 223 | # define IF_BIG_ENDIAN(...) __VA_ARGS__ |
219 | # define IF_LITTLE_ENDIAN(...) | 224 | # define IF_LITTLE_ENDIAN(...) |
220 | #else | 225 | #else |
221 | # define SWAP_BE16(x) bswap_16(x) | 226 | # define SWAP_BE16(x) bswap_16(x) |
222 | # define SWAP_BE32(x) bswap_32(x) | 227 | # define SWAP_BE32(x) bswap_32(x) |
223 | # define SWAP_BE64(x) bswap_64(x) | 228 | # define SWAP_BE64(x) bb_bswap_64(x) |
224 | # define SWAP_LE16(x) (x) | 229 | # define SWAP_LE16(x) (x) |
225 | # define SWAP_LE32(x) (x) | 230 | # define SWAP_LE32(x) (x) |
226 | # define SWAP_LE64(x) (x) | 231 | # define SWAP_LE64(x) (x) |