TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
tsPlatform.h File Reference

Cross-platforms portable base definitions for the TSDuck project. More...

Namespaces

 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_ALPHA
 Defined when the target processor architecture is Digital Alpha architecture.
 
#define TS_ARM
 Defined when the target processor architecture is ARM.
 
#define TS_ARM64
 Defined when the target processor architecture is ARM64.
 
#define TS_BIG_ENDIAN
 Defined when compiled for a big-endian or MSB-first target platform.
 
#define TS_CONST64(n)
 Portable definition of a 64-bit signed literal. More...
 
#define TS_CXX11
 Defined when the compiler is compliant with C++11.
 
#define TS_CXX11_STRING
 Defined when the STL basic_string is compliant with C++11. More...
 
#define TS_CXX14
 Defined when the compiler is compliant with C++14.
 
#define TS_CXX17
 Defined when the compiler is compliant with C++17.
 
#define TS_CYGWIN
 Defined when compiled for a Cygwin target platform.
 
#define TS_DLL_EXPORT
 On Windows, this attribute exports a symbol out of a DLL.
 
#define TS_DVB_API_VERSION
 On Linux systems, identify the Linux DVB API version in one value. More...
 
#define TS_FLAGS_OPERATORS(type)
 This macro defines all bit-wise operators on an enumeration type. More...
 
#define TS_FUNCTION
 Definition of the name of the current function. More...
 
#define TS_GCC
 Defined when the compiler is GCC, also known as "GNU C", or a GCC-compatible compiler.
 
#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. More...
 
#define TS_I386
 Defined when the target processor architecture is Intel IA-32, also known as x86.
 
#define TS_IA64
 Defined when the target processor architecture is Intel IA-64 architecture, also known as Itanium.
 
#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_LLVM
 Defined when the compiler is LLVM (clang). More...
 
#define TS_MAC
 Defined when compiled for a macOS target platform.
 
#define TS_MIPS
 Defined when the target processor architecture is MIPS architecture.
 
#define TS_MSC
 Defined when the compiler is Microsoft C/C++, the default compiler in the Microsoft Visual Studio environment. More...
 
#define TS_NEED_STATIC_CONST_DEFINITIONS
 Compilation of definitions of C++ constants. More...
 
#define TS_NO_MEMORY_BARRIER
 To be defined to implement memory barrier as a no-operation. More...
 
#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_RECVBUF_T(x)   platform_specific
 Type conversion macro for the address of the data buffer for a recv() system call. More...
 
#define TS_SENDBUF_T(x)   platform_specific
 Type conversion macro for the address of the data buffer for a send() system call. More...
 
#define TS_SIZE_T_IS_STDINT
 Defined is size_t is an exact overload of some predefined uintXX_t. More...
 
#define TS_SLINE   TS_STRINGIFY(__LINE__)
 String version of LINE
 
#define TS_SOCKET_CLOSE   platform_specific
 Name of the close() system call which applies to socket devices. More...
 
#define TS_SOCKET_ERR_NOTCONN   platform_specific
 System error code value meaning "peer socket not connected".
 
#define TS_SOCKET_ERR_RESET   platform_specific
 System error code value meaning "connection reset by peer".
 
#define TS_SOCKET_IOCTL   platform_specific
 Name of the ioctl() system call which applies to socket devices. More...
 
#define TS_SOCKET_L_LINGER_T(x)   platform_specific
 Type conversion macro for the field l_linger in the struct linger socket option. More...
 
#define TS_SOCKET_MC_TTL_T   platform_specific
 Integer data type for the multicast Time To Live (TTL) socket option. More...
 
#define TS_SOCKET_PKTINFO_T   platform_specific
 Integer data type for the IP_PKTINFO socket option. More...
 
#define TS_SOCKET_SHUT_RD   platform_specific
 Name of the option for the shutdown() system call which means "close on receive side". More...
 
#define TS_SOCKET_SHUT_RDWR   platform_specific
 Name of the option for the shutdown() system call which means "close on both directions". More...
 
#define TS_SOCKET_SHUT_WR   platform_specific
 Name of the option for the shutdown() system call which means "close on send side". More...
 
#define TS_SOCKET_SOCKLEN_T   platform_specific
 Integer data type which receives the length of a struct sockaddr. More...
 
#define TS_SOCKET_SSIZE_T   platform_specific
 Integer data type for a "signed size" returned from send() or recv() system calls. More...
 
#define TS_SOCKET_T   platform_specific
 Data type for socket descriptors as returned by the socket() system call.
 
#define TS_SOCKET_T_INVALID   platform_specific
 Value of type TS_SOCKET_T which is returned by the socket() system call in case of failure. More...
 
#define TS_SOCKET_TOS_T   platform_specific
 Integer data type for the TOS socket option.
 
#define TS_SOCKET_TTL_T   platform_specific
 Integer data type for the Time To Live (TTL) socket option. More...
 
#define TS_SOCKOPT_T(x)   platform_specific
 Type conversion macro for the address of a socket option value. More...
 
#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_STRINGIFY(x)
 This macro transforms the value of a macro parameter into the equivalent string literal. More...
 
#define TS_STXP70
 Defined when the target processor architecture is STxP70.
 
#define TS_UCONST64(n)
 Portable definition of a 64-bit unsigned literal. More...
 
#define TS_UNIX
 Defined when compiled for any flavor of UNIX target platforms. More...
 
#define TS_UNUSED   platform_specific
 Attribute for explicitly unused variables. More...
 
#define TS_USTRINGIFY(x)
 This macro transforms the value of a macro parameter into the equivalent 16-bit Unicode string literal. More...
 
#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_SOURCE
 This macro inserts a build mark in the source code, identifying it as part or TSDuck. More...
 
#define TSDUCK_STATIC
 User-defined macro to enable full static linking. More...
 
#define TSDUCK_STATIC_LIBRARY
 Applications which link against the TSDuck static library. More...
 
#define TSDUCK_STATIC_PLUGINS
 User-defined macro to enable static linking of plugins. More...
 
#define TSDUCKDLL
 Attribute to declare a class or function from tsduck.dll on Windows. More...
 

Typedefs

typedef platform_specific ts::ErrorCode
 Integer type for operating system error codes.
 
typedef SubSecond ts::MicroSecond
 This integer type is used to represent a number of microseconds. More...
 
typedef SubSecond ts::MilliSecond
 This integer type is used to represent a number of milliseconds. More...
 
typedef SubSecond ts::NanoSecond
 This integer type is used to represent a number of nanoseconds. More...
 
typedef SubSecond ts::Second
 This integer type is used to represent a number of seconds. More...
 
typedef int64_t ts::SubSecond
 This integer type is used to represent any sub-quantity of seconds. More...
 

Enumerations

enum  ts::CopyShare {
  ts::COPY,
  ts::SHARE
}
 Enumeration type used to indicate if the data referenced by a pointer shall be copied or shared. More...
 
enum  ts::Tristate {
  MAYBE = -1,
  ts::FALSE = 0,
  ts::TRUE = 1
}
 Tristate boolean. More...
 

Functions

uint16_t ts::ByteSwap16 (uint16_t x)
 Inlined function performing byte swap on 16-bit integer data. More...
 
uint32_t ts::ByteSwap24 (uint32_t x)
 Inlined function performing byte swap on 24-bit integer data. More...
 
uint32_t ts::ByteSwap32 (uint32_t x)
 Inlined function performing byte swap on 32-bit integer data. More...
 
uint64_t ts::ByteSwap64 (uint64_t x)
 Inlined function performing byte swap on 64-bit integer data. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT ts::CondByteSwap (INT x)
 Template function performing conditional byte swap on integer data to obtain the data in big endian representation. More...
 
uint16_t ts::CondByteSwap16 (uint16_t x)
 Inlined function performing conditional byte swap on 16-bit integer data to obtain the data in big endian representation. More...
 
uint16_t ts::CondByteSwap16BE (uint16_t x)
 Inlined function performing conditional byte swap on 16-bit integer data to obtain the data in big endian representation. More...
 
uint16_t ts::CondByteSwap16LE (uint16_t x)
 Inlined function performing conditional byte swap on 16-bit integer data to obtain the data in little endian representation. More...
 
uint32_t ts::CondByteSwap24 (uint32_t x)
 Inlined function performing conditional byte swap on 24-bit integer data to obtain the data in big endian representation. More...
 
uint32_t ts::CondByteSwap24BE (uint32_t x)
 Inlined function performing conditional byte swap on 24-bit integer data to obtain the data in big endian representation. More...
 
uint32_t ts::CondByteSwap24LE (uint32_t x)
 Inlined function performing conditional byte swap on 24-bit integer data to obtain the data in little endian representation. More...
 
uint32_t ts::CondByteSwap32 (uint32_t x)
 Inlined function performing conditional byte swap on 32-bit integer data to obtain the data in big endian representation. More...
 
uint32_t ts::CondByteSwap32BE (uint32_t x)
 Inlined function performing conditional byte swap on 32-bit integer data to obtain the data in big endian representation. More...
 
uint32_t ts::CondByteSwap32LE (uint32_t x)
 Inlined function performing conditional byte swap on 32-bit integer data to obtain the data in little endian representation. More...
 
uint64_t ts::CondByteSwap64 (uint64_t x)
 Inlined function performing conditional byte swap on 64-bit integer data to obtain the data in big endian representation. More...
 
uint64_t ts::CondByteSwap64BE (uint64_t x)
 Inlined function performing conditional byte swap on 64-bit integer data to obtain the data in big endian representation. More...
 
uint64_t ts::CondByteSwap64LE (uint64_t x)
 Inlined function performing conditional byte swap on 64-bit integer data to obtain the data in little endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT ts::CondByteSwapBE (INT x)
 Template function performing conditional byte swap on integer data to obtain the data in big endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT ts::CondByteSwapLE (INT x)
 Template function performing conditional byte swap on integer data to obtain the data in little endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT ts::GetInt (const void *p)
 Template function getting an integer from serialized data in big endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::GetInt (const void *p, INT &i)
 Template function getting an integer from serialized data in big endian representation. More...
 
int16_t ts::GetInt16 (const void *p)
 Inlined function getting a 16-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt16 (const void *p, int16_t &i)
 Inlined function getting a 16-bit signed integer from serialized data in big endian representation. More...
 
int16_t ts::GetInt16BE (const void *p)
 Inlined function getting a 16-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt16BE (const void *p, int16_t &i)
 Inlined function getting a 16-bit signed integer from serialized data in big endian representation. More...
 
int16_t ts::GetInt16LE (const void *p)
 Inlined function getting a 16-bit signed integer from serialized data in little endian representation. More...
 
void ts::GetInt16LE (const void *p, int16_t &i)
 Inlined function getting a 16-bit signed integer from serialized data in little endian representation. More...
 
int32_t ts::GetInt24 (const void *p)
 Inlined function getting a 24-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt24 (const void *p, int32_t &i)
 Inlined function getting a 24-bit signed integer from serialized data in big endian representation. More...
 
int32_t ts::GetInt24BE (const void *p)
 Inlined function getting a 24-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt24BE (const void *p, int32_t &i)
 Inlined function getting a 24-bit signed integer from serialized data in big endian representation. More...
 
int32_t ts::GetInt24LE (const void *p)
 Inlined function getting a 24-bit signed integer from serialized data in little endian representation. More...
 
void ts::GetInt24LE (const void *p, int32_t &i)
 Inlined function getting a 24-bit signed integer from serialized data in little endian representation. More...
 
int32_t ts::GetInt32 (const void *p)
 Inlined function getting a 32-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt32 (const void *p, int32_t &i)
 Inlined function getting a 32-bit signed integer from serialized data in big endian representation. More...
 
int32_t ts::GetInt32BE (const void *p)
 Inlined function getting a 32-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt32BE (const void *p, int32_t &i)
 Inlined function getting a 32-bit signed integer from serialized data in big endian representation. More...
 
int32_t ts::GetInt32LE (const void *p)
 Inlined function getting a 32-bit signed integer from serialized data in little endian representation. More...
 
void ts::GetInt32LE (const void *p, int32_t &i)
 Inlined function getting a 32-bit signed integer from serialized data in little endian representation. More...
 
int64_t ts::GetInt64 (const void *p)
 Inlined function getting a 64-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt64 (const void *p, int64_t &i)
 Inlined function getting a 64-bit signed integer from serialized data in big endian representation. More...
 
int64_t ts::GetInt64BE (const void *p)
 Inlined function getting a 64-bit signed integer from serialized data in big endian representation. More...
 
void ts::GetInt64BE (const void *p, int64_t &i)
 Inlined function getting a 64-bit signed integer from serialized data in big endian representation. More...
 
int64_t ts::GetInt64LE (const void *p)
 Inlined function getting a 64-bit signed integer from serialized data in little endian representation. More...
 
void ts::GetInt64LE (const void *p, int64_t &i)
 Inlined function getting a 64-bit signed integer from serialized data in little endian representation. More...
 
int8_t ts::GetInt8 (const void *p)
 Inlined function getting an 8-bit signed integer from serialized data. More...
 
void ts::GetInt8 (const void *p, int8_t &i)
 Inlined function getting an 8-bit signed integer from serialized data. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT ts::GetIntBE (const void *p)
 Template function getting an integer from serialized data in big endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::GetIntBE (const void *p, INT &i)
 Template function getting an integer from serialized data in big endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
INT ts::GetIntLE (const void *p)
 Template function getting an integer from serialized data in little endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::GetIntLE (const void *p, INT &i)
 Template function getting an integer from serialized data in little endian representation. More...
 
uint16_t ts::GetUInt16 (const void *p)
 Inlined function getting a 16-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt16 (const void *p, uint16_t &i)
 Inlined function getting a 16-bit unsigned integer from serialized data in big endian representation. More...
 
uint16_t ts::GetUInt16BE (const void *p)
 Inlined function getting a 16-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt16BE (const void *p, uint16_t &i)
 Inlined function getting a 16-bit unsigned integer from serialized data in big endian representation. More...
 
uint16_t ts::GetUInt16LE (const void *p)
 Inlined function getting a 16-bit unsigned integer from serialized data in little endian representation. More...
 
void ts::GetUInt16LE (const void *p, uint16_t &i)
 Inlined function getting a 16-bit unsigned integer from serialized data in little endian representation. More...
 
uint32_t ts::GetUInt24 (const void *p)
 Inlined function getting a 24-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt24 (const void *p, uint32_t &i)
 Inlined function getting a 24-bit unsigned integer from serialized data in big endian representation. More...
 
uint32_t ts::GetUInt24BE (const void *p)
 Inlined function getting a 24-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt24BE (const void *p, uint32_t &i)
 Inlined function getting a 24-bit unsigned integer from serialized data in big endian representation. More...
 
uint32_t ts::GetUInt24LE (const void *p)
 Inlined function getting a 24-bit unsigned integer from serialized data in little endian representation. More...
 
void ts::GetUInt24LE (const void *p, uint32_t &i)
 Inlined function getting a 24-bit unsigned integer from serialized data in little endian representation. More...
 
uint32_t ts::GetUInt32 (const void *p)
 Inlined function getting a 32-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt32 (const void *p, uint32_t &i)
 Inlined function getting a 32-bit unsigned integer from serialized data in big endian representation. More...
 
uint32_t ts::GetUInt32BE (const void *p)
 Inlined function getting a 32-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt32BE (const void *p, uint32_t &i)
 Inlined function getting a 32-bit unsigned integer from serialized data in big endian representation. More...
 
uint32_t ts::GetUInt32LE (const void *p)
 Inlined function getting a 32-bit unsigned integer from serialized data in little endian representation. More...
 
void ts::GetUInt32LE (const void *p, uint32_t &i)
 Inlined function getting a 32-bit unsigned integer from serialized data in little endian representation. More...
 
uint64_t ts::GetUInt40 (const void *p)
 Inlined function getting a 40-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt40 (const void *p, uint64_t &i)
 Inlined function getting a 40-bit unsigned integer from serialized data in big endian representation. More...
 
uint64_t ts::GetUInt40BE (const void *p)
 Inlined function getting a 40-bit unsigned integer from serialized data in big endian representation. More...
 
uint64_t ts::GetUInt40LE (const void *p)
 Inlined function getting a 40-bit unsigned integer from serialized data in little endian representation. More...
 
uint64_t ts::GetUInt48 (const void *p)
 Inlined function getting a 48-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt48 (const void *p, uint64_t &i)
 Inlined function getting a 48-bit unsigned integer from serialized data in big endian representation. More...
 
uint64_t ts::GetUInt48BE (const void *p)
 Inlined function getting a 48-bit unsigned integer from serialized data in big endian representation. More...
 
uint64_t ts::GetUInt48LE (const void *p)
 Inlined function getting a 48-bit unsigned integer from serialized data in little endian representation. More...
 
uint64_t ts::GetUInt64 (const void *p)
 Inlined function getting a 64-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt64 (const void *p, uint64_t &i)
 Inlined function getting a 64-bit unsigned integer from serialized data in big endian representation. More...
 
uint64_t ts::GetUInt64BE (const void *p)
 Inlined function getting a 64-bit unsigned integer from serialized data in big endian representation. More...
 
void ts::GetUInt64BE (const void *p, uint64_t &i)
 Inlined function getting a 64-bit unsigned integer from serialized data in big endian representation. More...
 
uint64_t ts::GetUInt64LE (const void *p)
 Inlined function getting a 64-bit unsigned integer from serialized data in little endian representation. More...
 
void ts::GetUInt64LE (const void *p, uint64_t &i)
 Inlined function getting a 64-bit unsigned integer from serialized data in little endian representation. More...
 
uint8_t ts::GetUInt8 (const void *p)
 Inlined function getting an 8-bit unsigned integer from serialized data. More...
 
void ts::GetUInt8 (const void *p, uint8_t &i)
 Inlined function getting an 8-bit unsigned integer from serialized data. More...
 
ErrorCode ts::LastErrorCode ()
 Get the error code of the last operating system call. More...
 
void ts::MemoryBarrier (void)
 Inlined C function performing a CPU/compiler dependent memory barrier.
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::PutInt (void *p, INT i)
 Template function serializing an integer data in big endian representation. More...
 
void ts::PutInt16 (void *p, int16_t i)
 Inlined function serializing a 16-bit signed integer data in big endian representation. More...
 
void ts::PutInt16BE (void *p, int16_t i)
 Inlined function serializing a 16-bit signed integer data in big endian representation. More...
 
void ts::PutInt16LE (void *p, int16_t i)
 Inlined function serializing a 16-bit signed integer data in little endian representation. More...
 
void ts::PutInt24 (void *p, int32_t i)
 Inlined function serializing a 24-bit signed integer data in big endian representation. More...
 
void ts::PutInt24BE (void *p, int32_t i)
 Inlined function serializing a 24-bit signed integer data in big endian representation. More...
 
void ts::PutInt24LE (void *p, int32_t i)
 Inlined function serializing a 24-bit signed integer data in little endian representation. More...
 
void ts::PutInt32 (void *p, int32_t i)
 Inlined function serializing a 32-bit signed integer data in big endian representation. More...
 
void ts::PutInt32BE (void *p, int32_t i)
 Inlined function serializing a 32-bit signed integer data in big endian representation. More...
 
void ts::PutInt32LE (void *p, int32_t i)
 Inlined function serializing a 32-bit signed integer data in little endian representation. More...
 
void ts::PutInt64 (void *p, int64_t i)
 Inlined function serializing a 64-bit signed integer data in big endian representation. More...
 
void ts::PutInt64BE (void *p, int64_t i)
 Inlined function serializing a 64-bit signed integer data in big endian representation. More...
 
void ts::PutInt64LE (void *p, int64_t i)
 Inlined function serializing a 64-bit signed integer data in little endian representation. More...
 
void ts::PutInt8 (void *p, int8_t i)
 Inlined function serializing an 8-bit signed integer data. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::PutIntBE (void *p, INT i)
 Template function serializing an integer data in big endian representation. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::PutIntLE (void *p, INT i)
 Template function serializing an integer data in little endian representation. More...
 
void ts::PutUInt16 (void *p, uint16_t i)
 Inlined function serializing a 16-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt16BE (void *p, uint16_t i)
 Inlined function serializing a 16-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt16LE (void *p, uint16_t i)
 Inlined function serializing a 16-bit unsigned integer data in little endian representation. More...
 
void ts::PutUInt24 (void *p, uint32_t i)
 Inlined function serializing a 24-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt24BE (void *p, uint32_t i)
 Inlined function serializing a 24-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt24LE (void *p, uint32_t i)
 Inlined function serializing a 24-bit unsigned integer data in little endian representation. More...
 
void ts::PutUInt32 (void *p, uint32_t i)
 Inlined function serializing a 32-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt32BE (void *p, uint32_t i)
 Inlined function serializing a 32-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt32LE (void *p, uint32_t i)
 Inlined function serializing a 32-bit unsigned integer data in little endian representation. More...
 
void ts::PutUInt40 (void *p, uint64_t i)
 Inlined function serializing a 40-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt40BE (void *p, uint64_t i)
 Inlined function serializing a 40-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt40LE (void *p, uint64_t i)
 Inlined function serializing a 40-bit unsigned integer data in little endian representation. More...
 
void ts::PutUInt48 (void *p, uint64_t i)
 Inlined function serializing a 48-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt48BE (void *p, uint64_t i)
 Inlined function serializing a 48-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt48LE (void *p, uint64_t i)
 Inlined function serializing a 48-bit unsigned integer data in little endian representation. More...
 
void ts::PutUInt64 (void *p, uint64_t i)
 Inlined function serializing a 64-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt64BE (void *p, uint64_t i)
 Inlined function serializing a 64-bit unsigned integer data in big endian representation. More...
 
void ts::PutUInt64LE (void *p, uint64_t i)
 Inlined function serializing a 64-bit unsigned integer data in little endian representation. More...
 
void ts::PutUInt8 (void *p, uint8_t i)
 Inlined function serializing an 8-bit unsigned integer data. More...
 
uint32_t ts::ROL (uint32_t word, int i)
 Inlined function performing 32-bit left-rotate. More...
 
uint64_t ts::ROL64 (uint64_t word, int i)
 Inlined function performing 64-bit left-rotate. More...
 
uint64_t ts::ROL64c (uint64_t word, const int i)
 Inlined function performing 64-bit left-rotate with a constant value in the range 0..63 for index. More...
 
uint32_t ts::ROR (uint32_t word, int i)
 Inlined function performing 32-bit right-rotate. More...
 
uint64_t ts::ROR64 (uint64_t word, int i)
 Inlined function performing 64-bit right-rotate. More...
 
uint64_t ts::ROR64c (uint64_t word, const int i)
 Inlined function performing 64-bit right-rotate with a constant value in the range 0..63 for index. More...
 
uint32_t ts::RORc (uint32_t word, const int i)
 Inlined function performing 32-bit left-rotate with a constant value in the range 0..31 for index. More...
 
int32_t ts::SignExtend24 (int32_t x)
 Perform a sign extension on 24 bit integers. More...
 
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. More...
 

Variables

constexpr SubSecond ts::Infinite =
 This constant shall be used by convention to express an infinite number of sub-quantities of seconds.
 
constexpr MicroSecond ts::MicroSecPerMilliSec = 1000
 Number of microseconds per millisecond.
 
constexpr MicroSecond ts::MicroSecPerSec = 1000000
 Number of microseconds per second.
 
constexpr MilliSecond ts::MilliSecPerDay = 1000 * 60 * 60 * 24
 Number of milliseconds per day.
 
constexpr MilliSecond ts::MilliSecPerHour = 1000 * 60 * 60
 Number of milliseconds per hour.
 
constexpr MilliSecond ts::MilliSecPerMin = 1000 * 60
 Number of milliseconds per minute.
 
constexpr MilliSecond ts::MilliSecPerSec = 1000
 Number of milliseconds per second.
 
constexpr NanoSecond ts::NanoSecPerMicroSec = 1000
 Number of nanoseconds per microsecond.
 
constexpr NanoSecond ts::NanoSecPerMilliSec = 1000000
 Number of nanoseconds per millisecond.
 
constexpr NanoSecond ts::NanoSecPerSec = 1000000000
 Number of nanoseconds per second.
 
const size_t ts::NPOS
 Constant meaning "no size", "not found" or "do not resize". More...
 
const ErrorCode ts::SYS_DATA_ERROR = platform_specific
 An ErrorCode value indicating a generic data error. More...
 
const ErrorCode ts::SYS_SUCCESS = platform_specific
 An ErrorCode value indicating success. More...
 

Detailed Description

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.

Platform definitions

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:

Solving various compilation issues

This header file defines some macros which can be used to solve various C/C++ compilation issues.

Macro Definition Documentation

◆ TS_LLVM

#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.

◆ TS_MSC

#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.

◆ TS_GCC_VERSION

#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.

◆ TS_CXX11_STRING

#define TS_CXX11_STRING

Defined when the STL basic_string is compliant with C++11.

The class basic_string from the C++ STL has more features starting with C++11. However, GCC does not support them with old versions, even if –std=c++11 or 14 is specified. The level of language is increased but not the level of STL.

◆ TS_UNIX

#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.)

◆ TSDUCK_STATIC_PLUGINS

#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.

◆ TSDUCK_STATIC_LIBRARY

#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.

◆ TSDUCK_STATIC

#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.

◆ TS_DVB_API_VERSION

#define TS_DVB_API_VERSION

On Linux systems, identify the Linux DVB API version in one value.

Example: TS_DVB_API_VERSION is 503 for DVB API version 5.3.

◆ TS_STRINGIFY

#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:

#define P1(v) printf("#parameter: %s = %d\n", #v, v)
#define P2(v) printf("TS_STRINGIFY: %s = %d\n", TS_STRINGIFY(v), v)
....
#define X 1
P1(X);
P2(X);

This will print:

#parameter: X = 1
TS_STRINGIFY: 1 = 1

◆ TS_USTRINGIFY

#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 "..."

See also
TS_STRINGIFY()

◆ TS_UNUSED

#define TS_UNUSED   platform_specific

Attribute for explicitly unused variables.

It is sometimes required to declare unused variables. This may be temporary, before completing the code and using the variable later, or for any other reason. When the compiler is used in "paranoid" warning mode, declaring unused variables may trigger a warning or an error.

When you know that you need to declare an unused variable, the special macro TS_UNUSED shall be used as an attribute of the variable. Using this attribute, the compiler will no longer complain that the variable is unused.

Example:

TS_UNUSED int i;

◆ TS_FUNCTION

#define TS_FUNCTION

Definition of the name of the current function.

This is typically func but recent compilers have "pretty" names for C++.

◆ TSDUCKDLL

#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.

◆ TS_NEED_STATIC_CONST_DEFINITIONS

#define TS_NEED_STATIC_CONST_DEFINITIONS

Compilation of definitions of C++ constants.

It is a well-known pattern in C++ to define constants in header files as static const. Example:

static const int FOO = 1;

According to Stroustrup 10.4.6.2, this is only a declaration, which needs a definition somewhere else, without initialization. Example:

const int classname::FOO;

This is a really stupid oddity of C++ which is handled differently by compilers:

  • GCC, with optimization: The declaration alone is fine. The definition is accepted.
  • GCC, without optimization: Sometimes, depending on the way the constants are used, the definition is required. Without definition, the linker complains about an undefined symbol.
  • Microsoft C: The definition must not be used. Otherwise, the linker complains about a multiply defined symbol.

As a consequence, there are situations where the definition is required and situations where the definition is forbidden. The presence of the definition shall be conditioned to the macro TS_NEED_STATIC_CONST_DEFINITIONS.

Example: In tsFoo.h, the constant is declared as:

namespace ts {
class Foo
{
public:
static const size_t MAX_ENTRIES = 10;
...

In tsFoo.cpp, the definition of the constant shall be conditionally compiled since all compilers do not behave identically:

#if defined(TS_NEED_STATIC_CONST_DEFINITIONS)
const size_t ts::Foo::MAX_ENTRIES;
#endif

◆ TS_SIZE_T_IS_STDINT

#define TS_SIZE_T_IS_STDINT

Defined is size_t is an exact overload of some predefined uintXX_t.

In that case, it is not possible to declare distinct overloads of a function with size_t and uint32_t or uint64_t for instance.

◆ TS_CONST64

#define TS_CONST64 (   n)

Portable definition of a 64-bit signed literal.

The C/C++ languages define the syntax for integer literals. An integer literal is always typed. Without suffix such as in 0, the literal has type int. With an L suffix, such as in 0L, the literal has type long. But there is no standard suffix or syntax for 64-bit literals; different compilers have different syntaxes.

This macro is a portable way to write 64-bit signed literals.

Example:

const int64_t aBigOne = TS_CONST64(0x7FFFFFFFFFFFFFFF);

◆ TS_UCONST64

#define TS_UCONST64 (   n)

Portable definition of a 64-bit unsigned literal.

The C/C++ languages define the syntax for integer literals. An integer literal is always typed. Without suffix such as in 0, the literal has type int. With an L suffix, such as in 0L, the literal has type long. But there is no standard suffix or syntax for 64-bit literals; different compilers have different syntaxes.

This macro is a portable way to write 64-bit unsigned literals.

Example:

const uint64_t aBigOne = TS_UCONST64(0xFFFFFFFFFFFFFFFF);

◆ TS_NO_MEMORY_BARRIER

#define TS_NO_MEMORY_BARRIER

To be defined to implement memory barrier as a no-operation.

This symbol shall be defined by the developer on the command line to ensure that no specific memory barrier instruction is generated.

This can be useful in some environments (for instance using valgrind on the ARM architecture) when the memory barrier causes some trouble.

Note that not using memory barrier instructions can cause some extremely rare race conditions.

◆ TS_FLAGS_OPERATORS

#define TS_FLAGS_OPERATORS (   type)

This macro defines all bit-wise operators on an enumeration type.

These operations are useful for enumeration values which are used as bit-masks. This macro shall be used outside namespaces.

Example:

enum E {A = 0x01, B = 0x02, C = 0x04};
E e = A | B | C;
e ^= B | C;
Parameters
[in]typeThe name of an enumeration type.

◆ TS_SOCKET_T_INVALID

#define TS_SOCKET_T_INVALID   platform_specific

Value of type TS_SOCKET_T which is returned by the socket() system call in case of failure.

Example:

TS_SOCKET_T sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock == TS_SOCKET_T_INVALID) {
... error processing ...
}

◆ TS_SOCKET_SOCKLEN_T

#define TS_SOCKET_SOCKLEN_T   platform_specific

Integer data type which receives the length of a struct sockaddr.

Example:

struct sockaddr sock_addr;
TS_SOCKET_SOCKLEN_T len = sizeof(sock_addr);
if (getsockname(sock, &sock_addr, &len) != 0) {
... error processing ...
}

◆ TS_SOCKET_SSIZE_T

#define TS_SOCKET_SSIZE_T   platform_specific

Integer data type for a "signed size" returned from send() or recv() system calls.

Example:

TS_SOCKET_SSIZE_T got = recv(sock, TS_RECVBUF_T(&data), max_size, 0);

◆ TS_SOCKET_TTL_T

#define TS_SOCKET_TTL_T   platform_specific

Integer data type for the Time To Live (TTL) socket option.

Example:

TS_SOCKET_TTL_T ttl = 10;
if (setsockopt(sock, IPPROTO_IP, IP_TTL, TS_SOCKOPT_T(&ttl), sizeof(ttl)) != 0) {
... error processing ...
}

◆ TS_SOCKET_MC_TTL_T

#define TS_SOCKET_MC_TTL_T   platform_specific

Integer data type for the multicast Time To Live (TTL) socket option.

Example:

if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, TS_SOCKOPT_T(&mttl), sizeof(mttl)) != 0) {
... error processing ...
}

◆ TS_SOCKET_L_LINGER_T

#define TS_SOCKET_L_LINGER_T (   x)    platform_specific

Type conversion macro for the field l_linger in the struct linger socket option.

All systems do not use the same type size and this may generate some warnings. Example:

struct linger lin;
lin.l_linger = TS_SOCKET_L_LINGER_T(seconds);

◆ TS_SOCKET_PKTINFO_T

#define TS_SOCKET_PKTINFO_T   platform_specific

Integer data type for the IP_PKTINFO socket option.

Example:

if (setsockopt(sock, IPPROTO_IP, IP_PKTINFO, TS_SOCKOPT_T(&state), sizeof(state)) != 0) {
... error processing ...
}

◆ TS_SOCKOPT_T

#define TS_SOCKOPT_T (   x)    platform_specific

Type conversion macro for the address of a socket option value.

The "standard" parameter type is void* but some systems use other exotic values. Example:

TS_SOCKET_TTL_T ttl = 10;
if (setsockopt(sock, IPPROTO_IP, IP_TTL, TS_SOCKOPT_T(&ttl), sizeof(ttl)) != 0) {
... error processing ...
}

◆ TS_RECVBUF_T

#define TS_RECVBUF_T (   x)    platform_specific

Type conversion macro for the address of the data buffer for a recv() system call.

The "standard" parameter type is void* but some systems use other exotic values. Example:

TS_SOCKET_SSIZE_T got = recv(sock, TS_RECVBUF_T(&data), max_size, 0);

◆ TS_SENDBUF_T

#define TS_SENDBUF_T (   x)    platform_specific

Type conversion macro for the address of the data buffer for a send() system call.

The "standard" parameter type is void* but some systems use other exotic values. Example:

TS_SOCKET_SSIZE_T gone = send(sock, TS_SENDBUF_T(&data), size, 0);

◆ TS_SOCKET_IOCTL

#define TS_SOCKET_IOCTL   platform_specific

Name of the ioctl() system call which applies to socket devices.

The "standard" name is ioctl but some systems use other exotic names. Note that the ioctl() system call is rarely used on sockets. Most options are accessed through getsockopt() and setsockopt().

◆ TS_SOCKET_CLOSE

#define TS_SOCKET_CLOSE   platform_specific

Name of the close() system call which applies to socket devices.

The "standard" name is close but some systems use other exotic names. Example:

◆ TS_SOCKET_SHUT_RDWR

#define TS_SOCKET_SHUT_RDWR   platform_specific

Name of the option for the shutdown() system call which means "close on both directions".

Example:

shutdown(sock, TS_SOCKET_SHUT_RDWR);

◆ TS_SOCKET_SHUT_RD

#define TS_SOCKET_SHUT_RD   platform_specific

Name of the option for the shutdown() system call which means "close on receive side".

Example:

shutdown(sock, TS_SOCKET_SHUT_RD);

◆ TS_SOCKET_SHUT_WR

#define TS_SOCKET_SHUT_WR   platform_specific

Name of the option for the shutdown() system call which means "close on send side".

Example:

shutdown(sock, TS_SOCKET_SHUT_WR);

◆ TSDUCK_SOURCE

#define TSDUCK_SOURCE

This macro inserts a build mark in the source code, identifying it as part or TSDuck.

The string is built from fields, separated by '|'. The list of fields is:

  • Marker prefix: @($%)
  • String literal "tsduck"
  • TSDuck version number.
  • Compilation date. According to the C11 and C++11 standards, the value of the macro DATE is a character string literal of the form "Mmm dd yyyy", where the names of the months are the same as those generated by the asctime function, and the first character of dd is a space character if the value is less than 10.
  • Compilation time. According to the C11 and C++11 standards, the value of the macro TIME is a character string literal of the form "hh:mm:ss" as in the time generated by the asctime function.
  • Name of the source file which invokes the macro.