mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Portable generic byteswap for BE.
This commit is contained in:
parent
c533b031bc
commit
a30efcaa55
1
lrzip.c
1
lrzip.c
|
|
@ -37,7 +37,6 @@
|
|||
#include <sys/mman.h>
|
||||
#include <sys/time.h>
|
||||
#include <termios.h>
|
||||
#include <endian.h>
|
||||
|
||||
#include "md5.h"
|
||||
#include "rzip.h"
|
||||
|
|
|
|||
|
|
@ -99,6 +99,36 @@ typedef struct md5_ctx md5_ctx;
|
|||
# define mremap fake_mremap
|
||||
#endif
|
||||
|
||||
#define bswap_32(x) \
|
||||
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
|
||||
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
|
||||
|
||||
# define bswap_64(x) \
|
||||
((((x) & 0xff00000000000000ull) >> 56) \
|
||||
| (((x) & 0x00ff000000000000ull) >> 40) \
|
||||
| (((x) & 0x0000ff0000000000ull) >> 24) \
|
||||
| (((x) & 0x000000ff00000000ull) >> 8) \
|
||||
| (((x) & 0x00000000ff000000ull) << 8) \
|
||||
| (((x) & 0x0000000000ff0000ull) << 24) \
|
||||
| (((x) & 0x000000000000ff00ull) << 40) \
|
||||
| (((x) & 0x00000000000000ffull) << 56))
|
||||
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define htole32(x) (x)
|
||||
# define le32toh(x) (x)
|
||||
|
||||
# define htole64(x) (x)
|
||||
# define le64toh(x) (x)
|
||||
# elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define htole32(x) bswap_32 (x)
|
||||
# define le32toh(x) bswap_32 (x)
|
||||
|
||||
# define htole64(x) bswap_64 (x)
|
||||
# define le64toh(x) bswap_64 (x)
|
||||
#else
|
||||
#error UNKNOWN BYTE ORDER
|
||||
#endif
|
||||
|
||||
#define FLAG_SHOW_PROGRESS (1 << 0)
|
||||
#define FLAG_KEEP_FILES (1 << 1)
|
||||
#define FLAG_TEST_ONLY (1 << 2)
|
||||
|
|
|
|||
1
runzip.c
1
runzip.c
|
|
@ -31,7 +31,6 @@
|
|||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <endian.h>
|
||||
|
||||
#include "md5.h"
|
||||
#include "runzip.h"
|
||||
|
|
|
|||
1
rzip.c
1
rzip.c
|
|
@ -42,7 +42,6 @@
|
|||
#ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#include <endian.h>
|
||||
|
||||
#include "md5.h"
|
||||
#include "stream.h"
|
||||
|
|
|
|||
Loading…
Reference in a new issue