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 | 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. | |
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 |
Detailed Description
Additional support macros for compiler independance.
- Version:
- Id
- compiler.h 1696 2008-08-25 18:54:02Z bernie
Definition in file compiler.h.
Define Documentation
| #define containerof | ( | ptr, | |||
| type, | |||||
| member | ) |
Value:
({ \
const typeof( ((type *)0)->member ) *_mptr = (ptr); /* type check */ \
(type *)((char *)_mptr - offsetof(type, member)); \
})
- 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 502 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 |
| typedef int32_t mtime_t |
| typedef unsigned char page_t |
| typedef unsigned char sigbit_t |
| typedef unsigned char sigmask_t |
| typedef int32_t ticks_t |
| typedef int32_t utime_t |
