diff options
Diffstat (limited to 'firmware/export/system.h')
-rw-r--r-- | firmware/export/system.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h index b973b57fd9..dc3853211b 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -159,6 +159,20 @@ int get_cpu_boost_counter(void); | |||
159 | #define H_TO_BE32(x) (x) | 159 | #define H_TO_BE32(x) (x) |
160 | #endif | 160 | #endif |
161 | 161 | ||
162 | /* Get the byte offset of a type's member */ | ||
163 | #define OFFSETOF(type, membername) ((off_t)&((type *)0)->membername) | ||
164 | |||
165 | /* Get the type pointer from one of its members */ | ||
166 | #define TYPE_FROM_MEMBER(type, memberptr, membername) \ | ||
167 | ((type *)((intptr_t)(memberptr) - OFFSETOF(type, membername))) | ||
168 | |||
169 | /* returns index of first set bit + 1 or 0 if no bits are set */ | ||
170 | int find_first_set_bit(uint32_t val); | ||
171 | |||
172 | static inline __attribute__((always_inline)) | ||
173 | uint32_t isolate_first_bit(uint32_t val) | ||
174 | { return val & -val; } | ||
175 | |||
162 | /* gcc 3.4 changed the format of the constraints */ | 176 | /* gcc 3.4 changed the format of the constraints */ |
163 | #if (__GNUC__ >= 3) && (__GNUC_MINOR__ > 3) || (__GNUC__ >= 4) | 177 | #if (__GNUC__ >= 3) && (__GNUC_MINOR__ > 3) || (__GNUC__ >= 4) |
164 | #define I_CONSTRAINT "I08" | 178 | #define I_CONSTRAINT "I08" |