File: GB_cpu_features_impl.c

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (52 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//------------------------------------------------------------------------------
// GB_cpu_features_impl.c: cpu features for GraphBLAS
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// Google's cpu_features package makes extensive use of bit field manipulation.
// This makes the code easy to read, but the layout of the bits can depend on
// the implementation by the compiler.  The cpu_features/CMakeLists.txt file
// has this recommendation:

    // cpu_features uses bit-fields which are to some extent implementation
    // defined (see https://en.cppreference.com/w/c/language/bit_field).  As a
    // consequence it is discouraged to use cpu_features as a shared library
    // because different compilers may interpret the code in different ways.
    // Prefer static linking from source whenever possible.
    // option(BUILD_SHARED_LIBS "Build library as shared." OFF)

// GraphBLAS avoids this issue by compiling the cpu_features source directly
// into the libgraphblas.so and libgraphblas.a compiled libraries themselves.
// This ensures that the same compiler is used for both GraphBLAS and
// cpu_features.

// This file simply #include's all of the cpu_features/src/impl_*.c files,
// one for each architecture (and multiple ones for x86).  The supporting
// files for cpu_features are #include'd by GB_cpu_features_support.c.

#include "GB_cpu_features.h"

#if !defined ( GBNCPUFEAT )

    // include the implementation files from cpu_features/src/impl_*.c
    #include "src/impl_aarch64.c"
    #include "src/impl_arm_linux_or_android.c"
    #include "src/impl_mips_linux_or_android.c"
    #include "src/impl_ppc_linux.c"
    #include "src/impl_x86_freebsd.c"
    #include "src/impl_x86_linux_or_android.c"
    #include "src/impl_x86_windows.c"
    #if GBX86
        #if (defined(__apple__) || defined(__APPLE__) || defined(__MACH__))
        // needed for src/impl_x86_macos.c:
        #define HAVE_SYSCTLBYNAME
        #endif
    #endif
    #include "src/impl_x86_macos.c"

#endif