diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-18 11:40:26 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-18 11:40:26 +0200 |
commit | 9ff50b869780aba131dc9b542ccd0f1a3959e920 (patch) | |
tree | a1f65f2a5f8c3aa1d6f51bc15c734f2b3ae46ead /include | |
parent | b102e12253078e8c0ebdeeb5e1893ea6a025a700 (diff) | |
download | busybox-w32-9ff50b869780aba131dc9b542ccd0f1a3959e920.tar.gz busybox-w32-9ff50b869780aba131dc9b542ccd0f1a3959e920.tar.bz2 busybox-w32-9ff50b869780aba131dc9b542ccd0f1a3959e920.zip |
*: deinline SWAP_xE64 on 32-bit CPUs. Wins !90 bytes both on 32 and 64 bits
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 7 | ||||
-rw-r--r-- | include/platform.h | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/include/libbb.h b/include/libbb.h index b16157d46..c161ed7e2 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> |
@@ -254,6 +252,11 @@ extern int *const bb_errno; | |||
254 | #define errno (*bb_errno) | 252 | #define errno (*bb_errno) |
255 | #endif | 253 | #endif |
256 | 254 | ||
255 | #if !(ULONG_MAX > 0xffffffff) | ||
256 | /* Only 32-bit CPUs need this, 64-bit ones use inlined version */ | ||
257 | uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; | ||
258 | #endif | ||
259 | |||
257 | unsigned long long monotonic_ns(void) FAST_FUNC; | 260 | unsigned long long monotonic_ns(void) FAST_FUNC; |
258 | unsigned long long monotonic_us(void) FAST_FUNC; | 261 | unsigned long long monotonic_us(void) FAST_FUNC; |
259 | unsigned long long monotonic_ms(void) FAST_FUNC; | 262 | unsigned long long monotonic_ms(void) FAST_FUNC; |
diff --git a/include/platform.h b/include/platform.h index c255a17ce..b5c668517 100644 --- a/include/platform.h +++ b/include/platform.h | |||
@@ -150,6 +150,7 @@ | |||
150 | 150 | ||
151 | /* ---- Endian Detection ------------------------------------ */ | 151 | /* ---- Endian Detection ------------------------------------ */ |
152 | 152 | ||
153 | #include <limits.h> | ||
153 | #if defined(__digital__) && defined(__unix__) | 154 | #if defined(__digital__) && defined(__unix__) |
154 | # include <sex.h> | 155 | # include <sex.h> |
155 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ | 156 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ |
@@ -189,6 +190,10 @@ | |||
189 | # error "Can't determine endianness" | 190 | # error "Can't determine endianness" |
190 | #endif | 191 | #endif |
191 | 192 | ||
193 | #if ULONG_MAX > 0xffffffff | ||
194 | # define bb_bswap_64(x) bswap_64(x) | ||
195 | #endif | ||
196 | |||
192 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ | 197 | /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ |
193 | #if BB_BIG_ENDIAN | 198 | #if BB_BIG_ENDIAN |
194 | # define SWAP_BE16(x) (x) | 199 | # define SWAP_BE16(x) (x) |
@@ -196,13 +201,13 @@ | |||
196 | # define SWAP_BE64(x) (x) | 201 | # define SWAP_BE64(x) (x) |
197 | # define SWAP_LE16(x) bswap_16(x) | 202 | # define SWAP_LE16(x) bswap_16(x) |
198 | # define SWAP_LE32(x) bswap_32(x) | 203 | # define SWAP_LE32(x) bswap_32(x) |
199 | # define SWAP_LE64(x) bswap_64(x) | 204 | # define SWAP_LE64(x) bb_bswap_64(x) |
200 | # define IF_BIG_ENDIAN(...) __VA_ARGS__ | 205 | # define IF_BIG_ENDIAN(...) __VA_ARGS__ |
201 | # define IF_LITTLE_ENDIAN(...) | 206 | # define IF_LITTLE_ENDIAN(...) |
202 | #else | 207 | #else |
203 | # define SWAP_BE16(x) bswap_16(x) | 208 | # define SWAP_BE16(x) bswap_16(x) |
204 | # define SWAP_BE32(x) bswap_32(x) | 209 | # define SWAP_BE32(x) bswap_32(x) |
205 | # define SWAP_BE64(x) bswap_64(x) | 210 | # define SWAP_BE64(x) bb_bswap_64(x) |
206 | # define SWAP_LE16(x) (x) | 211 | # define SWAP_LE16(x) (x) |
207 | # define SWAP_LE32(x) (x) | 212 | # define SWAP_LE32(x) (x) |
208 | # define SWAP_LE64(x) (x) | 213 | # define SWAP_LE64(x) (x) |