compiler.h File Reference
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.
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 |
| Support for macros with variable arguments. | |
| #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 realod 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) (sizeof(a) / sizeof(*(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. | |
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 * | 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. | |
| typedef unsigned char | page_t |
| Type for banked memory pages. | |
Types for hardware registers. | |
| typedef volatile uint8_t | reg8_t |
| typedef volatile uint16_t | reg16_t |
| typedef volatile uint32_t | reg32_t |
Detailed Description
Additional support macros for compiler independance.
- Version:
- Id
- compiler.h 3224 2010-03-17 11:53:11Z arighi
Definition in file compiler.h.
Define Documentation
| #define alignof | ( | type | ) | offsetof(struct { char c; type member; }, member) |
Return the alignment in memory of a generic data type.
- Note:
- We need to worry about alignment when allocating memory that will be used later by unknown objects (e.g., malloc()) or, more generally, whenever creating generic container types.
Definition at line 501 of file compiler.h.
| #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.
- Parameters:
-
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 512 of file compiler.h.
| #define countof | ( | a | ) | (sizeof(a) / sizeof(*(a))) |
Count the number of elements in the static array a.
- Note:
- This macro is non-standard, but implements a very common idiom
Definition at line 491 of file compiler.h.
| #define offsetof | ( | s, | |||
| m | ) | (size_t)&(((s *)0)->m) |
Return the byte offset of the member m in struct s.
- Note:
- This macro should be defined in "stddef.h" and is sometimes compiler-specific (g++ has a builtin for it).
Definition at line 483 of file compiler.h.
Typedef Documentation
| typedef const void* const_iptr_t |
Bulk storage large enough for both pointers to constants or integers.
Definition at line 409 of file compiler.h.
| typedef void* iptr_t |
Bulk storage large enough for both pointers or integers.
Definition at line 406 of file compiler.h.
| typedef int32_t mtime_t |
Type for time expressed in milliseconds.
Definition at line 399 of file compiler.h.
| typedef unsigned char page_t |
Type for banked memory pages.
Definition at line 413 of file compiler.h.
| typedef unsigned char sigbit_t |
Type for signal bits.
Definition at line 411 of file compiler.h.
| typedef unsigned char sigmask_t |
Type for signal masks.
Definition at line 412 of file compiler.h.
| typedef int32_t ticks_t |
Type for time expressed in ticks.
Definition at line 392 of file compiler.h.
| typedef int32_t utime_t |
Type for time expressed in microseconds.
Definition at line 394 of file compiler.h.
