brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 0c28179 Raw
72 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H10#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H11 12// BEGIN FIXME13// 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// END18 19#include "lldb/Host/Config.h"20 21// Python.h needs to be included before any system headers in order to avoid22// redefinition of macros23 24#if LLDB_ENABLE_PYTHON25#include "llvm/Support/Compiler.h"26#if defined(_WIN32)27// If anyone #includes Host/PosixApi.h later, it will try to typedef pid_t.  We28// need to ensure this doesn't happen.  At the same time, Python.h will also try29// to redefine a bunch of stuff that PosixApi.h defines.  So define it all now30// so that PosixApi.h doesn't redefine it.31#define NO_PID_T32#endif33#if defined(__linux__)34// features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined.  This value35// may be different from the value that Python defines it to be which results36// in a warning.  Undefine _POSIX_C_SOURCE before including Python.h  The same37// holds for _XOPEN_SOURCE.38#undef _POSIX_C_SOURCE39#undef _XOPEN_SOURCE40#endif41 42// Include locale before Python so _PY_PORT_CTYPE_UTF8_ISSUE doesn't cause43// macro redefinitions.44#if defined(__APPLE__)45#include <locale>46#endif47 48#define LLDB_MINIMUM_PYTHON_VERSION 0x0308000049 50#if LLDB_ENABLE_PYTHON_LIMITED_API51// If defined, LLDB will be ABI-compatible with all Python 3 releases from the52// specified one onward, and can use Limited API introduced up to that version.53#define Py_LIMITED_API LLDB_MINIMUM_PYTHON_VERSION54#endif55 56// Include python for non windows machines57#include <Python.h>58 59// Provide a meaningful diagnostic error if someone tries to compile this file60// with a version of Python we don't support.61static_assert(PY_VERSION_HEX >= LLDB_MINIMUM_PYTHON_VERSION,62              "LLDB requires at least Python 3.8");63 64// PyMemoryView_FromMemory is part of stable ABI but the flag constants are not.65// See https://github.com/python/cpython/issues/9868066#ifndef PyBUF_READ67#define PyBUF_READ 0x10068#endif69#endif70 71#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H72