summaryrefslogtreecommitdiff
path: root/zaphod32_hash.h
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2019-09-04 21:48:56 -0700
committerTony Cook <tony@develop-help.com>2019-10-08 09:27:43 +1100
commite8864dba80952684bf3afe83438d4eee0c3939a9 (patch)
treeef39f361559ca7cabef294085a643c3742e6d4f5 /zaphod32_hash.h
parentee9ac1cd8eb988fea70841eae211b11355711416 (diff)
downloadperl-e8864dba80952684bf3afe83438d4eee0c3939a9.tar.gz
Clean up U8TO*_LE macro implementations
The code guarded by #ifndef U32_ALIGNMENT_REQUIRED attempts to optimize byte-swapping by doing unaligned loads, but accessing data through unaligned pointers is undefined behavior in C. Moreover, compilers are more than capable of recognizing these open-coded byte-swap patterns and emitting a bswap instruction, or an unaligned load instruction, or a combined load, etc. There's no need for multiple paths to attain the desired result. See https://rt.perl.org/Ticket/Display.html?id=133495
Diffstat (limited to 'zaphod32_hash.h')
-rw-r--r--zaphod32_hash.h35
1 files changed, 0 insertions, 35 deletions
diff --git a/zaphod32_hash.h b/zaphod32_hash.h
index c9b60ccb32..2fb391a233 100644
--- a/zaphod32_hash.h
+++ b/zaphod32_hash.h
@@ -74,41 +74,6 @@
#define STMT_END while(0)
#endif
-#ifndef ZAPHOD32_ALLOW_UNALIGNED_AND_LITTLE_ENDIAN
-/* ZAPHOD32_ALLOW_UNALIGNED_AND_LITTLE_ENDIAN only matters if nothing has defined U8TO64_LE etc,
- * and when built with Perl these should be defined before this file is loaded.
- */
-#ifdef U32_ALIGNMENT_REQUIRED
-#define ZAPHOD32_ALLOW_UNALIGNED_AND_LITTLE_ENDIAN 0
-#else
-#define ZAPHOD32_ALLOW_UNALIGNED_AND_LITTLE_ENDIAN 1
-#endif
-#endif
-
-#ifndef U8TO32_LE
-#if ZAPHOD32_ALLOW_UNALIGNED_AND_LITTLE_ENDIAN
-#define U8TO32_LE(ptr) (*((const U32 *)(ptr)))
-#else
-#define U8TO32_LE(ptr) (\
- (U32)(ptr)[3] << 24 | \
- (U32)(ptr)[2] << 16 | \
- (U32)(ptr)[1] << 8 | \
- (U32)(ptr)[0] \
-)
-#endif
-#endif
-
-#ifndef U8TO16_LE
-#if ZAPHOD32_ALLOW_UNALIGNED_AND_LITTLE_ENDIAN
-#define U8TO16_LE(ptr) (*((const U16 *)(ptr)))
-#else
-#define U8TO16_LE(ptr) (\
- (U16)(ptr)[1] << 8 | \
- (U16)(ptr)[0] \
-)
-#endif
-#endif
-
/* This is two marsaglia xor-shift permutes, with a prime-multiple
* sandwiched inside. The end result of doing this twice with different
* primes is a completely avalanched v. */