From 49844d4c729c7330e50772e6cf7ff792499c0361 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 11 Mar 2006 18:11:27 +0000 Subject: [PATCH] moved endianity macros to Platform.h git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4575 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/Platform.h | 23 +++++++++++++++++++++-- Source/Tests/endian.cpp | 2 +- Source/util.h | 20 -------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Source/Platform.h b/Source/Platform.h index 39c7b572..2124094b 100644 --- a/Source/Platform.h +++ b/Source/Platform.h @@ -49,6 +49,25 @@ typedef unsigned long HBRUSH; typedef WORD LANGID; #endif +#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) ) // script path separator @@ -594,8 +613,8 @@ typedef WORD LANGID; #ifndef _WIN32 # define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 -# define IMAGE_DOS_SIGNATURE 0x5A4D -# define IMAGE_NT_SIGNATURE 0x00004550 +# define IMAGE_DOS_SIGNATURE 0x5A4D +# define IMAGE_NT_SIGNATURE 0x00004550 # define IMAGE_FILE_DLL 8192 # define IMAGE_DIRECTORY_ENTRY_EXPORT 0 # define IMAGE_SIZEOF_SHORT_NAME 8 diff --git a/Source/Tests/endian.cpp b/Source/Tests/endian.cpp index 440a1c8f..38882db2 100644 --- a/Source/Tests/endian.cpp +++ b/Source/Tests/endian.cpp @@ -1,5 +1,5 @@ #include -#include "../util.h" +#include "../Platform.h" class EndianTest : public CppUnit::TestFixture { diff --git a/Source/util.h b/Source/util.h index 1c94d28f..28194350 100644 --- a/Source/util.h +++ b/Source/util.h @@ -36,26 +36,6 @@ size_t WCStrLen(const WCHAR* szwStr); 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); std::string get_file_name(const std::string& path);