BeRTOS
|
Additional support macros for compiler independance. More...
#include <cpu/detect.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>
Go to the source code of this file.
Data Structures | |
struct | Signal |
Signal structure. More... | |
Defines | |
#define | PP_CAT(x, y) PP_CAT__(x,y) |
Concatenate two different preprocessor tokens (allowing macros to expand) | |
#define | PP_STRINGIZE(x) PP_STRINGIZE__(x) |
String-ize a token (allowing macros to expand) | |
#define | COMPILER_VARIADIC_MACROS 1 |
usage: | |
#define | COMPILER_TYPEOF 1 |
Support for dynamic type identification. | |
#define | COMPILER_STATEMENT_EXPRESSIONS 1 |
Support for statement expressions. | |
#define | MEMORY_BARRIER asm volatile ("" : : : "memory") |
Force compiler to reload context variable. | |
#define | offsetof(s, m) (size_t)&(((s *)0)->m) |
Return the byte offset of the member m in struct s. | |
#define | countof(a) |
Count the number of elements in the static array a. | |
#define | alignof(type) offsetof(struct { char c; type member; }, member) |
Return the alignment in memory of a generic data type. | |
#define | containerof(ptr, type, member) |
Cast a member of a structure out to the containing structure. | |
#define | STATIC_ASSERT(condition) UNUSED_VAR(extern char, STATIC_ASSERTION_FAILED__[(condition) ? 1 : -1]) |
Issue a compilation error if the condition is false. | |
#define | STATIC_ASSERT_EXPR(__cond) (sizeof(struct { int STATIC_ASSERTION_FAILED__:!!(__cond); }) * 0) |
Issue a compilation error if __cond is false (this can be used inside an expression). | |
#define | ACCESS_SAFE(x) (*(volatile typeof(x) *)&(x)) |
Prevent the compiler from optimizing access to the variable x, enforcing a refetch from memory. | |
Typedefs | |
typedef int32_t | ticks_t |
Type for time expressed in ticks. | |
typedef int32_t | utime_t |
Type for time expressed in microseconds. | |
typedef int32_t | mtime_t |
Type for time expressed in milliseconds. | |
typedef void(* | Hook )(void *) |
User defined callback type. | |
typedef void * | iptr_t |
Bulk storage large enough for both pointers or integers. | |
typedef const void * | const_iptr_t |
Bulk storage large enough for both pointers to constants or integers. | |
typedef unsigned char | sigbit_t |
Type for signal bits. | |
typedef unsigned char | sigmask_t |
Type for signal masks. | |
Types for hardware registers. | |
Only use these types for registers whose contents can be changed asynchronously by external hardware. | |
typedef volatile uint8_t | reg8_t |
typedef volatile uint16_t | reg16_t |
typedef volatile uint32_t | reg32_t |
Additional support macros for compiler independance.
Definition in file compiler.h.
#define ACCESS_SAFE | ( | x | ) | (*(volatile typeof(x) *)&(x)) |
Prevent the compiler from optimizing access to the variable x, enforcing a refetch from memory.
This also forbid from reordering successing instances of ACCESS_SAFE().
Definition at line 637 of file compiler.h.
#define alignof | ( | type | ) | offsetof(struct { char c; type member; }, member) |
Return the alignment in memory of a generic data type.
Definition at line 586 of file compiler.h.
#define COMPILER_VARIADIC_MACROS 1 |
usage:
Support for macros with variable arguments.
#define foo_init(args...) PP_CAT(foo_init_, COUNT_PARMS(args)) (args)
#define containerof | ( | ptr, | |
type, | |||
member | |||
) |
({ \ typeof( ((type *)0)->member ) *_mptr = (ptr); /* type check */ \ (type *)(void *)((char *)_mptr - offsetof(type, member)); \ })
Cast a member of a structure out to the containing structure.
ptr | the pointer to the member. |
type | the type of the container struct this is embedded in. |
member | the name of the member within the struct. |
Definition at line 597 of file compiler.h.
#define countof | ( | a | ) |
(sizeof(a) / sizeof(*(a)) + \ STATIC_ASSERT_EXPR( \ !__builtin_types_compatible_p( \ typeof(a), typeof(&a[0]))))
Count the number of elements in the static array a.
Definition at line 570 of file compiler.h.
#define offsetof | ( | s, | |
m | |||
) | (size_t)&(((s *)0)->m) |
Return the byte offset of the member m in struct s.
Definition at line 553 of file compiler.h.
typedef const void* const_iptr_t |
Bulk storage large enough for both pointers to constants or integers.
Definition at line 472 of file compiler.h.
typedef void* iptr_t |
Bulk storage large enough for both pointers or integers.
Definition at line 469 of file compiler.h.
typedef int32_t mtime_t |
Type for time expressed in milliseconds.
Definition at line 459 of file compiler.h.
typedef unsigned char sigbit_t |
Type for signal bits.
Definition at line 474 of file compiler.h.
typedef unsigned char sigmask_t |
Type for signal masks.
Definition at line 475 of file compiler.h.
typedef int32_t ticks_t |
Type for time expressed in ticks.
Definition at line 452 of file compiler.h.
typedef int32_t utime_t |
Type for time expressed in microseconds.
Definition at line 454 of file compiler.h.