From 23cbdb99f72bd57ee775c7a9bc4e20999a4d7199 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 11 Mar 2006 11:15:41 +0000 Subject: [PATCH] added 16-bit endian conversion macros git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4569 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/util.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/util.h b/Source/util.h index eb434f19..1c94d28f 100644 --- a/Source/util.h +++ b/Source/util.h @@ -38,14 +38,23 @@ size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm); #ifndef __BIG_ENDIAN__ # define FIX_ENDIAN_INT32_INPLACE(x) (x) +# define FIX_ENDIAN_INT32(x) (x) +# define FIX_ENDIAN_INT16_INPLACE(x) (x) +# define FIX_ENDIAN_INT16(x) (x) #else # define FIX_ENDIAN_INT32_INPLACE(x) ((x) = SWAP_ENDIAN_INT32(x)) +# define FIX_ENDIAN_INT32(x) SWAP_ENDIAN_INT32(x) +# define FIX_ENDIAN_INT16_INPLACE(x) ((x) = SWAP_ENDIAN_INT16(x)) +# define FIX_ENDIAN_INT16(x) SWAP_ENDIAN_INT16(x) #endif #define SWAP_ENDIAN_INT32(x) ( \ (((x)&0xFF000000) >> 24) | \ (((x)&0x00FF0000) >> 8) | \ (((x)&0x0000FF00) << 8) | \ (((x)&0x000000FF) << 24) ) +#define SWAP_ENDIAN_INT16(x) ( \ + (((x)&0xFF00) >> 8) | \ + (((x)&0x00FF) << 8) ) std::string get_full_path(const std::string& path); std::string get_dir_name(const std::string& path);