mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
# Conflicts: # .github/workflows/main.yml # include/etl/version.h # library.json # library.properties # support/Release notes.txt # test/vs2019/etl.vcxproj.filters
173 lines
5.1 KiB
C
173 lines
5.1 KiB
C
///\file
|
|
|
|
/******************************************************************************
|
|
The MIT License(MIT)
|
|
|
|
Embedded Template Library.
|
|
https://github.com/ETLCPP/etl
|
|
https://www.etlcpp.com
|
|
|
|
Copyright(c) 2016 jwellbelove
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files(the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions :
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
******************************************************************************/
|
|
|
|
#ifndef ETL_PLATFORM_INCLUDED
|
|
#define ETL_PLATFORM_INCLUDED
|
|
|
|
#include <stdint.h>
|
|
#include <limits.h>
|
|
|
|
// Some targets do not support 8bit types.
|
|
#define ETL_8BIT_SUPPORT (CHAR_BIT == 8)
|
|
|
|
// Define a debug macro
|
|
#if (defined(_DEBUG) || defined(DEBUG)) && !defined(ETL_DEBUG)
|
|
#define ETL_DEBUG
|
|
#endif
|
|
|
|
// Determine the bit width of the platform.
|
|
#define ETL_PLATFORM_16BIT (UINT16_MAX == UINTPTR_MAX)
|
|
#define ETL_PLATFORM_32BIT (UINT32_MAX == UINTPTR_MAX)
|
|
#define ETL_PLATFORM_64BIT (UINT64_MAX == UINTPTR_MAX)
|
|
|
|
// Include the user's profile definition.
|
|
#if !defined(ETL_NO_PROFILE_HEADER) && defined(__has_include)
|
|
#if !__has_include("etl_profile.h")
|
|
#define ETL_NO_PROFILE_HEADER
|
|
#endif
|
|
#endif
|
|
|
|
#if !defined(ETL_NO_PROFILE_HEADER)
|
|
#include "etl_profile.h"
|
|
#endif
|
|
|
|
// Helper macro, so we don't have to use double negatives.
|
|
// The ETL will use the STL, unless ETL_NO_STL is defined.
|
|
// With this macro we can use '#if ETL_USING_STL' instead of '#if !ETL_NO_STL' in the code.
|
|
#if defined(ETL_NO_STL)
|
|
#define ETL_USING_STL 0
|
|
#define ETL_NOT_USING_STL 1
|
|
#else
|
|
#define ETL_USING_STL 1
|
|
#define ETL_NOT_USING_STL 0
|
|
#endif
|
|
|
|
// Helper macros for ETL_STLPORT.
|
|
#if defined(ETL_STLPORT)
|
|
#define ETL_USING_STLPORT 1
|
|
#define ETL_NOT_USING_STLPORT 0
|
|
#else
|
|
#define ETL_USING_STLPORT 0
|
|
#define ETL_NOT_USING_STLPORT 1
|
|
#endif
|
|
|
|
// Helper macro for ETL_NO_64BIT_TYPES.
|
|
#if defined(ETL_NO_64BIT_TYPES)
|
|
#define ETL_USING_64BIT_TYPES 0
|
|
#define ETL_NOT_USING_64BIT_TYPES 1
|
|
#else
|
|
#define ETL_USING_64BIT_TYPES 1
|
|
#define ETL_NOT_USING_64BIT_TYPES 0
|
|
#endif
|
|
|
|
// Figure out things about the compiler, if haven't already done so in etl_profile.h
|
|
#include "profiles/determine_compiler_version.h"
|
|
#include "profiles/determine_compiler_language_support.h"
|
|
|
|
// See if we can determine the OS we're compiling on, if haven't already done so in etl_profile.h
|
|
#include "profiles/determine_development_os.h"
|
|
|
|
// Option to force string construction from a character pointer to be explicit.
|
|
#if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR)
|
|
#define ETL_EXPLICIT_STRING_FROM_CHAR explicit
|
|
#else
|
|
#define ETL_EXPLICIT_STRING_FROM_CHAR
|
|
#endif
|
|
|
|
// The macros below are dependent on the profile.
|
|
// C++11
|
|
#if ETL_CPP11_SUPPORTED && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
|
#define ETL_CONSTEXPR constexpr
|
|
#define ETL_CONST_OR_CONSTEXPR constexpr
|
|
#define ETL_DELETE = delete
|
|
#define ETL_EXPLICIT explicit
|
|
#define ETL_OVERRIDE override
|
|
#define ETL_FINAL final
|
|
#define ETL_NORETURN [[noreturn]]
|
|
|
|
#if defined(ETL_THROW_EXCEPTIONS)
|
|
#define ETL_NOEXCEPT noexcept
|
|
#define ETL_NOEXCEPT_EXPR(expression) noexcept(expression)
|
|
#else
|
|
#define ETL_NOEXCEPT
|
|
#define ETL_NOEXCEPT_EXPR(expression)
|
|
#endif
|
|
#else
|
|
#define ETL_CONSTEXPR
|
|
#define ETL_CONST_OR_CONSTEXPR const
|
|
#define ETL_DELETE
|
|
#define ETL_EXPLICIT
|
|
#define ETL_OVERRIDE
|
|
#define ETL_FINAL
|
|
#define ETL_NORETURN
|
|
#define ETL_NOEXCEPT
|
|
#define ETL_NOEXCEPT_EXPR(expression)
|
|
#endif
|
|
|
|
// C++14
|
|
#if ETL_CPP14_SUPPORTED && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
|
#define ETL_CONSTEXPR14 constexpr
|
|
#define ETL_DEPRECATED [[deprecated]]
|
|
#define ETL_DEPRECATED_REASON(reason) [[deprecated(reason)]]
|
|
#else
|
|
#define ETL_CONSTEXPR14
|
|
#define ETL_DEPRECATED
|
|
#define ETL_DEPRECATED_REASON(reason)
|
|
#endif
|
|
|
|
// C++17
|
|
#if ETL_CPP17_SUPPORTED && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
|
#define ETL_CONSTEXPR17 constexpr
|
|
#define ETL_IF_CONSTEXPR constexpr
|
|
#define ETL_NODISCARD [[nodiscard]]
|
|
#define ETL_FALLTHROUGH [[fallthrough]]
|
|
#else
|
|
#define ETL_CONSTEXPR17
|
|
#define ETL_IF_CONSTEXPR
|
|
#define ETL_NODISCARD
|
|
#define ETL_FALLTHROUGH
|
|
#endif
|
|
|
|
// C++20
|
|
#if ETL_CPP20_SUPPORTED && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
|
#define ETL_LIKELY [[likely]]
|
|
#define ETL_UNLIKELY [[unlikely]]
|
|
#define ETL_CONSTEXPR20 constexpr
|
|
#else
|
|
#define ETL_LIKELY
|
|
#define ETL_UNLIKELY
|
|
#define ETL_CONSTEXPR20
|
|
#endif
|
|
|
|
// Sort out namespaces for STL/No STL options.
|
|
#include "private/choose_namespace.h"
|
|
|
|
#endif
|