OSDEP API
This header provides a comprehensive cross-platform abstraction layer for embedded IoT applications. It defines standard types, platform detection constants, compiler abstractions, and operating system compatibility macros to enable portability across diverse embedded and desktop systems. This is the foundational module consumed by all other EmbedThis modules and must be included first in any source file. The module automatically detects the target platform's CPU architecture, operating system, compiler, and endianness to provide consistent behavior across ARM, x86, MIPS, PowerPC, SPARC, RISC-V, Xtensa, and other architectures running on Linux, macOS, Windows, VxWorks, FreeRTOS, ESP32, and other operating systems.
By including "osdep.h", you will include most common O/S headers and define a set of useful cross-platform constants.
Function Index
Typedef Index
| Offset | Signed 64-bit file offset type. |
| Socket | Argument for sockets. |
| Socklen | Size to hold the length of a socket address. |
| Ticks | Relative time in milliseconds for durations and intervals. |
| Time | Absolute time in milliseconds since Unix epoch. |
| bool | Boolean data type. |
| cchar | Constant character pointer type. |
| cint | Constant int data type. |
| cuchar | Constant unsigned character type. |
| cushort | Constant unsigned short data type. |
| cvoid | Constant void data type. |
| int16 | Signed 16-bit integer type. |
| int32 | Signed 32-bit integer type. |
| int8 | Signed 8-bit integer type. |
| schar | Signed 8-bit character type. |
| size_t | Unsigned integral type. |
| ssize | Signed size type for memory and I/O operations. |
| time_t | Unsigned time type. |
| uchar | Unsigned 8-bit character type. |
| uint | Unsigned integer (machine dependent bit size) data type. |
| uint16 | Unsigned 16-bit integer type. |
| uint32 | Unsigned 32-bit integer type. |
| uint8 | Unsigned 8-bit integer type. |
| ulong | Unsigned long (machine dependent bit size) data type. |
| ushort | Unsigned short data type. |
| wchar | Wide character type for ASCII/UTF-8. |
| wsize | Windows uses uint for write/read counts (Ugh!). |
Defines
| #define | BITS ((int) (BITSPERBYTE * (int) sizeof(type))) |
| Calculate number of bits in a data type. | |
| #define | BITSPERBYTE ((int) (8 * sizeof(char))) |
| Number of bits per byte. | |
| #define | HAS_BOOL 1 |
| #define | max (((a) > (b)) ? (a) : (b)) |
| Return the maximum of two values. | |
| #define | ME_64 0 |
| #define | ME_BIG_ENDIAN 2 |
| Big endian byte ordering. | |
| #define | ME_BUFSIZE 4096 |
| Standard buffer size for desktop/server systems. | |
| #define | ME_CHAR_LEN 1 |
| Character length for Unicode support. | |
| #define | ME_CPU_ARM 1 |
| ARM 32-bit architecture (ARMv7 and earlier). | |
| #define | ME_CPU_ARM64 2 |
| ARM 64-bit architecture (ARMv8 and later). | |
| #define | ME_CPU_ITANIUM 3 |
| Intel Itanium (IA-64) architecture. | |
| #define | ME_CPU_MIPS 6 |
| MIPS 32-bit architecture. | |
| #define | ME_CPU_MIPS64 7 |
| MIPS 64-bit architecture. | |
| #define | ME_CPU_PPC 8 |
| PowerPC 32-bit architecture. | |
| #define | ME_CPU_PPC64 9 |
| PowerPC 64-bit architecture. | |
| #define | ME_CPU_RISCV 13 |
| RISC-V 32-bit architecture. | |
| #define | ME_CPU_RISCV64 14 |
| RISC-V 64-bit architecture. | |
| #define | ME_CPU_SH 12 |
| SuperH architecture. | |
| #define | ME_CPU_SPARC 10 |
| SPARC architecture. | |
| #define | ME_CPU_TIDSP 11 |
| Texas Instruments DSP architecture. | |
| #define | ME_CPU_UNKNOWN 0 |
| Unknown or unsupported CPU architecture. | |
| #define | ME_CPU_X64 5 |
| Intel/AMD x86-64 architecture. | |
| #define | ME_CPU_X86 4 |
| Intel x86 32-bit architecture. | |
| #define | ME_CPU_XTENSA 15 |
| Xtensa architecture including ESP32. | |
| #define | ME_DEBUG 0 |
| Default to a debug build. | |
| #define | ME_DOUBLE_BUFFER (DBL_MANT_DIG - DBL_MIN_EXP + 4) |
| Buffer size for double-precision floating point string conversion. | |
| #define | ME_ENDIAN CPU_ENDIAN |
| #define | ME_LITTLE_ENDIAN 1 |
| Little endian byte ordering. | |
| #define | ME_MAX_ARGC 32 |
| Maximum command line arguments for desktop/server systems. | |
| #define | ME_MAX_FNAME 256 |
| Maximum filename length for desktop/server systems. | |
| #define | ME_MAX_IP 1024 |
| Maximum IP address string length for desktop/server systems. | |
| #define | ME_MAX_PATH 1024 |
| Maximum path length for desktop/server systems. | |
| #define | ME_STACK_SIZE (32 * 1024) |
| Default thread stack size for systems without virtual memory. | |
| #define | min (((a) < (b)) ? (a) : (b)) |
| Return the minimum of two values. | |
| #define | PRINTF_ATTRIBUTE |
| #define | TPS 1000 |
| Time/Ticks units per second (milliseconds). | |
| #define | UT s |
| String literal macro for ASCII/UTF-8 (no conversion). |
Typedefs
Boolean data type.
- Description:
- Provides consistent boolean type across platforms. Uses char underlying type for compatibility with systems lacking native bool support. Should be used with true/false constants.
- API Stability:
- Stable.
Constant character pointer type.
- Description:
- Commonly used for read-only string parameters and immutable text data.
- API Stability:
- Stable.
Constant int data type.
- API Stability:
- Stable.
Constant unsigned character type.
- Description:
- Provides read-only access to unsigned byte data.
- API Stability:
- Stable.
Constant unsigned short data type.
- API Stability:
- Stable.
Constant void data type.
- API Stability:
- Stable.
Signed 16-bit integer type.
- Description:
- Guaranteed 16-bit signed integer (-32,768 to 32,767) for network protocols and compact data.
- API Stability:
- Stable.
Signed 32-bit integer type.
- Description:
- Guaranteed 32-bit signed integer for general-purpose arithmetic and system values.
- API Stability:
- Stable.
Signed 8-bit integer type.
- Description:
- Guaranteed 8-bit signed integer (-128 to 127) for precise byte-level operations.
- API Stability:
- Stable.
Signed 64-bit file offset type.
- Description:
- Supports large files greater than 4GB in size on all systems. Used for file positioning, seeking, and size calculations. Always 64-bit regardless of platform word size.
- API Stability:
- Stable.
Signed 8-bit character type.
- Description:
- Provides explicit signed char semantics when the sign of char values matters.
- API Stability:
- Stable.
Unsigned integral type.
Equivalent in size to void*Argument for sockets.
- API Stability:
- Stable.
Size to hold the length of a socket address.
- API Stability:
- Stable.
Signed size type for memory and I/O operations.
- Description:
- Platform-appropriate signed integer type large enough to hold array indices, memory sizes, and I/O transfer counts. Can represent negative values for error conditions. Equivalent to size_t but signed.
- API Stability:
- Stable.
Relative time in milliseconds for durations and intervals.
- Description:
- Elapsed time measurement in milliseconds from an arbitrary starting point. Used for timeouts, delays, performance measurements, and relative time calculations.
- API Stability:
- Stable.
Absolute time in milliseconds since Unix epoch.
- Description:
- Time value representing milliseconds since January 1, 1970 UTC (Unix epoch). Used for timestamps, timeouts, and absolute time calculations across the system.
- API Stability:
- Stable.
Unsigned time type.
Time in seconds since Jan 1, 1970Unsigned 8-bit character type.
- Description:
- Provides explicit unsigned char semantics for byte manipulation and binary data handling.
- API Stability:
- Stable.
Unsigned integer (machine dependent bit size) data type.
- API Stability:
- Stable.
Unsigned 16-bit integer type.
- Description:
- Guaranteed 16-bit unsigned integer (0 to 65,535) for ports, packet sizes, and compact counters.
- API Stability:
- Stable.
Unsigned 32-bit integer type.
- Description:
- Guaranteed 32-bit unsigned integer for addresses, large counters, and hash values.
- API Stability:
- Stable.
Unsigned 8-bit integer type.
- Description:
- Guaranteed 8-bit unsigned integer (0 to 255) for byte manipulation and flags.
- API Stability:
- Stable.
Unsigned long (machine dependent bit size) data type.
- API Stability:
- Stable.
Unsigned short data type.
- API Stability:
- Stable.
Wide character type for ASCII/UTF-8.
- API Stability:
- Stable.
Windows uses uint for write/read counts (Ugh!).
- API Stability:
- Stable.
