From 53d69ce19b02051cbf732af00ab98bcf384561cd Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Tue, 24 Jan 2017 19:38:02 -0500 Subject: Fix various SunCC and Solaris warnings and build problems. Based on build output sent by @noloader. If RLIMIT_MEMLOCK is not defined, assume regular user is not able to call mlock. This probably also affected Clang/GCC on Solaris. Work around resolution issue in SIMD_4x32 where it finds ambiguity between arg taking uint32_t and __m128i. This is probably some artifact of how SunCC represents vector types, and seems highly bogus in general but is easy to work around here. Change constructor taking a single value to instead be `SIMD_4x32::splat` function. The SIMD class is internal, so no API implications. Fix various warnings about lambda functions that were missing return types and which were not a single return statement. AIUI C++11 doesn't guarantee that lambda return type will be deduced in that situation, though in practice every compiler including SunCC seems to handle it. Disable AVX2 usage, since SunCC's intrinsics seem to be broken - its _mm_loadu_si256 takes non-const pointer. Rename a few variables in the tests to avoid shadowed var warnings. --- src/lib/utils/os_utils.cpp | 9 +++++++++ src/lib/utils/simd/simd_32.h | 11 +++-------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/lib/utils') diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp index 87cbcfd0f..c6d99237c 100644 --- a/src/lib/utils/os_utils.cpp +++ b/src/lib/utils/os_utils.cpp @@ -182,6 +182,7 @@ size_t get_memory_locking_limit() catch(std::exception&) { /* ignore it */ } } +#if defined(RLIMIT_MEMLOCK) if(mlock_requested > 0) { struct ::rlimit limits; @@ -197,6 +198,14 @@ size_t get_memory_locking_limit() return std::min(limits.rlim_cur, mlock_requested * 1024); } +#else + /* + * If RLIMIT_MEMLOCK is not defined, likely the OS does not support + * unprivileged mlock calls. + */ + return 0; +#endif + #elif defined(BOTAN_TARGET_OS_HAS_VIRTUAL_LOCK) && defined(BOTAN_BUILD_COMPILER_IS_MSVC) SIZE_T working_min = 0, working_max = 0; DWORD working_flags = 0; diff --git a/src/lib/utils/simd/simd_32.h b/src/lib/utils/simd/simd_32.h index 591e0e9c9..2308da652 100644 --- a/src/lib/utils/simd/simd_32.h +++ b/src/lib/utils/simd/simd_32.h @@ -74,17 +74,12 @@ class SIMD_4x32 #endif } - explicit SIMD_4x32(uint32_t B) + static SIMD_4x32 splat(uint32_t B) { #if defined(BOTAN_SIMD_USE_SSE2) - m_reg = _mm_set1_epi32(B); -#elif defined(BOTAN_SIMD_USE_ALTIVEC) - m_reg = (__vector unsigned int){B, B, B, B}; + return SIMD_4x32(_mm_set1_epi32(B)); #else - m_reg[0] = B; - m_reg[1] = B; - m_reg[2] = B; - m_reg[3] = B; + return SIMD_4x32(B, B, B, B); #endif } -- cgit v1.2.3