TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Cross-platforms portable base definitions for the TSDuck project. More...
Classes | |
class | ts::null_mutex |
A null_mutex class which can be used to replace std::mutex or std::recursive_mutex . More... | |
struct | ts::ThreadSafetyMutex< THS > |
Define the appropriate mutex class for a given level of thread-safety. More... | |
Namespaces | |
namespace | ts |
TSDuck namespace, containing all TSDuck classes and functions. | |
Macros | |
#define | TS_ADDRESS_BITS 16, 32, 64, etc. |
Number of bits in an address (or a pointer or a size_t). | |
#define | TS_AIX |
Defined when compiled for an IBM AIX target platform. | |
#define | TS_ANDROID |
Defined when compiled for an Android target platform. | |
#define | TS_ARM32 |
Defined when the target processor architecture is 32-bit ARM. | |
#define | TS_ARM64 |
Defined when the target processor architecture is 64-bit ARM. | |
#define | TS_BIG_ENDIAN |
Defined when compiled for a big-endian or MSB-first target platform. | |
#define | TS_BIG_ENDIAN_BOOL true/false |
Defined to true when compiled for a big-endian or MSB-first target platform, false otherwise. | |
#define | TS_BIG_ENDIAN_BOOL false |
Defined to true when compiled for a big-endian or MSB-first target platform, false otherwise. | |
#define | TS_BSD |
Defined when compiled for a BSD target platform (FreeBSD, OpenBSD, NetBSD, DragonFlyBSD). | |
#define | TS_CPLUSPLUS |
Level of C++ language, same as predefined __cplusplus, but safe with MSVC. | |
#define | TS_CXX17 |
Defined when the compiler is compliant with C++17. | |
#define | TS_CXX20 |
Defined when the compiler is compliant with C++20. | |
#define | TS_CXX23 |
Defined when the compiler is compliant with C++23. | |
#define | TS_CYGWIN |
Defined when compiled for a Cygwin target platform. | |
#define | TS_DEFAULT_ASSIGMENTS(classname) |
A macro to declare the default assignment operators in the declaration of a class. | |
#define | TS_DEFAULT_COPY_MOVE(classname) |
A macro to declare the default copy and move constructors and assignment operators in the declaration of a class. | |
#define | TS_DRAGONFLYBSD |
Defined when compiled for a DragonFlyBSD target platform. | |
#define | TS_FREEBSD |
Defined when compiled for a FreeBSD target platform. | |
#define | TS_FUNCTION |
Definition of the name of the current function. | |
#define | TS_GCC |
Defined when the compiler is GCC, also known as "GNU C", or a GCC-compatible compiler. | |
#define | TS_GCC_NOWARNING(name) |
Disable a warning with the GCC compiler (does nothing on other compilers). | |
#define | TS_GCC_ONLY |
Defined when the compiler is exactly GCC, also known as "GNU C", not a GCC-compatible compiler. | |
#define | TS_GCC_VERSION |
GCC version, encoded as an integer. | |
#define | TS_I386 |
Defined when the target processor architecture is Intel IA-32, also known as x86. | |
#define | TS_INTERFACE(classname) |
A macro to declare the basic operators in the declaration of an interface class. | |
#define | TS_LINUX |
Defined when compiled for a Linux target platform. | |
#define | TS_LITTLE_ENDIAN |
Defined when compiled for a little-endian or LSB-first target platform. | |
#define | TS_LITTLE_ENDIAN_BOOL true/false |
Defined to true when compiled for a little-endian or LSB-first target platform, false otherwise. | |
#define | TS_LITTLE_ENDIAN_BOOL true |
Defined to true when compiled for a little-endian or LSB-first target platform, false otherwise. | |
#define | TS_LLVM |
Defined when the compiler is LLVM (clang). | |
#define | TS_LLVM_NOWARNING(name) |
Disable a warning with the LLVM/clang compiler (does nothing on other compilers). | |
#define | TS_MAC |
Defined when compiled for a macOS target platform. | |
#define | TS_MIPS |
Defined when the target processor architecture is 32-bit MIPS architecture. | |
#define | TS_MIPS64 |
Defined when the target processor architecture is 64-bit MIPS architecture. | |
#define | TS_MSC |
Defined when the compiler is Microsoft C/C++, the default compiler in the Microsoft Visual Studio environment. | |
#define | TS_MSC_NOWARNING(num) |
Disable a warning with the Microsoft Visual C++ compiler (does nothing on other compilers). | |
#define | TS_NEED_UNEQUAL_OPERATOR 1 |
Defined when the != operator shall be defined in addition to ==. | |
#define | TS_NETBSD |
Defined when compiled for a NetBSD target platform. | |
#define | TS_NO_ARM_CRC32_INSTRUCTIONS |
Define TS_NO_ARM_CRC32_INSTRUCTIONS from the command line if you want to disable the usage of Arm64 CRC32 instructions. | |
#define | TS_NO_DEFAULT_CONSTRUCTORS(classname) |
A macro to disable default constructors in the declaration of a class. | |
#define | TS_NO_OPTIMIZE platform_specific |
Attribute to explicitly disable optimization in a function. | |
#define | TS_NOBUILD_NOCOPY(classname) |
A macro to disable default constructor and object copy in the declaration of a class. | |
#define | TS_NOCOPY(classname) |
A macro to disable object copy in the declaration of a class. | |
#define | TS_OPENBSD |
Defined when compiled for an OpenBSD target platform. | |
#define | TS_POP_WARNING() |
Restore the compiler's warnings reporting from a previous TS_PUSH_WARNING(). | |
#define | TS_POWERPC |
Defined when the target processor architecture is 32-bit Power PC. | |
#define | TS_POWERPC64 |
Defined when the target processor architecture is 64-bit Power PC. | |
#define | TS_PRAGMA(directive) |
Helper macro for the C++11 keyword _Pragma . | |
#define | TS_PUSH_WARNING() |
Save the compiler's warnings reporting. | |
#define | TS_RISCV64 |
Defined when the target processor architecture is 64-bit RISC-V. | |
#define | TS_RULE_OF_FIVE(classname, dtor_attributes) |
A macro to apply the C++ "rule of five" in the declaration of a class. | |
#define | TS_S390X |
Defined when the target processor architecture is S390X. | |
#define | TS_SLINE TS_STRINGIFY(__LINE__) |
String version of LINE | |
#define | TS_SOLARIS |
Defined when compiled for a Sun Solaris target platform. | |
#define | TS_SPARC |
Defined when the target processor architecture is Sun SPARC architecture. | |
#define | TS_STATIC_REFERENCE(suffix, addr) |
This macro generates a reference to some address (string literal, external symbol, etc.) The reference is a unique static symbol which is otherwise unused. | |
#define | TS_STRICT_MEMORY_ALIGN 1 |
Defined when the CPU requires strict memory alignment (address must be a multiple of the data size). | |
#define | TS_STRINGIFY(x) |
This macro transforms the value of a macro parameter into the equivalent string literal. | |
#define | TS_UNEQUAL_OPERATOR(classname) |
A macro to declare an unequal operator in the declaration of a class. | |
#define | TS_UNIQUE_NAME(prefix) |
This macro generates a unique name based on the source line number. | |
#define | TS_UNIX |
Defined when compiled for any flavor of UNIX target platforms. | |
#define | TS_USTRINGIFY(x) |
This macro transforms the value of a macro parameter into the equivalent 16-bit Unicode string literal. | |
#define | TS_WINDOWS |
Defined when compiled for a Microsoft Windows target platform. | |
#define | TS_X86_64 |
Defined when the target processor architecture is the 64-bit extension of the IA-32 architecture, also known as AMD-64 or Intel x86-64. | |
#define | TSDUCK_STATIC |
User-defined macro to enable full static linking. | |
#define | TSDUCK_STATIC_LIBRARY |
Applications which link against the TSDuck static library. | |
#define | TSDUCK_STATIC_PLUGINS |
User-defined macro to enable static linking of plugins. | |
#define | TSDUCKDLL |
Attribute to declare a class or function from tsduck.dll on Windows. | |
Typedefs | |
using | ts::char_ptr = char * |
Pointer to char . | |
using | ts::const_char_ptr = const char * |
Pointer to const char. | |
using | ts::const_int16_ptr = const int16_t * |
Pointer to const int16_t. | |
using | ts::const_int32_ptr = const int32_t * |
Pointer to const int32_t. | |
using | ts::const_int64_ptr = const int64_t * |
Pointer to const int64_t. | |
using | ts::const_int8_ptr = const int8_t * |
Pointer to const int8_t. | |
using | ts::const_uint16_ptr = const uint16_t * |
Pointer to const uint16_t. | |
using | ts::const_uint32_ptr = const uint32_t * |
Pointer to const uint32_t. | |
using | ts::const_uint64_ptr = const uint64_t * |
Pointer to const uint64_t. | |
using | ts::const_uint8_ptr = const uint8_t * |
Pointer to const uint8_t. | |
using | ts::deciseconds = cn::duration< cn::milliseconds::rep, std::deci > |
A derivative of std::chrono::duration for deciseconds (1/10 of a second). | |
using | ts::int16_ptr = int16_t * |
Pointer to int16_t . | |
using | ts::int32_ptr = int32_t * |
Pointer to int32_t . | |
using | ts::int64_ptr = int64_t * |
Pointer to int64_t . | |
using | ts::int8_ptr = int8_t * |
Pointer to int8_t . | |
using | ts::monotonic_time = cn::time_point< cn::steady_clock > |
Definition of a monotonic time. | |
using | ts::uint16_ptr = uint16_t * |
Pointer to uint16_t . | |
using | ts::uint32_ptr = uint32_t * |
Pointer to uint32_t . | |
using | ts::uint64_ptr = uint64_t * |
Pointer to uint64_t . | |
using | ts::uint8_ptr = uint8_t * |
Pointer to uint8_t . | |
Enumerations | |
enum class | ts::ShareMode { ts::COPY , ts::SHARE } |
Enumeration type used to indicate if the data referenced by a pointer shall be copied or shared. More... | |
enum class | ts::ThreadSafety { ts::Full , ts::None } |
Thread safety property of a class. More... | |
enum class | ts::Tristate { Maybe = -1 , ts::False = 0 , ts::True = 1 } |
Tristate boolean. More... | |
Functions | |
template<class T , class U > | |
void | ts::set_default (std::optional< T > &opt, const U &value) |
Set a default value in a std::optional object, if there is none. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
Tristate | ts::ToTristate (INT i) |
Normalize any integer value in the range of a Tristate value. | |
Variables | |
constexpr std::uintmax_t | ts::FS_ERROR = static_cast<std::uintmax_t>(-1) |
This error code is returned by some functions in std::filesystem. | |
constexpr size_t | ts::NPOS = size_t(-1) |
Constant meaning "no size", "not found" or "do not resize". | |
Cross-platforms portable base definitions for the TSDuck project.
This header file shall be included by all C++ compilation units in the TSDuck project. It provides common portable definitions. This file shall always be included first, before system headers and other TSDuck headers.
Important: This file shall be updated each time a new platform is used (processor, compiler, operating system). When recompiling this header on a new platform, many errors are generated (explicit #error
directives). These errors will guide you on the required additions for the new platform.
This header file conditionally defines several symbols (macros) which describe the platform (processor, compiler, operating system). These symbols can be used for conditional compilation.
The following environments are described:
#define TS_LLVM |
Defined when the compiler is LLVM (clang).
In that case, TS_GCC is also defined since LLVM is reasonably compatible with GCC.
#define TS_MSC |
Defined when the compiler is Microsoft C/C++, the default compiler in the Microsoft Visual Studio environment.
Also used on command line and batch file as the cl
command.
#define TS_GCC_VERSION |
GCC version, encoded as an integer.
Example: 40801 for GCC 4.8.1. Undefined when the compiler is not GCC or its version is unknown.
#define TS_CPLUSPLUS |
Level of C++ language, same as predefined __cplusplus, but safe with MSVC.
Microsoft-specific ways of signaling the language level: With Visual Studio 2017, there are flags such as /std:c++14 to specify the level of language. However, __cplusplus is still set to 199711L. It is unclear if this is a bug or if __cplusplus is not set because the C++11/14/17 standards all not super-completely implemented. The Microsoft-specific symbol _MSVC_LANG is defined to describe a "good-enough" level of standard which is fine for us.
The current version of TSDuck requires C++17 at least (GCC 8, clang 5, Visual Studio 2017 15.8).
#define TS_NEED_UNEQUAL_OPERATOR 1 |
Defined when the != operator shall be defined in addition to ==.
In C++20, != operators are implicitly derived from the corresponding == operators. Defining the != operator when == is already defined is not only useless, it also creates "ambiguous operator" errors because tests such as "a != b" become ambiguous when a and b are not const (the exact profile of !=). In that case, the compiler cannot choose between the explicitly defined != and the implicit one which is derived from ==.
#define TS_UNIX |
Defined when compiled for any flavor of UNIX target platforms.
This symbol comes in addition to the specific symbol for the target platform (TS_LINUX, etc.)
#define TSDUCK_STATIC_PLUGINS |
User-defined macro to enable static linking of plugins.
If TSDUCK_STATIC_PLUGINS is defined, typically on the compilation command line, all plugins are linked statically. Dynamic loading of plugins is disabled.
#define TSDUCK_STATIC_LIBRARY |
Applications which link against the TSDuck static library.
Applications which link against the TSDuck static library should define TSDUCK_STATIC_LIBRARY. This symbol can be used to force external references.
TSDUCK_STATIC_LIBRARY enforces TSDUCK_STATIC_PLUGINS.
#define TSDUCK_STATIC |
User-defined macro to enable full static linking.
If TSDUCK_STATIC is defined, typically on the compilation command line, the code is compiled and linked statically, including system libraries. On Linux, this is not recommended since a few features such as IP address resolution are disabled.
TSDUCK_STATIC enforces TSDUCK_STATIC_LIBRARY and TSDUCK_STATIC_PLUGINS.
#define TS_STRINGIFY | ( | x | ) |
This macro transforms the value of a macro parameter into the equivalent string literal.
This is a very specific macro. It is typically used only inside the definition of another macro. It is similar to the # token in the preprocessor but has a slightly different effect. The # token transforms the text of a macro parameter into a string while TS_STRINGIFY transforms the value of a macro parameter into a string, after all preprocessing substitutions.
The following example illustrates the difference between the # token and TS_STRINGIFY:
This will print:
#define TS_USTRINGIFY | ( | x | ) |
This macro transforms the value of a macro parameter into the equivalent 16-bit Unicode string literal.
This macro is equivalent to TS_STRINGIFY() except that the string literal is of the for u"..."
instead of "..."
#define TS_UNIQUE_NAME | ( | prefix | ) |
This macro generates a unique name based on the source line number.
It is typically used in more complex macro definitions. These complex macros should be defined on one single line. All invocations of TS_UNIQUE_NAME generate the same symbol when placed one the same source line.
prefix | Prefix for the symbol. Using different prefixes, several distinct unique identifiers can be used on the same line. |
#define TS_PRAGMA | ( | directive | ) |
Helper macro for the C++11 keyword _Pragma
.
With the C++11 standard, the keywork _Pragma
uses a string literal. However, Visual C++ does not support it as of Visual Studio 2019. Instead, it uses the non-standard keyword __pragma
with a plain directive (not a string).
directive | The directive for the pragma. Plain directive, not a string literal. |
Examples (depending on compilers):
#define TS_PUSH_WARNING | ( | ) |
Save the compiler's warnings reporting.
#define TS_POP_WARNING | ( | ) |
Restore the compiler's warnings reporting from a previous TS_PUSH_WARNING().
#define TS_LLVM_NOWARNING | ( | name | ) |
Disable a warning with the LLVM/clang compiler (does nothing on other compilers).
name | Warning name, as used after command line option -W |
#define TS_GCC_NOWARNING | ( | name | ) |
Disable a warning with the GCC compiler (does nothing on other compilers).
name | Warning name, as used after command line option -W |
#define TS_MSC_NOWARNING | ( | num | ) |
Disable a warning with the Microsoft Visual C++ compiler (does nothing on other compilers).
num | Warning number. |
#define TS_NO_OPTIMIZE platform_specific |
Attribute to explicitly disable optimization in a function.
Example:
#define TS_FUNCTION |
Definition of the name of the current function.
This is typically func but recent compilers have "pretty" names for C++.
#define TSDUCKDLL |
Attribute to declare a class or function from tsduck.dll on Windows.
When building tsduck.dll on Windows, define _TSDUCKDLL_IMPL in the project options. When building a project which references tsduck.dll, define _TSDUCKDLL_USE. All API located inside tsduck.dll shall be prefixed by TSDUCKDLL in headers. This prefix exports the API when building the DLL and imports the API when used in an application.
#define TS_NOCOPY | ( | classname | ) |
A macro to disable object copy in the declaration of a class.
The copy and move constructors and assignments are explicitly deleted.
classname | Name of the enclosing class. |
#define TS_NOBUILD_NOCOPY | ( | classname | ) |
A macro to disable default constructor and object copy in the declaration of a class.
The default, copy and move constructors and assignments are explicitly deleted.
classname | Name of the enclosing class. |
#define TS_NO_DEFAULT_CONSTRUCTORS | ( | classname | ) |
A macro to disable default constructors in the declaration of a class.
The default, copy and move constructors are explicitly deleted.
classname | Name of the enclosing class. |
#define TS_DEFAULT_ASSIGMENTS | ( | classname | ) |
A macro to declare the default assignment operators in the declaration of a class.
classname | Name of the enclosing class. |
#define TS_DEFAULT_COPY_MOVE | ( | classname | ) |
A macro to declare the default copy and move constructors and assignment operators in the declaration of a class.
classname | Name of the enclosing class. |
#define TS_RULE_OF_FIVE | ( | classname, | |
dtor_attributes | |||
) |
A macro to apply the C++ "rule of five" in the declaration of a class.
An explicit virtual destructor is declared. The copy and move constructors and assignments are defaulted.
classname | Name of the enclosing class. |
dtor_attributes | Post attributes for the destructor. |
#define TS_INTERFACE | ( | classname | ) |
A macro to declare the basic operators in the declaration of an interface class.
classname | Name of the enclosing class. |
#define TS_UNEQUAL_OPERATOR | ( | classname | ) |
A macro to declare an unequal operator in the declaration of a class.
Before C++20, define an inline != operator based on the == operator. In C++20 and beyond, != is implicitly derived from the corresponding == and this macro does nothing.
classname | Name of the enclosing class. |
#define TS_STATIC_REFERENCE | ( | suffix, | |
addr | |||
) |
This macro generates a reference to some address (string literal, external symbol, etc.) The reference is a unique static symbol which is otherwise unused.
The difficulty is to make sure that the compiler will not optimize away this data (it is local and unused).
suffix | Some unique suffix if the macro is invoked several times on the same line. |
addr | An address to reference (string literal, external symbol, etc.) |