Welcome to mirror list, hosted at ThFree Co, Russian Federation.

check_cpu_features.cpp.in « cpu_features « modules « cmake « libc - github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3771129b4a56cf576540defe61b9d8ef330c8932 (plain)
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
#include <cstdio>
#include <cstdlib>

// This file is instantiated by CMake.
// DEFINITIONS below is replaced with a set of lines like so:
//   #ifdef __SSE2__
//     "SSE2",
//   #endif
//
// This allows for introspection of compiler definitions.
// The output of the program is a single line of semi colon separated feature
// names.

// MSVC is using a different set of preprocessor definitions for 
// SSE and SSE2, see _M_IX86_FP in
// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros

int main(int, char **) {
  const char *strings[] = {
      @DEFINITIONS@
      // If DEFINITIONS turns out to be empty, we don't want to list
      // an empty array. So, we add an end of list marker.
      "<end_of_feature_list>"
  };
  const size_t size = sizeof(strings) / sizeof(strings[0]);
  for (size_t i = 0; i < size; ++i) {
    if (i)
      putchar(';');
    fputs(strings[i], stdout);
  }
  return EXIT_SUCCESS;
}