summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c')
-rw-r--r--src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c b/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c
index dfa1d9e03b2..8db4b254366 100644
--- a/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c
+++ b/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c
@@ -106,14 +106,25 @@ extern uint32_t (*wiredtiger_crc32c_func(void))(const void *, size_t);
*/
uint32_t (*wiredtiger_crc32c_func(void))(const void *, size_t)
{
+ static uint32_t (*crc32c_func)(const void *, size_t);
#if defined(__linux__) && !defined(HAVE_NO_CRC32_HARDWARE)
- unsigned long caps = getauxval(AT_HWCAP);
+ unsigned long caps;
+#endif
+
+ /*
+ * This function calls slow hardware functions; if the application doesn't realize that, they
+ * may call it on every request.
+ */
+ if (crc32c_func != NULL)
+ return (crc32c_func);
+#if defined(__linux__) && !defined(HAVE_NO_CRC32_HARDWARE)
+ caps = getauxval(AT_HWCAP);
if (caps & HWCAP_S390_VX)
- return (__wt_checksum_hw);
+ return (crc32c_func = __wt_checksum_hw);
else
- return (__wt_checksum_sw);
+ return (crc32c_func = __wt_checksum_sw);
#else
- return (__wt_checksum_sw);
+ return (crc32c_func = __wt_checksum_sw);
#endif
}