Check for different endian.h includes and variants of le32toh.

This commit is contained in:
Con Kolivas 2011-03-22 07:57:32 +11:00
parent fae0f0d493
commit 2736118f82
6 changed files with 33 additions and 2 deletions

View file

@ -37,6 +37,11 @@
#include <sys/mman.h>
#include <sys/time.h>
#include <termios.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif
#include "md5.h"
#include "rzip.h"

View file

@ -113,21 +113,26 @@ typedef struct md5_ctx md5_ctx;
| (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56))
#ifdef leto32h
# define le32toh(x) leto32h(x)
# define le64toh(x) leto64h(x)
#endif
#ifndef le32toh
# 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
#endif
#define FLAG_SHOW_PROGRESS (1 << 0)
#define FLAG_KEEP_FILES (1 << 1)

5
main.c
View file

@ -37,6 +37,11 @@
#endif
#include <math.h>
#include <termios.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif
#include "rzip.h"
#include "lrzip.h"

View file

@ -31,6 +31,11 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif
#include "md5.h"
#include "runzip.h"
@ -40,6 +45,7 @@
#include "liblrzip.h"
/* needed for CRC routines */
#include "lzma/C/7zCrc.h"
static inline uchar read_u8(rzip_control *control, void *ss, int stream)
{
uchar b;

5
rzip.c
View file

@ -42,6 +42,11 @@
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif
#include "md5.h"
#include "stream.h"

View file

@ -39,6 +39,11 @@
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif
/* LZMA C Wrapper */
#include "lzma/C/LzmaLib.h"