diff options
author | Rob Landley <rob@landley.net> | 2006-03-04 22:40:25 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-03-04 22:40:25 +0000 |
commit | 688ed0d7606c0563073f588098b9bedf904c70a9 (patch) | |
tree | 123b85ec83aede5c1323d95297dc6d67f3b9e1f5 | |
parent | d9969ea175503bdd37fdc966a0ed38bb6f81ff89 (diff) | |
download | busybox-w32-688ed0d7606c0563073f588098b9bedf904c70a9.tar.gz busybox-w32-688ed0d7606c0563073f588098b9bedf904c70a9.tar.bz2 busybox-w32-688ed0d7606c0563073f588098b9bedf904c70a9.zip |
Patch from Robert P. Day, moving byte order checks to use platform.h macros.
-rw-r--r-- | archival/libunarchive/decompress_unlzma.c | 4 | ||||
-rw-r--r-- | archival/unzip.c | 14 | ||||
-rw-r--r-- | miscutils/hdparm.c | 4 | ||||
-rw-r--r-- | modutils/insmod.c | 12 |
4 files changed, 17 insertions, 17 deletions
diff --git a/archival/libunarchive/decompress_unlzma.c b/archival/libunarchive/decompress_unlzma.c index 62811ddfc..9c53e0a56 100644 --- a/archival/libunarchive/decompress_unlzma.c +++ b/archival/libunarchive/decompress_unlzma.c | |||
@@ -119,10 +119,10 @@ int unlzma(int src_fd, int dst_fd) | |||
119 | pos_state_mask = (1 << pb) - 1; | 119 | pos_state_mask = (1 << pb) - 1; |
120 | literal_pos_mask = (1 << lp) - 1; | 120 | literal_pos_mask = (1 << lp) - 1; |
121 | 121 | ||
122 | #if __BYTE_ORDER == __BIG_ENDIAN | 122 | #if BB_BIG_ENDIAN |
123 | header.dict_size = bswap_32(header.dict_size); | 123 | header.dict_size = bswap_32(header.dict_size); |
124 | header.dst_size = bswap_64(header.dst_size); | 124 | header.dst_size = bswap_64(header.dst_size); |
125 | #endif /* __BYTE_ORDER */ | 125 | #endif |
126 | 126 | ||
127 | if (header.dict_size == 0) | 127 | if (header.dict_size == 0) |
128 | header.dict_size = 1; | 128 | header.dict_size = 1; |
diff --git a/archival/unzip.c b/archival/unzip.c index 7e0d107cc..f95e31206 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "unarchive.h" | 32 | #include "unarchive.h" |
33 | #include "busybox.h" | 33 | #include "busybox.h" |
34 | 34 | ||
35 | #if (BYTE_ORDER == BIG_ENDIAN) | 35 | #if BB_BIG_ENDIAN |
36 | static inline unsigned short | 36 | static inline unsigned short |
37 | __swap16(unsigned short x) { | 37 | __swap16(unsigned short x) { |
38 | return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8); | 38 | return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8); |
@@ -45,10 +45,10 @@ __swap32(uint32_t x) { | |||
45 | ((x & 0xFF0000) >> 8) | | 45 | ((x & 0xFF0000) >> 8) | |
46 | ((x & 0xFF000000) >> 24)); | 46 | ((x & 0xFF000000) >> 24)); |
47 | } | 47 | } |
48 | #else | 48 | #else /* it's little-endian */ |
49 | #define __swap16(x) (x) | 49 | # define __swap16(x) (x) |
50 | #define __swap32(x) (x) | 50 | # define __swap32(x) (x) |
51 | #endif | 51 | #endif /* BB_BIG_ENDIAN */ |
52 | 52 | ||
53 | #define ZIP_FILEHEADER_MAGIC __swap32(0x04034b50) | 53 | #define ZIP_FILEHEADER_MAGIC __swap32(0x04034b50) |
54 | #define ZIP_CDS_MAGIC __swap32(0x02014b50) | 54 | #define ZIP_CDS_MAGIC __swap32(0x02014b50) |
@@ -253,7 +253,7 @@ extern int unzip_main(int argc, char **argv) | |||
253 | 253 | ||
254 | /* Read the file header */ | 254 | /* Read the file header */ |
255 | unzip_read(src_fd, zip_header.raw, 26); | 255 | unzip_read(src_fd, zip_header.raw, 26); |
256 | #if (BYTE_ORDER == BIG_ENDIAN) | 256 | #if BB_BIG_ENDIAN |
257 | zip_header.formated.version = __swap16(zip_header.formated.version); | 257 | zip_header.formated.version = __swap16(zip_header.formated.version); |
258 | zip_header.formated.flags = __swap16(zip_header.formated.flags); | 258 | zip_header.formated.flags = __swap16(zip_header.formated.flags); |
259 | zip_header.formated.method = __swap16(zip_header.formated.method); | 259 | zip_header.formated.method = __swap16(zip_header.formated.method); |
@@ -264,7 +264,7 @@ extern int unzip_main(int argc, char **argv) | |||
264 | zip_header.formated.ucmpsize = __swap32(zip_header.formated.ucmpsize); | 264 | zip_header.formated.ucmpsize = __swap32(zip_header.formated.ucmpsize); |
265 | zip_header.formated.filename_len = __swap16(zip_header.formated.filename_len); | 265 | zip_header.formated.filename_len = __swap16(zip_header.formated.filename_len); |
266 | zip_header.formated.extra_len = __swap16(zip_header.formated.extra_len); | 266 | zip_header.formated.extra_len = __swap16(zip_header.formated.extra_len); |
267 | #endif | 267 | #endif /* BB_BIG_ENDIAN */ |
268 | if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) { | 268 | if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) { |
269 | bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method); | 269 | bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method); |
270 | } | 270 | } |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index e733c9172..bd3065d7e 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -48,8 +48,8 @@ | |||
48 | #include <asm/byteorder.h> | 48 | #include <asm/byteorder.h> |
49 | 49 | ||
50 | 50 | ||
51 | #if (__BYTE_ORDER == __BIG_ENDIAN) && !defined(__USE_XOPEN) | 51 | #if BB_BIG_ENDIAN && !defined(__USE_XOPEN) |
52 | #define __USE_XOPEN | 52 | # define __USE_XOPEN |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | /* device types */ | 55 | /* device types */ |
diff --git a/modutils/insmod.c b/modutils/insmod.c index d40012d70..14322d978 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -268,8 +268,8 @@ extern int insmod_ng_main( int argc, char **argv); | |||
268 | #define CONFIG_USE_SINGLE | 268 | #define CONFIG_USE_SINGLE |
269 | /* the SH changes have only been tested in =little endian= mode */ | 269 | /* the SH changes have only been tested in =little endian= mode */ |
270 | /* I'm not sure about big endian, so let's warn: */ | 270 | /* I'm not sure about big endian, so let's warn: */ |
271 | #if defined(__sh__) && defined(__BIG_ENDIAN__) | 271 | #if defined(__sh__) && BB_BIG_ENDIAN |
272 | #error insmod.c may require changes for use on big endian SH | 272 | # error insmod.c may require changes for use on big endian SH |
273 | #endif | 273 | #endif |
274 | /* it may or may not work on the SH1/SH2... Error on those also */ | 274 | /* it may or may not work on the SH1/SH2... Error on those also */ |
275 | #if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && (defined(__sh__)) | 275 | #if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && (defined(__sh__)) |
@@ -511,10 +511,10 @@ static const int MODUTILS_OBJ_H = 1; | |||
511 | #include <elf.h> | 511 | #include <elf.h> |
512 | #include <endian.h> | 512 | #include <endian.h> |
513 | 513 | ||
514 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 514 | #if BB_LITTLE_ENDIAN |
515 | #define ELFDATAM ELFDATA2LSB | 515 | # define ELFDATAM ELFDATA2LSB |
516 | #elif __BYTE_ORDER == __BIG_ENDIAN | 516 | #else |
517 | #define ELFDATAM ELFDATA2MSB | 517 | # define ELFDATAM ELFDATA2MSB |
518 | #endif | 518 | #endif |
519 | 519 | ||
520 | #ifndef ElfW | 520 | #ifndef ElfW |