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 /networking | |
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 'networking')
-rw-r--r-- | networking/udhcp/dumpleases.c | 13 | ||||
-rw-r--r-- | networking/udhcp/files.c | 14 |
2 files changed, 3 insertions, 24 deletions
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index 341815a69..46610fc63 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c | |||
@@ -6,17 +6,6 @@ | |||
6 | #include "dhcpd.h" | 6 | #include "dhcpd.h" |
7 | #include "unicode.h" | 7 | #include "unicode.h" |
8 | 8 | ||
9 | #if BB_LITTLE_ENDIAN | ||
10 | static inline uint64_t hton64(uint64_t v) | ||
11 | { | ||
12 | return SWAP_BE64(v); | ||
13 | } | ||
14 | #else | ||
15 | #define hton64(v) (v) | ||
16 | #endif | ||
17 | #define ntoh64(v) hton64(v) | ||
18 | |||
19 | |||
20 | int dumpleases_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 9 | int dumpleases_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
21 | int dumpleases_main(int argc UNUSED_PARAM, char **argv) | 10 | int dumpleases_main(int argc UNUSED_PARAM, char **argv) |
22 | { | 11 | { |
@@ -54,7 +43,7 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) | |||
54 | /* "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */ | 43 | /* "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */ |
55 | 44 | ||
56 | xread(fd, &written_at, sizeof(written_at)); | 45 | xread(fd, &written_at, sizeof(written_at)); |
57 | written_at = ntoh64(written_at); | 46 | written_at = SWAP_BE64(written_at); |
58 | curr = time(NULL); | 47 | curr = time(NULL); |
59 | if (curr < written_at) | 48 | if (curr < written_at) |
60 | written_at = curr; /* lease file from future! :) */ | 49 | written_at = curr; /* lease file from future! :) */ |
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 68b2085a9..49bcafb9c 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -11,16 +11,6 @@ | |||
11 | #include "common.h" | 11 | #include "common.h" |
12 | #include "dhcpd.h" | 12 | #include "dhcpd.h" |
13 | 13 | ||
14 | #if BB_LITTLE_ENDIAN | ||
15 | static inline uint64_t hton64(uint64_t v) | ||
16 | { | ||
17 | return SWAP_BE64(v); | ||
18 | } | ||
19 | #else | ||
20 | #define hton64(v) (v) | ||
21 | #endif | ||
22 | #define ntoh64(v) hton64(v) | ||
23 | |||
24 | /* on these functions, make sure your datatype matches */ | 14 | /* on these functions, make sure your datatype matches */ |
25 | static int FAST_FUNC read_str(const char *line, void *arg) | 15 | static int FAST_FUNC read_str(const char *line, void *arg) |
26 | { | 16 | { |
@@ -140,7 +130,7 @@ void FAST_FUNC write_leases(void) | |||
140 | 130 | ||
141 | curr = written_at = time(NULL); | 131 | curr = written_at = time(NULL); |
142 | 132 | ||
143 | written_at = hton64(written_at); | 133 | written_at = SWAP_BE64(written_at); |
144 | full_write(fd, &written_at, sizeof(written_at)); | 134 | full_write(fd, &written_at, sizeof(written_at)); |
145 | 135 | ||
146 | for (i = 0; i < server_config.max_leases; i++) { | 136 | for (i = 0; i < server_config.max_leases; i++) { |
@@ -190,7 +180,7 @@ void FAST_FUNC read_leases(const char *file) | |||
190 | 180 | ||
191 | if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at)) | 181 | if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at)) |
192 | goto ret; | 182 | goto ret; |
193 | written_at = ntoh64(written_at); | 183 | written_at = SWAP_BE64(written_at); |
194 | 184 | ||
195 | time_passed = time(NULL) - written_at; | 185 | time_passed = time(NULL) - written_at; |
196 | /* Strange written_at, or lease file from old version of udhcpd | 186 | /* Strange written_at, or lease file from old version of udhcpd |