LLDB mainline
lldb-python.h
Go to the documentation of this file.
1//===-- lldb-python.h -------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
10#define LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
11
12// BEGIN FIXME
13// This declaration works around a clang module build failure.
14// It should be deleted ASAP.
15#include "llvm/Support/Error.h"
16static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
17// END
18
19#include "llvm/Support/Compiler.h"
20#if defined(_WIN32)
21// If anyone #includes Host/PosixApi.h later, it will try to typedef pid_t. We
22// need to ensure this doesn't happen. At the same time, Python.h will also try
23// to redefine a bunch of stuff that PosixApi.h defines. So define it all now
24// so that PosixApi.h doesn't redefine it.
25#define NO_PID_T
26#endif
27#if defined(__linux__)
28// features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
29// may be different from the value that Python defines it to be which results
30// in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
31// holds for _XOPEN_SOURCE.
32#undef _POSIX_C_SOURCE
33#undef _XOPEN_SOURCE
34#endif
35
36// Include locale before Python so _PY_PORT_CTYPE_UTF8_ISSUE doesn't cause
37// macro redefinitions.
38#if defined(__APPLE__)
39#include <locale>
40#endif
41
42#define LLDB_MINIMUM_PYTHON_VERSION 0x03080000
43
44#if LLDB_ENABLE_PYTHON_LIMITED_API
45// If defined, LLDB will be ABI-compatible with all Python 3 releases from the
46// specified one onward, and can use Limited API introduced up to that version.
47#define Py_LIMITED_API LLDB_MINIMUM_PYTHON_VERSION
48#endif
49
50// Include python for non windows machines
51#include <Python.h>
52
53// Provide a meaningful diagnostic error if someone tries to compile this file
54// with a version of Python we don't support.
55static_assert(PY_VERSION_HEX >= LLDB_MINIMUM_PYTHON_VERSION,
56 "LLDB requires at least Python 3.8");
57
58// PyMemoryView_FromMemory is part of stable ABI but the flag constants are not.
59// See https://github.com/python/cpython/issues/98680
60#ifndef PyBUF_READ
61#define PyBUF_READ 0x100
62#endif
63
64#endif // LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
#define LLDB_MINIMUM_PYTHON_VERSION
Definition lldb-python.h:42
static llvm::Expected< bool > * g_fcxx_modules_workaround
Definition lldb-python.h:16