X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Fcompiler.h;h=d164184d2a090eded0fd45db9bb7f2e61b68b6db;hb=422e2b2852bfc326be37fb76346d89caf15fdf4f;hp=91445b2a6ada21275e9648ff5c1cff79f7c248d0;hpb=66cb00059d739a05e8165664b86fc8e254e950ba;p=wimlib diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 91445b2a..d164184d 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -49,14 +49,6 @@ # define __has_builtin(builtin) 0 #endif -/* Declare that the annotated function should be exported from the shared - * library (or DLL). */ -#ifdef __WIN32__ -# define WIMLIBAPI __declspec(dllexport) -#else -# define WIMLIBAPI __attribute__((visibility("default"))) -#endif - /* Declare that the annotated function should always be inlined. This might be * desirable in highly tuned code, e.g. compression codecs. */ #define forceinline inline __attribute__((always_inline)) @@ -102,7 +94,7 @@ /* Hint that the annotated function takes a printf()-like format string and * arguments. This is currently disabled on Windows because MinGW does not * support this attribute on functions taking wide-character strings. */ -#ifdef __WIN32__ +#ifdef _WIN32 # define _format_attribute(type, format_str, format_start) #else # define _format_attribute(type, format_str, format_start) \ @@ -131,27 +123,25 @@ /* UNALIGNED_ACCESS_IS_FAST should be defined to 1 if unaligned memory accesses * can be performed efficiently on the target platform. */ -#if defined(__x86_64__) || defined(__i386__) || defined(__ARM_FEATURE_UNALIGNED) +#if defined(__x86_64__) || defined(__i386__) || \ + defined(__ARM_FEATURE_UNALIGNED) || defined(__powerpc64__) # define UNALIGNED_ACCESS_IS_FAST 1 #else # define UNALIGNED_ACCESS_IS_FAST 0 #endif -/* Get the type of the specified expression. */ -#define typeof __typeof__ - /* Get the minimum of two variables, without multiple evaluation. */ -#ifndef min -# define min(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ - (_a < _b) ? _a : _b; }) -#endif +#undef min +#define min(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ + (_a < _b) ? _a : _b; }) +#undef MIN #define MIN(a, b) min((a), (b)) /* Get the maximum of two variables, without multiple evaluation. */ -#ifndef max -# define max(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ - (_a > _b) ? _a : _b; }) -#endif +#undef max +#define max(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ + (_a > _b) ? _a : _b; }) +#undef MAX #define MAX(a, b) max((a), (b)) /* Swap the values of two variables, without multiple evaluation. */ @@ -160,27 +150,6 @@ #endif #define SWAP(a, b) swap((a), (b)) -/* (Optional) Efficiently swap the bytes of a 16-bit integer. */ -#if GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16) -# define compiler_bswap16 __builtin_bswap16 -#endif - -/* (Optional) Efficiently swap the bytes of a 32-bit integer. */ -#if GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap32) -# define compiler_bswap32 __builtin_bswap32 -#endif - -/* (Optional) Efficiently swap the bytes of a 64-bit integer. */ -#if GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64) -# define compiler_bswap64 __builtin_bswap64 -#endif - -/* (Optional) Find Last Set bit and Find First Set bit macros. */ -#define compiler_bsr32(n) (31 - __builtin_clz(n)) -#define compiler_bsr64(n) (63 - __builtin_clzll(n)) -#define compiler_bsf32(n) __builtin_ctz(n) -#define compiler_bsf64(n) __builtin_ctzll(n) - /* Optional definitions for checking with 'sparse'. */ #ifdef __CHECKER__ # define _bitwise_attr __attribute__((bitwise))