AWS IoT Device SDK C: Platform
Platform portability layer
Return to main page ↑
Configuration

Configuration settings of the platform layer.

Configuration settings are C pre-processor constants. They can be set with a #define in the config file (iot_config.h) or by using a compiler option such as -D in gcc. If a configuration setting is not defined, the library will use a "sensible" default value (unless otherwise noted). Because they are compile-time constants, a library must be rebuilt if a configuration setting is changed.

configpagemarker

IOT_ATOMIC_USE_PORT

Use a custom atomics port, provided in the header iot_atomic_port.h.

Set this to 1 to use a custom atomics port in place of any atomics port provided with the SDK. The custom atomics port should be implemented in platform/include/atomic/iot_atomic_port.h.

See Atomics and atomics functions for details on writing an atomics port.

Possible values: 0 (no atomic port) or 1 (use atomic port)
Default value (if undefined): 0

IOT_LOG_LEVEL_PLATFORM

Set the log level of all platform components except the networking component.

This setting overrides IOT_LOG_LEVEL_GLOBAL for the platform layer components that it affects. All log messages with a level at or below this setting will be printed. The platform networking component is generally more verbose than others, so its logging is controlled separately by IOT_LOG_LEVEL_NETWORK.

Possible values: One of the Log levels.
Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined, then IOT_LOG_NONE.

IOT_LOG_LEVEL_NETWORK

Set the log level of the platform networking component.

This setting overrides IOT_LOG_LEVEL_GLOBAL for the platform networking component. All log messages with a level at or below this setting will be printed. See IOT_LOG_LEVEL_PLATFORM to set the log level of other platform components.

Possible values: One of the Log levels.
Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined, then IOT_LOG_NONE.

Memory allocation

Memory allocation function overrides for the platform layer.

Some platform layers are not affected by IOT_STATIC_MEMORY_ONLY. Currently, the following platform implementations require memory allocation:

  • POSIX
    This implementation is not affected by IOT_STATIC_MEMORY_ONLY. However, its memory allocation functions may be overridden by setting the following constants. All memory allocation functions must have the same signatures as malloc and free.
    • IotThreads_Malloc and IotThreads_Free.
    • IotNetwork_Malloc and IotNetwork_Free.

POSIX headers

The POSIX platform layer allows the standard POSIX header includes to be overridden. Overrides only affect the POSIX platform layer.

Any substitute headers are expected to provide the same functionality as the standard POSIX headers. The POSIX header overrides should only be used if the system's headers do not follow the standard names for POSIX headers. The POSIX headers may be overridden by defining the following settings:

Standard name Setting
errno.h POSIX_ERRNO_HEADER
limits.h POSIX_LIMITS_HEADER
pthread.h POSIX_PTHREAD_HEADER
signal.h POSIX_SIGNAL_HEADER
semaphore.h POSIX_SEMAPHORE_HEADER
time.h POSIX_TIME_HEADER
sys/types.h POSIX_TYPES_HEADER

Example:
To use a header named custom_errno.h instead of errno.h, the POSIX_ERRNO_HEADER setting should be defined.

#define POSIX_ERRNO_HEADER "custom_errno.h"

Possible values: Strings representing file names. These files must be in the compiler's include path.
Default value (if undefined): Standard POSIX header names.