Lines Matching refs:a
82 static inline uint32_t lfs_max(uint32_t a, uint32_t b) in lfs_max() argument
84 return (a > b) ? a : b; in lfs_max()
87 static inline uint32_t lfs_min(uint32_t a, uint32_t b) in lfs_min() argument
89 return (a < b) ? a : b; in lfs_min()
93 static inline uint32_t lfs_aligndown(uint32_t a, uint32_t alignment) in lfs_aligndown() argument
95 return a - (a % alignment); in lfs_aligndown()
98 static inline uint32_t lfs_alignup(uint32_t a, uint32_t alignment) in lfs_alignup() argument
100 return lfs_aligndown(a + alignment-1, alignment); in lfs_alignup()
104 static inline uint32_t lfs_npw2(uint32_t a) in lfs_npw2() argument
107 return 32 - __builtin_clz(a-1); in lfs_npw2()
112 a -= 1; in lfs_npw2()
113 s = (a > 0xffff) << 4; a >>= s; r |= s; in lfs_npw2()
114 s = (a > 0xff) << 3; a >>= s; r |= s; in lfs_npw2()
115 s = (a > 0xf) << 2; a >>= s; r |= s; in lfs_npw2()
116 s = (a > 0x3) << 1; a >>= s; r |= s; in lfs_npw2()
117 return (r | (a >> 1)) + 1; in lfs_npw2()
123 static inline uint32_t lfs_ctz(uint32_t a) in lfs_ctz() argument
126 return __builtin_ctz(a); in lfs_ctz()
128 return lfs_npw2((a & -a) + 1) - 1; in lfs_ctz()
133 static inline uint32_t lfs_popc(uint32_t a) in lfs_popc() argument
136 return __builtin_popcount(a); in lfs_popc()
138 a = a - ((a >> 1) & 0x55555555); in lfs_popc()
139 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); in lfs_popc()
140 return (((a + (a >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24; in lfs_popc()
146 static inline int lfs_scmp(uint32_t a, uint32_t b) in lfs_scmp() argument
148 return (int)(unsigned int)(a - b); in lfs_scmp()
152 static inline uint32_t lfs_fromle32(uint32_t a) in lfs_fromle32() argument
155 return a; in lfs_fromle32()
157 return __builtin_bswap32(a); in lfs_fromle32()
159 return (((uint8_t *)&a)[0] << 0) | in lfs_fromle32()
160 (((uint8_t *)&a)[1] << 8) | in lfs_fromle32()
161 (((uint8_t *)&a)[2] << 16) | in lfs_fromle32()
162 (((uint8_t *)&a)[3] << 24); in lfs_fromle32()
166 static inline uint32_t lfs_tole32(uint32_t a) in lfs_tole32() argument
168 return lfs_fromle32(a); in lfs_tole32()
172 static inline uint32_t lfs_frombe32(uint32_t a) in lfs_frombe32() argument
175 return a; in lfs_frombe32()
177 return __builtin_bswap32(a); in lfs_frombe32()
179 return (((uint8_t *)&a)[0] << 24) | in lfs_frombe32()
180 (((uint8_t *)&a)[1] << 16) | in lfs_frombe32()
181 (((uint8_t *)&a)[2] << 8) | in lfs_frombe32()
182 (((uint8_t *)&a)[3] << 0); in lfs_frombe32()
186 static inline uint32_t lfs_tobe32(uint32_t a) in lfs_tobe32() argument
188 return lfs_frombe32(a); in lfs_tobe32()