TRLC Platform Library  1.0.0
Header-only C++ library for compile-time platform detection and abstraction
features.hpp File Reference

Language and runtime feature detection utilities. More...

#include <cstdint>

Go to the source code of this file.

Classes

struct  trlc::platform::FeatureSet
 Feature detection structure. More...
 

Namespaces

 trlc
 
 trlc::platform
 

Macros

#define TRLC_HAS_X86_INTRINSICS   0
 
#define TRLC_HAS_ARM_INTRINSICS   0
 
#define TRLC_HAS_EXCEPTIONS   (trlc::platform::hasExceptions())
 Check if C++ exceptions are available. More...
 
#define TRLC_HAS_RTTI   (trlc::platform::hasRtti())
 Check if RTTI is available. More...
 
#define TRLC_HAS_THREADS   (trlc::platform::hasThreads())
 Check if threading support is available. More...
 
#define TRLC_HAS_ATOMIC   (trlc::platform::hasAtomicOperations())
 Check if atomic operations are available. More...
 
#define TRLC_HAS_INLINE_ASM   (trlc::platform::hasInlineAssembly())
 Check if inline assembly is available. More...
 
#define TRLC_HAS_VECTOR_INTRINSICS   (trlc::platform::hasVectorIntrinsics())
 Check if vector intrinsics are available. More...
 
#define TRLC_HAS_STACK_PROTECTION   (trlc::platform::hasStackProtection())
 Check if stack protection is enabled. More...
 
#define TRLC_HAS_ADDRESS_SANITIZER   (trlc::platform::hasAddressSanitizer())
 Check if AddressSanitizer is enabled. More...
 
#define TRLC_HAS_THREAD_SANITIZER   (trlc::platform::hasThreadSanitizer())
 Check if ThreadSanitizer is enabled. More...
 
#define TRLC_HAS_MEMORY_SANITIZER   (trlc::platform::hasMemorySanitizer())
 Check if MemorySanitizer is enabled. More...
 
#define TRLC_HAS_UNDEFINED_BEHAVIOR_SANITIZER   (trlc::platform::hasUndefinedBehaviorSanitizer())
 Check if UndefinedBehaviorSanitizer is enabled. More...
 
#define TRLC_HAS_FEATURE(X)   (trlc::platform::hasFeature<trlc::platform::LanguageFeature::X>())
 Generic feature test macro. More...
 
#define TRLC_HAS_SSE_RUNTIME()   (trlc::platform::hasSseSupport())
 Check SSE support at runtime. More...
 
#define TRLC_HAS_SSE2_RUNTIME()   (trlc::platform::hasSse2Support())
 Check SSE2 support at runtime. More...
 
#define TRLC_HAS_SSE3_RUNTIME()   (trlc::platform::hasSse3Support())
 Check SSE3 support at runtime. More...
 
#define TRLC_HAS_SSE41_RUNTIME()   (trlc::platform::hasSse41Support())
 Check SSE4.1 support at runtime. More...
 
#define TRLC_HAS_SSE42_RUNTIME()   (trlc::platform::hasSse42Support())
 Check SSE4.2 support at runtime. More...
 
#define TRLC_HAS_AVX_RUNTIME()   (trlc::platform::hasAvxSupport())
 Check AVX support at runtime. More...
 
#define TRLC_HAS_AVX2_RUNTIME()   (trlc::platform::hasAvx2Support())
 Check AVX2 support at runtime. More...
 
#define TRLC_HAS_AVX512F_RUNTIME()   (trlc::platform::hasAvx512fSupport())
 Check AVX-512F support at runtime. More...
 
#define TRLC_HAS_NEON_RUNTIME()   (trlc::platform::hasNeonSupport())
 Check NEON support at runtime. More...
 
#define TRLC_HAS_HARDWARE_AES_RUNTIME()   (trlc::platform::hasHardwareAes())
 Check hardware AES support at runtime. More...
 
#define TRLC_HAS_HARDWARE_RANDOM_RUNTIME()   (trlc::platform::hasHardwareRandom())
 Check hardware RNG support at runtime. More...
 
#define TRLC_IF_EXCEPTIONS(code)   ((void)0)
 Execute code only if exceptions are available. More...
 
#define TRLC_IF_RTTI(code)   ((void)0)
 Execute code only if RTTI is available. More...
 
#define TRLC_IF_THREADS(code)   ((void)0)
 Execute code only if threading is available. More...
 

Enumerations

enum class  trlc::platform::LanguageFeature : int {
  trlc::platform::exceptions = 0 , trlc::platform::rtti , trlc::platform::threads , trlc::platform::atomic_operations ,
  trlc::platform::inline_assembly , trlc::platform::vector_intrinsics , trlc::platform::stack_protection , trlc::platform::address_sanitizer ,
  trlc::platform::thread_sanitizer , trlc::platform::memory_sanitizer , trlc::platform::undefined_behavior_sanitizer
}
 Language feature enumeration. More...
 
enum class  trlc::platform::RuntimeFeature : int {
  trlc::platform::sse = 0 , trlc::platform::sse2 , trlc::platform::sse3 , trlc::platform::sse4_1 ,
  trlc::platform::sse4_2 , trlc::platform::avx , trlc::platform::avx2 , trlc::platform::avx512f ,
  trlc::platform::neon , trlc::platform::hardware_aes , trlc::platform::hardware_random
}
 Runtime feature enumeration. More...
 

Functions

static bool trlc::platform::hasExceptions ()
 Detects if C++ exceptions are enabled. More...
 
static bool trlc::platform::hasRtti ()
 Detects if RTTI (Runtime Type Information) is enabled. More...
 
static bool trlc::platform::hasThreads ()
 Detects if threading support is available. More...
 
static bool trlc::platform::hasAtomicOperations ()
 Detects if atomic operations are supported. More...
 
static bool trlc::platform::hasInlineAssembly ()
 Detects if inline assembly is supported. More...
 
static bool trlc::platform::hasVectorIntrinsics ()
 Detects if vector intrinsics are available. More...
 
static bool trlc::platform::hasStackProtection ()
 Detects if stack protection is enabled. More...
 
static bool trlc::platform::hasAddressSanitizer ()
 Detects if AddressSanitizer is enabled. More...
 
static bool trlc::platform::hasThreadSanitizer ()
 Detects if ThreadSanitizer is enabled. More...
 
static bool trlc::platform::hasMemorySanitizer ()
 Detects if MemorySanitizer is enabled. More...
 
static bool trlc::platform::hasUndefinedBehaviorSanitizer ()
 Detects if UndefinedBehaviorSanitizer is enabled. More...
 
bool trlc::platform::hasSseSupport ()
 Detects SSE support at runtime. More...
 
bool trlc::platform::hasSse2Support ()
 Detects SSE2 support at runtime. More...
 
bool trlc::platform::hasSse3Support ()
 Detects SSE3 support at runtime. More...
 
bool trlc::platform::hasSse41Support ()
 Detects SSE4.1 support at runtime. More...
 
bool trlc::platform::hasSse42Support ()
 Detects SSE4.2 support at runtime. More...
 
bool trlc::platform::hasAvxSupport ()
 Detects AVX support at runtime. More...
 
bool trlc::platform::hasAvx2Support ()
 Detects AVX2 support at runtime. More...
 
bool trlc::platform::hasAvx512fSupport ()
 Detects AVX-512F support at runtime. More...
 
bool trlc::platform::hasNeonSupport ()
 Detects ARM NEON support. More...
 
bool trlc::platform::hasHardwareAes ()
 Detects hardware AES support. More...
 
bool trlc::platform::hasHardwareRandom ()
 Detects hardware random number generation support. More...
 
static FeatureSet trlc::platform::getFeatureSet ()
 Gets a complete feature set with all detected features. More...
 
static bool trlc::platform::hasLanguageFeature (LanguageFeature feature)
 Checks if a specific language feature is available. More...
 
bool trlc::platform::hasRuntimeFeature (RuntimeFeature feature)
 Checks if a specific runtime feature is available. More...
 
template<LanguageFeature TFeature>
static bool trlc::platform::hasFeature ()
 Generic template function for feature testing. More...
 

Detailed Description

Language and runtime feature detection utilities.

This header provides compile-time language feature detection and runtime CPU feature detection for cross-platform C++ development. Language features are detected at compile time with zero overhead, while CPU features may require runtime detection.

Definition in file features.hpp.

Macro Definition Documentation

◆ TRLC_HAS_ADDRESS_SANITIZER

#define TRLC_HAS_ADDRESS_SANITIZER   (trlc::platform::hasAddressSanitizer())

Check if AddressSanitizer is enabled.

Definition at line 692 of file features.hpp.

◆ TRLC_HAS_ARM_INTRINSICS

#define TRLC_HAS_ARM_INTRINSICS   0

Definition at line 36 of file features.hpp.

◆ TRLC_HAS_ATOMIC

#define TRLC_HAS_ATOMIC   (trlc::platform::hasAtomicOperations())

Check if atomic operations are available.

Definition at line 680 of file features.hpp.

◆ TRLC_HAS_AVX2_RUNTIME

#define TRLC_HAS_AVX2_RUNTIME ( )    (trlc::platform::hasAvx2Support())

Check AVX2 support at runtime.

Definition at line 729 of file features.hpp.

◆ TRLC_HAS_AVX512F_RUNTIME

#define TRLC_HAS_AVX512F_RUNTIME ( )    (trlc::platform::hasAvx512fSupport())

Check AVX-512F support at runtime.

Definition at line 732 of file features.hpp.

◆ TRLC_HAS_AVX_RUNTIME

#define TRLC_HAS_AVX_RUNTIME ( )    (trlc::platform::hasAvxSupport())

Check AVX support at runtime.

Definition at line 726 of file features.hpp.

◆ TRLC_HAS_EXCEPTIONS

#define TRLC_HAS_EXCEPTIONS   (trlc::platform::hasExceptions())

Check if C++ exceptions are available.

Definition at line 671 of file features.hpp.

◆ TRLC_HAS_FEATURE

#define TRLC_HAS_FEATURE (   X)    (trlc::platform::hasFeature<trlc::platform::LanguageFeature::X>())

Generic feature test macro.

Definition at line 704 of file features.hpp.

◆ TRLC_HAS_HARDWARE_AES_RUNTIME

#define TRLC_HAS_HARDWARE_AES_RUNTIME ( )    (trlc::platform::hasHardwareAes())

Check hardware AES support at runtime.

Definition at line 738 of file features.hpp.

◆ TRLC_HAS_HARDWARE_RANDOM_RUNTIME

#define TRLC_HAS_HARDWARE_RANDOM_RUNTIME ( )    (trlc::platform::hasHardwareRandom())

Check hardware RNG support at runtime.

Definition at line 741 of file features.hpp.

◆ TRLC_HAS_INLINE_ASM

#define TRLC_HAS_INLINE_ASM   (trlc::platform::hasInlineAssembly())

Check if inline assembly is available.

Definition at line 683 of file features.hpp.

◆ TRLC_HAS_MEMORY_SANITIZER

#define TRLC_HAS_MEMORY_SANITIZER   (trlc::platform::hasMemorySanitizer())

Check if MemorySanitizer is enabled.

Definition at line 698 of file features.hpp.

◆ TRLC_HAS_NEON_RUNTIME

#define TRLC_HAS_NEON_RUNTIME ( )    (trlc::platform::hasNeonSupport())

Check NEON support at runtime.

Definition at line 735 of file features.hpp.

◆ TRLC_HAS_RTTI

#define TRLC_HAS_RTTI   (trlc::platform::hasRtti())

Check if RTTI is available.

Definition at line 674 of file features.hpp.

◆ TRLC_HAS_SSE2_RUNTIME

#define TRLC_HAS_SSE2_RUNTIME ( )    (trlc::platform::hasSse2Support())

Check SSE2 support at runtime.

Definition at line 714 of file features.hpp.

◆ TRLC_HAS_SSE3_RUNTIME

#define TRLC_HAS_SSE3_RUNTIME ( )    (trlc::platform::hasSse3Support())

Check SSE3 support at runtime.

Definition at line 717 of file features.hpp.

◆ TRLC_HAS_SSE41_RUNTIME

#define TRLC_HAS_SSE41_RUNTIME ( )    (trlc::platform::hasSse41Support())

Check SSE4.1 support at runtime.

Definition at line 720 of file features.hpp.

◆ TRLC_HAS_SSE42_RUNTIME

#define TRLC_HAS_SSE42_RUNTIME ( )    (trlc::platform::hasSse42Support())

Check SSE4.2 support at runtime.

Definition at line 723 of file features.hpp.

◆ TRLC_HAS_SSE_RUNTIME

#define TRLC_HAS_SSE_RUNTIME ( )    (trlc::platform::hasSseSupport())

Check SSE support at runtime.

Definition at line 711 of file features.hpp.

◆ TRLC_HAS_STACK_PROTECTION

#define TRLC_HAS_STACK_PROTECTION   (trlc::platform::hasStackProtection())

Check if stack protection is enabled.

Definition at line 689 of file features.hpp.

◆ TRLC_HAS_THREAD_SANITIZER

#define TRLC_HAS_THREAD_SANITIZER   (trlc::platform::hasThreadSanitizer())

Check if ThreadSanitizer is enabled.

Definition at line 695 of file features.hpp.

◆ TRLC_HAS_THREADS

#define TRLC_HAS_THREADS   (trlc::platform::hasThreads())

Check if threading support is available.

Definition at line 677 of file features.hpp.

◆ TRLC_HAS_UNDEFINED_BEHAVIOR_SANITIZER

#define TRLC_HAS_UNDEFINED_BEHAVIOR_SANITIZER   (trlc::platform::hasUndefinedBehaviorSanitizer())

Check if UndefinedBehaviorSanitizer is enabled.

Definition at line 701 of file features.hpp.

◆ TRLC_HAS_VECTOR_INTRINSICS

#define TRLC_HAS_VECTOR_INTRINSICS   (trlc::platform::hasVectorIntrinsics())

Check if vector intrinsics are available.

Definition at line 686 of file features.hpp.

◆ TRLC_HAS_X86_INTRINSICS

#define TRLC_HAS_X86_INTRINSICS   0

Definition at line 27 of file features.hpp.

◆ TRLC_IF_EXCEPTIONS

#define TRLC_IF_EXCEPTIONS (   code)    ((void)0)

Execute code only if exceptions are available.

Definition at line 753 of file features.hpp.

◆ TRLC_IF_RTTI

#define TRLC_IF_RTTI (   code)    ((void)0)

Execute code only if RTTI is available.

Definition at line 762 of file features.hpp.

◆ TRLC_IF_THREADS

#define TRLC_IF_THREADS (   code)    ((void)0)

Execute code only if threading is available.

Definition at line 775 of file features.hpp.