diff --git a/zzip/fetch.c b/zzip/fetch.c index 4ae24cc..c406c68 100644 --- a/zzip/fetch.c +++ b/zzip/fetch.c @@ -16,17 +16,6 @@ #include -#if defined ZZIP_WORDS_BIGENDIAN && \ - defined bswap_16 && defined bswap_32 && defined bswap_64 -# define __ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) -# define __ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) -# define __ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) -# define __ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x))) -# define __ZZIP_GET64(__p) bswap_64(*(zzip_off64_t*)(__p)) -# define __ZZIP_SET64(__p,__x) \ - (*(zzip_off64_t*)(__p) = bswap_64((zzip_off64_t)(__x))) -#endif - /* ------------------------- fetch helpers --------------------------------- */ /** @@ -35,12 +24,8 @@ */ uint32_t __zzip_get32(unsigned char * s) { -#if defined __ZZIP_GET32 - return __ZZIP_GET32(s); -#else return ((uint32_t)s[3] << 24) | ((uint32_t)s[2] << 16) | ((uint32_t)s[1] << 8) | ((uint32_t)s[0]); -#endif } /** => __zzip_get32 @@ -48,11 +33,7 @@ uint32_t __zzip_get32(unsigned char * s) */ uint16_t __zzip_get16(unsigned char * s) { -#if defined __ZZIP_GET16 - return __ZZIP_GET16(s); -#else return ((uint16_t)s[1] << 8) | ((uint16_t)s[0]); -#endif } /** => __zzip_get32 @@ -85,16 +66,12 @@ uint64_t __zzip_get64(unsigned char * s) */ void __zzip_set32(unsigned char * s, uint32_t v) { -#if defined __ZZIP_SET32 - return __ZZIP_SET32(s, v); -#else /* *INDENT-OFF* */ s[0] = (unsigned char) (v); v >>= 8; s[1] = (unsigned char) (v); v >>= 8; s[2] = (unsigned char) (v); v >>= 8; s[3] = (unsigned char) (v); /* *INDENT-ON* */ -#endif } /** => __zzip_get32 @@ -102,14 +79,10 @@ void __zzip_set32(unsigned char * s, uint32_t v) */ void __zzip_set16(unsigned char * s, uint16_t v) { -#if defined __ZZIP_SET16 - return __ZZIP_SET16(s, v); -#else /* *INDENT-OFF* */ s[0] = (unsigned char) (v); v >>= 8; s[1] = (unsigned char) (v); /* *INDENT-ON* */ -#endif } /** => __zzip_get32 diff --git a/zzip/fetch.h b/zzip/fetch.h index e2c5e9b..0f2ca18 100644 --- a/zzip/fetch.h +++ b/zzip/fetch.h @@ -24,21 +24,12 @@ extern uint64_t __zzip_get64(zzip_byte_t * s) __zzip_attribute__((const)); extern void __zzip_set64(zzip_byte_t * s, uint64_t v); #ifdef ZZIP_WORDS_BIGENDIAN -# if defined bswap_16 && defined bswap_32 && defined bswap_64 /* i.e. linux */ -# define ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) -# define ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) -# define ZZIP_GET64(__p) bswap_64(*(uint64_t*)(__p)) -# define ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) -# define ZZIP_SET32(__p,__x) (*(uint32_t*)(__p) = bswap_32((uint32_t)(__x))) -# define ZZIP_SET64(__p,__x) (*(uint64_t*)(__p) = bswap_64((uint64_t)(__x))) -# else # define ZZIP_GET64(__p) (__zzip_get64((__p))) # define ZZIP_GET32(__p) (__zzip_get32((__p))) # define ZZIP_GET16(__p) (__zzip_get16((__p))) # define ZZIP_SET64(__p,__x) (__zzip_set64((__p),(__x))) # define ZZIP_SET32(__p,__x) (__zzip_set32((__p),(__x))) # define ZZIP_SET16(__p,__x) (__zzip_set16((__p),(__x))) -# endif #else /* little endian is the original zip format byteorder */ # define ZZIP_GET16(__p) (*(uint16_t*)(__p)) # define ZZIP_GET32(__p) (*(uint32_t*)(__p))