Coverage Report

Created: 2024-10-21 15:10

/root/bitcoin/src/crc32c/src/crc32c_sse42_check.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2017 The CRC32C Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file. See the AUTHORS file for names of contributors.
4
5
#ifndef CRC32C_CRC32C_SSE42_CHECK_H_
6
#define CRC32C_CRC32C_SSE42_CHECK_H_
7
8
// X86-specific code checking the availability of SSE4.2 instructions.
9
10
#include <cstddef>
11
#include <cstdint>
12
13
#ifdef CRC32C_HAVE_CONFIG_H
14
#include "crc32c/crc32c_config.h"
15
#endif
16
17
#if HAVE_SSE42 && (defined(_M_X64) || defined(__x86_64__))
18
19
// If the compiler supports SSE4.2, it definitely supports X86.
20
21
#if defined(_MSC_VER)
22
#include <intrin.h>
23
24
namespace crc32c {
25
26
inline bool CanUseSse42() {
27
  int cpu_info[4];
28
  __cpuid(cpu_info, 1);
29
  return (cpu_info[2] & (1 << 20)) != 0;
30
}
31
32
}  // namespace crc32c
33
34
#else  // !defined(_MSC_VER)
35
#include <cpuid.h>
36
37
namespace crc32c {
38
39
0
inline bool CanUseSse42() {
40
0
  unsigned int eax, ebx, ecx, edx;
41
0
  return __get_cpuid(1, &eax, &ebx, &ecx, &edx) && ((ecx & (1 << 20)) != 0);
42
0
}
43
44
}  // namespace crc32c
45
46
#endif  // defined(_MSC_VER)
47
48
#endif  // HAVE_SSE42 && (defined(_M_X64) || defined(__x86_64__))
49
50
#endif  // CRC32C_CRC32C_SSE42_CHECK_H_