High Performance OPC UA Server SDK  1.7.1.383
platform

Abstraction layer for different platforms. More...

Modules

 file
 Wrapper for common file operations.
 
 guid
 Platform level guid abstraction.
 
 hostname
 Functionality for retrieving local hostname information.
 
 ipc_mem
 
 memory
 Wrapper for common memory operations.
 
 mutex
 Mutex that can be locked and unlocked for mutual exclusion of different processes.
 
 platform
 General platform specfic defines and initialization/cleanup for platform layer.
 
 process
 Functionality for starting and stopping processes.
 
 semaphore
 Semaphore for managing shared resources.
 
 shutdown
 Functionality for server shutdown and configuration reload.
 
 time
 Retrieve current time in different formats and sleep.
 
#define UA_BEGIN_EXTERN_C
 
#define UA_END_EXTERN_C
 
#define UA_UNUSED(x)   (void)(x)
 Indicates to the compiler that the parameter with the specified name is not used in the body of a function. More...
 
#define UA_LITTLE_ENDIAN   __LITTLE_ENDIAN
 
#define UA_BIG_ENDIAN   __BIG_ENDIAN
 
#define UA_PDP_ENDIAN   __PDP_ENDIAN
 
#define UA_BYTE_ORDER   __BYTE_ORDER
 
#define UA_FLOAT_BYTE_ORDER   UA_BYTE_ORDER
 
#define UA_DOUBLE_BYTE_ORDER   UA_BYTE_ORDER
 
#define container_of(ptr, type, member)
 container_of returns the base address of the structure containing the field 'member'. More...
 
#define GCC_VERSION   (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
 
#define BUILD_BUG_ON_ZERO(e)   (sizeof(struct { int : -!!(e); }))
 Force a compilation error if condition is true, but also produce a result (of value 0 and type size_t), so the expression can be used e.g. More...
 
#define __must_be_array(a)   BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
 Ensures the given argument is an array. More...
 
#define countof(arr)   (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 Returns the size of an array (number of elements). More...
 
#define ua_bswap16(x)   ((((uint16_t)(x)) >> 8) | (((uint16_t)(x)) << 8))
 
#define ua_bswap32(x)
 
#define ua_bswap64(x)
 
#define ua_htole16(x)   (x)
 
#define ua_htole32(x)   (x)
 
#define ua_htole64(x)   (x)
 
#define ua_letoh16(x)   ua_htole16(x)
 
#define ua_letoh32(x)   ua_htole32(x)
 
#define ua_letoh64(x)   ua_htole64(x)
 
#define ua_offsetof   offsetof
 The offsetof macro as defined in C89 and C99, but certain platforms need workarounds. More...
 
#define UA_FORMAT_ARGUMENT(fmt, va)
 Marks arguments to be format specifier which allows further static checks by GCC and Clang. More...
 
#define UA_WEAK_SYMBOL
 
#define UA_CONST_FUNCTION   __attribute__((const))
 Const function, has no side effects only reads parameters, it does not modifiy anything.
 
#define UA_PURE_FUNCTION   __attribute__((pure))
 Pure function, has no side effects only reads parameters and global state, it does not modifiy anything.
 
#define UA_NONNULL(...)   __attribute__((nonnull(__VA_ARGS__)))
 Mark non null parameters. More...
 
#define UA_HAVE_NONNULL_SUPPORT
 Pointer checks of arguments defined as NONNULL produce warnings. More...
 
#define UA_DEPRECATED   __attribute((__deprecated__))
 Macro for marking functions as deprecated. More...
 
#define UA_WARN_UNUSED_RESULT   __attribute((__warn_unused_result__))
 Macro to force checking the return values (missing error handling)
 
#define UA_NORETURN   __attribute((noreturn))
 Function marked with this macro might never return. More...
 
#define PRIuSIZE_T   "zu"
 format specifier for size_t (unsigned)
 
#define PRIiSIZE_T   "zi"
 format specifier for ssize_t (signed, but also not supported at all by MS)
 
#define UA_ASSERT(cond)   assert(cond)
 portable wrapper for assert function/macro
 
#define UA_STATIC_ASSERT(cond, msg)
 A static assert macro as defined by C11. More...
 
#define UA_SAFESTR(x)   (x) ? (x) : "(NULL)"
 allows to safely print strings which may be NULL
 
#define UA_MIN(a, b)
 
#define UA_MAX(a, b)
 
#define UA_P_TRACE_INFO(msg, ...)   fprintf(stdout, msg, ##__VA_ARGS__)
 Platform layer trace macro which prints to stdout. More...
 
#define UA_P_TRACE_ERROR(msg, ...)   fprintf(stderr, msg, ##__VA_ARGS__)
 Platform layer trace macro which prints to stderr. More...
 
#define SDK_INTERNAL   __attribute__((deprecated("You are using an SDK internal function")))
 
int ua_p_platform_init (void)
 
int ua_p_platform_cleanup (void)
 
void ua_p_platform_panic (const char *msg, const char *file, int line) UA_NORETURN
 

Detailed Description

Abstraction layer for different platforms.

Macro Definition Documentation

◆ __must_be_array

#define __must_be_array (   a)    BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))

Ensures the given argument is an array.

Returns zero if arr is an array or produces an error using BUILD_BUG_ON_ZERO.

◆ BUILD_BUG_ON_ZERO

#define BUILD_BUG_ON_ZERO (   e)    (sizeof(struct { int : -!!(e); }))

Force a compilation error if condition is true, but also produce a result (of value 0 and type size_t), so the expression can be used e.g.

in a structure initializer (or where-ever else comma expressions aren't permitted).

◆ container_of

#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
typeof(((type *)0)->member) *__mptr = (ptr); \
(type *)(void *)((char *)__mptr - offsetof(type, member)); \
})

container_of returns the base address of the structure containing the field 'member'.

So it does the same as offsetof() macro which is part of the C standard, just in the opposite direction. Indeed it uses offsetof() to calculate the address.

struct foo {
int foo;
int bar;
int x;
};
struct foo test;
struct foo *p;
int *barptr = &test.bar;

Assume you have the address of the field bar and want to get the address of test. Do the following.

p = container_of(barptr, struct foo, bar);

◆ countof

#define countof (   arr)    (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

Returns the size of an array (number of elements).

We use some GCC magic to make it more typesafe, if this macro is used on a pointer it will break the build instead of producing incorrect results.

◆ ua_bswap32

#define ua_bswap32 (   x)
Value:
(((((uint32_t)(x)) & 0xff000000) >> 24) | ((((uint32_t)(x)) & 0x00ff0000) >> 8) | \
((((uint32_t)(x)) & 0x0000ff00) << 8) | ((((uint32_t)(x)) & 0x000000ff) << 24))

◆ ua_bswap64

#define ua_bswap64 (   x)
Value:
(((((uint64_t)(x)) & 0xff00000000000000ll) >> 56) | ((((uint64_t)(x)) & 0x00ff000000000000ll) >> 40) | \
((((uint64_t)(x)) & 0x0000ff0000000000ll) >> 24) | ((((uint64_t)(x)) & 0x000000ff00000000ll) >> 8) | \
((((uint64_t)(x)) & 0x00000000ff000000ll) << 8) | ((((uint64_t)(x)) & 0x0000000000ff0000ll) << 24) | \
((((uint64_t)(x)) & 0x000000000000ff00ll) << 40) | ((((uint64_t)(x)) & 0x00000000000000ffll) << 56))

◆ UA_DEPRECATED

#define UA_DEPRECATED   __attribute((__deprecated__))

Macro for marking functions as deprecated.

◆ UA_FORMAT_ARGUMENT

#define UA_FORMAT_ARGUMENT (   fmt,
  va 
)

Marks arguments to be format specifier which allows further static checks by GCC and Clang.

Parameters
fmtindex of the format string (starting from 1)
vaindex of the first variable argument (starting from 1)

◆ UA_HAVE_NONNULL_SUPPORT

#define UA_HAVE_NONNULL_SUPPORT

Pointer checks of arguments defined as NONNULL produce warnings.

So we do this only if the compiler does not support the nonnull attribute, otherwise we need those checks.

◆ UA_MAX

#define UA_MAX (   a,
 
)
Value:
({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a > _b ? _a : _b; \
})

◆ UA_MIN

#define UA_MIN (   a,
 
)
Value:
({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a < _b ? _a : _b; \
})

◆ UA_NONNULL

#define UA_NONNULL (   ...)    __attribute__((nonnull(__VA_ARGS__)))

Mark non null parameters.

Example: my_memcpy (void *dest, const void *src, size_t len) UA_NONNULL(1, 2);

◆ UA_NORETURN

#define UA_NORETURN   __attribute((noreturn))

Function marked with this macro might never return.

Example: my_exit() UA_NORETURN;

◆ ua_offsetof

#define ua_offsetof   offsetof

The offsetof macro as defined in C89 and C99, but certain platforms need workarounds.

◆ UA_P_TRACE_ERROR

#define UA_P_TRACE_ERROR (   msg,
  ... 
)    fprintf(stderr, msg, ##__VA_ARGS__)

Platform layer trace macro which prints to stderr.

◆ UA_P_TRACE_INFO

#define UA_P_TRACE_INFO (   msg,
  ... 
)    fprintf(stdout, msg, ##__VA_ARGS__)

Platform layer trace macro which prints to stdout.

◆ UA_STATIC_ASSERT

#define UA_STATIC_ASSERT (   cond,
  msg 
)

A static assert macro as defined by C11.

For compilers which don't support it, this will be an empty define.

◆ UA_UNUSED

#define UA_UNUSED (   x)    (void)(x)

Indicates to the compiler that the parameter with the specified name is not used in the body of a function.

This can be used to suppress compiler warnings while allowing functions to be defined with meaningful parameter names in their signatures.