[SimplifyCFG] Always allow hoisting if all instructions match. (#97158)
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / make / test_common.h
blobaa8960e1c0aea771ec72661bb27640aacb3237f6
1 // This header is included in all the test programs (C and C++) and provides a
2 // hook for dealing with platform-specifics.
4 #if defined(_WIN32) || defined(_WIN64)
5 #define LLDB_DYLIB_EXPORT __declspec(dllexport)
6 #define LLDB_DYLIB_IMPORT __declspec(dllimport)
7 #else
8 #define LLDB_DYLIB_EXPORT
9 #define LLDB_DYLIB_IMPORT
10 #endif
12 #ifdef COMPILING_LLDB_TEST_DLL
13 #define LLDB_TEST_API LLDB_DYLIB_EXPORT
14 #else
15 #define LLDB_TEST_API LLDB_DYLIB_IMPORT
16 #endif
18 #if defined(_WIN32)
19 #define LLVM_PRETTY_FUNCTION __FUNCSIG__
20 #else
21 #define LLVM_PRETTY_FUNCTION LLVM_PRETTY_FUNCTION
22 #endif
25 // On some systems (e.g., some versions of linux) it is not possible to attach to a process
26 // without it giving us special permissions. This defines the lldb_enable_attach macro, which
27 // should perform any such actions, if needed by the platform. This is a macro instead of a
28 // function to avoid the need for complex linking of the test programs.
29 #if defined(__linux__)
30 #include <sys/prctl.h>
32 // Android API <= 16 does not have these defined.
33 #ifndef PR_SET_PTRACER
34 #define PR_SET_PTRACER 0x59616d61
35 #endif
36 #ifndef PR_SET_PTRACER_ANY
37 #define PR_SET_PTRACER_ANY ((unsigned long)-1)
38 #endif
40 // For now we execute on best effort basis. If this fails for some reason, so be it.
41 #define lldb_enable_attach() \
42 do \
43 { \
44 const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); \
45 (void)prctl_result; \
46 } while (0)
48 #else // not linux
50 #define lldb_enable_attach()
52 #endif