Files
pip/libs/main/piplatform.h
andrey 94084fb351 Merge branch 'master' into webasm
Переработка ветки под систему фиче-флагов master:
- CMake-секция PIP_WASM (платформа, аналог PICO/FREERTOS): принудительный
  OFF PIP_HAS_SOCKET/PROCESS/DYNLIB/SERIAL и PIP_BUILD_CONSOLE/USB/OPENCL/
  FFTW/LUA/MQTT_CLIENT/HTTP_SERVER/HTTP_CLIENT до pip_resolve_feature_flags();
  таблица зависимостей довыключает client_server/cloud/introspection
- Файлы, покрытые фиче-флагами master (piethernet/piserial/pican/pilibrary/
  piprocess): взята master-версия, EMSCRIPTEN-стубы webasm удалены как
  мёртвый код (нет флага — нет класса)
- Сохранены EMSCRIPTEN-гварды там, где флаги не покрывают поведение:
  pihidevice (компилируется под wasm), piinit (initSignals/initLocale/
  initUsername/initOSname/initHWInfo), pisysteminfo (instance/machineKey),
  pithread (gettid-фоллбэк), picout (EM_ASM console.log),
  pibase_macros (PIP_MIN_MSLEEP), pipiplatform.h (EMSCRIPTEN/ARCH_BITS)
- Исправлен AUTO-merge в PISystemInfo::machineKey() (семантический баг:
  пустой результат при PIP_HAS_FILESYSTEM=OFF)

Проверено: нативный ctest 364/364 (build-verify), wasm-сборка (build_wasm,
лишь libpip.a + libpip_io_utils.a + pcre2), node-смоук-тест PICout/PISystemInfo
2026-09-19 11:01:39 +03:00

232 lines
6.4 KiB
C

/*! \file piplatform.h
* \ingroup Core
* \~\brief
* \~english Public platform and compiler detection macros
* \~russian Публичные макросы определения платформы и компилятора
*
* \~\details
* \~english
* This header defines portability macros that can be used in public PIP-aware
* code for platform, compiler and architecture checks.
* \~russian
* Этот заголовок определяет макросы переносимости, которые можно использовать
* в публичном PIP-коде для проверки платформы, компилятора и архитектуры.
*/
/*
PIP - Platform Independent Primitives
Platform and compiler macros
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPLATFORM_H
#define PIPLATFORM_H
#include <pip_export.h>
#ifdef DOXYGEN
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Windows targets.
//! \~russian Определяется для целевых сборок Windows.
# define WINDOWS
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Linux targets.
//! \~russian Определяется для целевых сборок Linux.
# define LINUX
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for macOS targets.
//! \~russian Определяется для целевых сборок macOS.
# define MAC_OS
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Android targets.
//! \~russian Определяется для целевых сборок Android.
# define ANDROID
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for QNX targets.
//! \~russian Определяется для целевых сборок QNX.
# define QNX
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for FreeBSD targets.
//! \~russian Определяется для целевых сборок FreeBSD.
# define FREE_BSD
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Emscripten targets.
//! \~russian Определяется для целевых сборок Emscripten.
# define EMSCRIPTEN
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for reduced embedded PIP builds.
//! \~russian Определяется для облегченных встраиваемых сборок PIP.
# define PIP_EMBEDDED
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when the target architecture is 32-bit.
//! \~russian Определяется, когда целевая архитектура 32-битная.
# define ARCH_BITS_32
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when the target architecture is 64-bit.
//! \~russian Определяется, когда целевая архитектура 64-битная.
# define ARCH_BITS_64
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for GCC-compatible compilers.
//! \~russian Определяется для GCC-совместимых компиляторов.
# define CC_GCC
//! \~\ingroup Core
//! \~\brief
//! \~english Encoded GCC major and minor version for \a CC_GCC builds.
//! \~russian Содержит закодированную основную и дополнительную версию GCC для сборок с \a CC_GCC.
# define CC_GCC_VERSION
//! \~\ingroup Core
//! \~\brief
//! \~english Defined for Microsoft Visual C++.
//! \~russian Определяется для Microsoft Visual C++.
# define CC_VC
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when no dedicated compiler macro above matched.
//! \~russian Определяется, когда ни один специализированный макрос компилятора выше не подошел.
# define CC_OTHER
//! \~\ingroup Core
//! \~\brief
//! \~english Defined when POSIX signal APIs are expected to be available.
//! \~russian Определяется, когда ожидается доступность POSIX API сигналов.
# define POSIX_SIGNALS
#endif
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
# define WINDOWS
# define ARCH_BITS_64
#else
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
# define WINDOWS
# define ARCH_BITS_32
# endif
#endif
#if defined(__QNX__) || defined(__QNXNTO__)
# define QNX
# ifdef Q_OS_BLACKBERRY
# define BLACKBERRY
# endif
#endif
#ifdef __FreeBSD__
# define FREE_BSD
#endif
#if defined(__APPLE__) || defined(__MACH__)
# define MAC_OS
#endif
#if defined(__ANDROID__) || defined(_ANDROID_) || defined(ANDROID)
# ifndef ANDROID
# define ANDROID
# endif
#endif
#ifdef PIP_FREERTOS
# define FREERTOS
#endif
#ifdef __EMSCRIPTEN__
# define EMSCRIPTEN
# ifdef __wasm64__
# define ARCH_BITS_64
# else
# define ARCH_BITS_32
# endif
#endif
#ifndef WINDOWS
# ifndef QNX
# ifndef FREE_BSD
# ifndef MAC_OS
# ifndef ANDROID
# ifndef BLACKBERRY
# ifndef FREERTOS
# ifndef PICO_SDK
# ifndef EMSCRIPTEN
# define LINUX
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
#endif
#ifndef WINDOWS
# ifndef EMSCRIPTEN
# if defined(__LP64__) || defined(_LP64_) || defined(LP64)
# define ARCH_BITS_64
# else
# define ARCH_BITS_32
# endif
# endif
#endif
#ifdef __GNUC__
# define CC_GCC
# define CC_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__)
#elif defined(_MSC_VER)
# define CC_VC
#else
# define CC_OTHER
#endif
#ifdef __AVR__
# define CC_AVR_GCC
#endif
#ifdef WINDOWS
# ifdef CC_GCC
# define typeof __typeof
# endif
#else
# define typeof __typeof__
#endif
#if defined(LINUX) || defined(MAC_OS) || defined(ANDROID)
# define POSIX_SIGNALS
#endif
// Platform provides a text terminal (termios TTY) for console keyboard I/O
#if defined(LINUX) || defined(MAC_OS) || defined(ANDROID) || defined(QNX) || defined(FREE_BSD)
# define PIP_HAS_TTY
#endif
#endif // PIPLATFORM_H