]> git.lizzy.rs Git - zlib.git/commitdiff
Don't use library or built-in byte swaps.
authorMark Adler <madler@alumni.caltech.edu>
Sat, 3 Mar 2012 08:03:30 +0000 (00:03 -0800)
committerMark Adler <madler@alumni.caltech.edu>
Sat, 3 Mar 2012 08:03:30 +0000 (00:03 -0800)
Using optimized byte swaps reduced portability for no real benefit,
since they are in parts of the code that represent a tiny fraction
of the execution time.  So a simple definition of a byte swap is
now used.

zutil.h

diff --git a/zutil.h b/zutil.h
index 7a409fad66d53137495c9355d70a1b789af53857..7be5f55497710d23904de553c914d18a51b6680a 100644 (file)
--- a/zutil.h
+++ b/zutil.h
@@ -246,18 +246,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
 
 /* Reverse the bytes in a 32-bit value */
-#ifndef Z_SOLO
-#  if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_X64))
-#    include <stdlib.h>
-#    pragma intrinsic(_byteswap_ulong)
-#    define ZSWAP32(q) _byteswap_ulong(q)
-#  elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-#    define ZSWAP32(q) __builtin_bswap32(q)
-#  endif
-#endif
-#ifndef ZSWAP32
-#  define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
-                      (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-#endif
+#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
+                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
 
 #endif /* ZUTIL_H */