1
0
mirror of https://github.com/ScrelliCopter/VGM-Tools synced 2025-02-21 04:09:25 +11:00

normalise macros

This commit is contained in:
2023-12-29 06:21:32 +11:00
parent 78790991b6
commit effcf727ac
2 changed files with 12 additions and 12 deletions

View File

@@ -3,43 +3,43 @@
#ifdef __APPLE__ #ifdef __APPLE__
# include <machine/endian.h> # include <machine/endian.h>
#elif defined( __linux__ ) || defined( __CYGWIN__ ) || defined( __OpenBSD__ ) #elif defined(__linux__) || defined(__CYGWIN__) || defined(__OpenBSD__)
# include <endian.h> # include <endian.h>
#elif defined( __NetBSD__ ) || defined( __FreeBSD__ ) || defined( __DragonFly__ ) #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/endian.h> # include <sys/endian.h>
# ifdef __FreeBSD__ # ifdef __FreeBSD__
# define LITTLE_ENDIAN _LITTLE_ENDIAN # define LITTLE_ENDIAN _LITTLE_ENDIAN
# define BIG_ENDIAN _BIG_ENDIAN # define BIG_ENDIAN _BIG_ENDIAN
# define BYTE_ORDER _BYTE_ORDER # define BYTE_ORDER _BYTE_ORDER
# endif # endif
#elif defined( _MSC_VER ) || defined( _WIN16 ) || defined( _WIN32 ) || defined( _WIN64 ) #elif defined(_MSC_VER) || defined(_WIN16) || defined(_WIN32) || defined(_WIN64)
# ifdef _MSC_VER # ifdef _MSC_VER
# define LITTLE_ENDIAN 1234 # define LITTLE_ENDIAN 1234
# define BIG_ENDIAN 4321 # define BIG_ENDIAN 4321
# if defined( _M_IX86 ) || defined( _M_X64 ) || defined( _M_AMD64 ) || defined( _M_IA64 ) # if defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64)
# define BYTE_ORDER LITTLE_ENDIAN # define BYTE_ORDER LITTLE_ENDIAN
# elif defined( _M_PPC ) # elif defined(_M_PPC)
// Probably not reliable but eh // Probably not reliable but eh
# define BYTE_ORDER BIG_ENDIAN # define BYTE_ORDER BIG_ENDIAN
# endif # endif
# elif defined( __GNUC__ ) # elif defined(__GNUC__)
# include <sys/param.h> # include <sys/param.h>
# endif # endif
#endif #endif
#if !defined( BYTE_ORDER ) || !defined( LITTLE_ENDIAN ) || !defined( BIG_ENDIAN ) || \ #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || \
!( BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == BIG_ENDIAN ) !(BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == BIG_ENDIAN)
# error "Couldn't determine endianness or unsupported platform" # error "Couldn't determine endianness or unsupported platform"
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
# define swap32(X) _byteswap_ulong((X)) # define swap32(X) _byteswap_ulong((X))
# define swap16(X) _byteswap_ushort((X)) # define swap16(X) _byteswap_ushort((X))
#elif ( __GNUC__ == 4 && __GNUC_MINOR__ >= 8 ) || ( __GNUC__ > 4 ) #elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (__GNUC__ > 4)
# define swap32(X) __builtin_bswap32((X)) # define swap32(X) __builtin_bswap32((X))
# define swap16(X) __builtin_bswap16((X)) # define swap16(X) __builtin_bswap16((X))
// Apparently smelly GCC 5 blows up on this test so this is done separately for Clang // Apparently smelly GCC 5 blows up on this test so this is done separately for Clang
#elif defined( __has_builtin ) && __has_builtin( __builtin_bswap32 ) && __has_builtin( __builtin_bswap16 ) #elif defined(__has_builtin) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap16)
# define swap32(X) __builtin_bswap32((X)) # define swap32(X) __builtin_bswap32((X))
# define swap16(X) __builtin_bswap16((X)) # define swap16(X) __builtin_bswap16((X))
#else #else

View File

@@ -5,9 +5,9 @@
#define MAX(A, B) (((A) > (B)) ? (A) : (B)) #define MAX(A, B) (((A) > (B)) ? (A) : (B))
#define CLAMP(X, A, B) (MIN(MAX((X), (A)), (B))) #define CLAMP(X, A, B) (MIN(MAX((X), (A)), (B)))
#if ( defined( __GNUC__ ) && ( __GNUC__ >= 4 ) ) || defined( __clang__ ) #if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
# define FORCE_INLINE inline __attribute__((always_inline)) # define FORCE_INLINE inline __attribute__((always_inline))
#elif defined( _MSC_VER ) #elif defined(_MSC_VER)
# define FORCE_INLINE __forceinline # define FORCE_INLINE __forceinline
#else #else
# define FORCE_INLINE inline # define FORCE_INLINE inline