Skip to content

Commit 301232e

Browse files
committed
Ported lfs_util functions to IAR intrinsics
required intrinsics for: - lfs_ctz - lfs_npw2
1 parent c390e89 commit 301232e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

littlefs/lfs_util.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <stdlib.h>
1111
#include <stdint.h>
1212
#include <stdio.h>
13+
#ifdef __ICCARM__
14+
#include <intrinsics.h>
15+
#endif
1316

1417

1518
// Builtin functions
@@ -22,11 +25,19 @@ static inline uint32_t lfs_min(uint32_t a, uint32_t b) {
2225
}
2326

2427
static inline uint32_t lfs_ctz(uint32_t a) {
28+
#ifdef __ICCARM__
29+
return __CLZ(__REV(a));
30+
#else
2531
return __builtin_ctz(a);
32+
#endif
2633
}
2734

2835
static inline uint32_t lfs_npw2(uint32_t a) {
36+
#ifdef __ICCARM__
37+
return 32 - __CLZ(a-1);
38+
#else
2939
return 32 - __builtin_clz(a-1);
40+
#endif
3041
}
3142

3243
static inline int lfs_scmp(uint32_t a, uint32_t b) {

0 commit comments

Comments
 (0)