1/* 2 * Copyright 2022, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _FBSD_MACHINE_GENERIC_CPUFUNC_H_ 6#define _FBSD_MACHINE_GENERIC_CPUFUNC_H_ 7 8 9#define HAVE_INLINE_FLS 10static __inline int 11fls(int mask) 12{ 13 int bit; 14 if (mask == 0) 15 return 0; 16 for (bit = 1; mask != 1; bit++) 17 mask = (unsigned int) mask >> 1; 18 return bit; 19} 20 21 22#define HAVE_INLINE_FFSL 23static __inline int 24ffsl(long mask) 25{ 26 int bit; 27 28 if (mask == 0) 29 return (0); 30 for (bit = 1; !(mask & 1); bit++) 31 mask = (unsigned long)mask >> 1; 32 return (bit); 33} 34 35 36#endif /* _FBSD_MACHINE_GENERIC_CPUFUNC_H_ */ 37