Skip to content

Commit 2547c6c

Browse files
committed
Don't use library or built-in byte swaps.
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.
1 parent 513dfcc commit 2547c6c

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

zutil.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
246246
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
247247

248248
/* Reverse the bytes in a 32-bit value */
249-
#ifndef Z_SOLO
250-
# if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_X64))
251-
# include <stdlib.h>
252-
# pragma intrinsic(_byteswap_ulong)
253-
# define ZSWAP32(q) _byteswap_ulong(q)
254-
# elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
255-
# define ZSWAP32(q) __builtin_bswap32(q)
256-
# endif
257-
#endif
258-
#ifndef ZSWAP32
259-
# define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
260-
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
261-
#endif
249+
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
250+
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
262251

263252
#endif /* ZUTIL_H */

0 commit comments

Comments
 (0)