Ported lfs_util functions to IAR intrinsics

required intrinsics for:
- lfs_ctz
- lfs_npw2
pull/5538/head
Christopher Haster 2017-10-10 06:28:08 -05:00
parent c390e89f17
commit 301232eb4e
1 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,9 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#ifdef __ICCARM__
#include <intrinsics.h>
#endif
// Builtin functions
@ -22,11 +25,19 @@ static inline uint32_t lfs_min(uint32_t a, uint32_t b) {
}
static inline uint32_t lfs_ctz(uint32_t a) {
#ifdef __ICCARM__
return __CLZ(__REV(a));
#else
return __builtin_ctz(a);
#endif
}
static inline uint32_t lfs_npw2(uint32_t a) {
#ifdef __ICCARM__
return 32 - __CLZ(a-1);
#else
return 32 - __builtin_clz(a-1);
#endif
}
static inline int lfs_scmp(uint32_t a, uint32_t b) {