]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/main.cpp
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / register / intel_xtended_registers / main.cpp
1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
2 ////
3 ////                     The LLVM Compiler Infrastructure
4 ////
5 //// This file is distributed under the University of Illinois Open Source
6 //// License. See LICENSE.TXT for details.
7 ////
8 ////===----------------------------------------------------------------------===//
9 //
10
11 #include <cpuid.h>
12 #include <cstddef>
13
14 int
15 main(int argc, char const *argv[])
16 {
17     // This call returns 0 only if the CPU and the kernel support Intel(R) MPX.
18     if (prctl(PR_MPX_ENABLE_MANAGEMENT, 0, 0, 0, 0) != 0)
19         return -1;
20
21 // Run Intel(R) MPX test code.
22 #if defined(__x86_64__)
23     asm("mov $16, %rax\n\t"
24         "mov $9, %rdx\n\t"
25         "bndmk (%rax,%rdx), %bnd0\n\t"
26         "mov $32, %rax\n\t"
27         "mov $9, %rdx\n\t"
28         "bndmk (%rax,%rdx), %bnd1\n\t"
29         "mov $48, %rax\n\t"
30         "mov $9, %rdx\n\t"
31         "bndmk (%rax,%rdx), %bnd2\n\t"
32         "mov $64, %rax\n\t"
33         "mov $9, %rdx\n\t"
34         "bndmk (%rax,%rdx), %bnd3\n\t"
35         "bndstx %bnd3, (%rax) \n\t"
36         "nop\n\t");
37 #endif
38 #if defined(__i386__)
39     asm("mov $16, %eax\n\t"
40         "mov $9, %edx\n\t"
41         "bndmk (%eax,%edx), %bnd0\n\t"
42         "mov $32, %eax\n\t"
43         "mov $9, %edx\n\t"
44         "bndmk (%eax,%edx), %bnd1\n\t"
45         "mov $48, %eax\n\t"
46         "mov $9, %edx\n\t"
47         "bndmk (%eax,%edx), %bnd2\n\t"
48         "mov $64, %eax\n\t"
49         "mov $9, %edx\n\t"
50         "bndmk (%eax,%edx), %bnd3\n\t"
51         "bndstx  %bnd3, (%eax)\n\t"
52         "nop\n\t");
53 #endif
54     asm("nop\n\t"); // Set a break point here.
55
56     return 0;
57 }