Lines Matching refs:a
108 static inline uint32_t lfs_max(uint32_t a, uint32_t b) { in lfs_max() argument
109 return (a > b) ? a : b; in lfs_max()
112 static inline uint32_t lfs_min(uint32_t a, uint32_t b) { in lfs_min() argument
113 return (a < b) ? a : b; in lfs_min()
117 static inline uint32_t lfs_aligndown(uint32_t a, uint32_t alignment) { in lfs_aligndown() argument
118 return a - (a % alignment); in lfs_aligndown()
121 static inline uint32_t lfs_alignup(uint32_t a, uint32_t alignment) { in lfs_alignup() argument
122 return lfs_aligndown(a + alignment-1, alignment); in lfs_alignup()
126 static inline uint32_t lfs_npw2(uint32_t a) { in lfs_npw2() argument
128 return 32 - __builtin_clz(a-1); in lfs_npw2()
132 a -= 1; in lfs_npw2()
133 s = (a > 0xffff) << 4; a >>= s; r |= s; in lfs_npw2()
134 s = (a > 0xff ) << 3; a >>= s; r |= s; in lfs_npw2()
135 s = (a > 0xf ) << 2; a >>= s; r |= s; in lfs_npw2()
136 s = (a > 0x3 ) << 1; a >>= s; r |= s; in lfs_npw2()
137 return (r | (a >> 1)) + 1; in lfs_npw2()
143 static inline uint32_t lfs_ctz(uint32_t a) { in lfs_ctz() argument
145 return __builtin_ctz(a); in lfs_ctz()
147 return lfs_npw2((a & -a) + 1) - 1; in lfs_ctz()
152 static inline uint32_t lfs_popc(uint32_t a) { in lfs_popc() argument
154 return __builtin_popcount(a); in lfs_popc()
156 a = a - ((a >> 1) & 0x55555555); in lfs_popc()
157 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); in lfs_popc()
158 return (((a + (a >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24; in lfs_popc()
164 static inline int lfs_scmp(uint32_t a, uint32_t b) { in lfs_scmp() argument
165 return (int)(unsigned)(a - b); in lfs_scmp()
169 static inline uint32_t lfs_fromle32(uint32_t a) { in lfs_fromle32() argument
173 return a; in lfs_fromle32()
178 return __builtin_bswap32(a); in lfs_fromle32()
180 return (((uint8_t*)&a)[0] << 0) | in lfs_fromle32()
181 (((uint8_t*)&a)[1] << 8) | in lfs_fromle32()
182 (((uint8_t*)&a)[2] << 16) | in lfs_fromle32()
183 (((uint8_t*)&a)[3] << 24); in lfs_fromle32()
187 static inline uint32_t lfs_tole32(uint32_t a) { in lfs_tole32() argument
188 return lfs_fromle32(a); in lfs_tole32()
192 static inline uint32_t lfs_frombe32(uint32_t a) { in lfs_frombe32() argument
197 return __builtin_bswap32(a); in lfs_frombe32()
201 return a; in lfs_frombe32()
203 return (((uint8_t*)&a)[0] << 24) | in lfs_frombe32()
204 (((uint8_t*)&a)[1] << 16) | in lfs_frombe32()
205 (((uint8_t*)&a)[2] << 8) | in lfs_frombe32()
206 (((uint8_t*)&a)[3] << 0); in lfs_frombe32()
210 static inline uint32_t lfs_tobe32(uint32_t a) { in lfs_tobe32() argument
211 return lfs_frombe32(a); in lfs_tobe32()