diff options
Diffstat (limited to 'lib/libc/string/ffsl.c')
-rw-r--r-- | lib/libc/string/ffsl.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/libc/string/ffsl.c b/lib/libc/string/ffsl.c index dbd894b9655b..701e23cdf8f4 100644 --- a/lib/libc/string/ffsl.c +++ b/lib/libc/string/ffsl.c @@ -3,6 +3,10 @@ * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. + * Copyright (c) 2023 The FreeBSD Foundation + * + * Portions of this software were developed by Robert Clausecker + * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,11 +44,5 @@ __FBSDID("$FreeBSD$"); int ffsl(long mask) { - int bit; - - if (mask == 0) - return (0); - for (bit = 1; !(mask & 1); bit++) - mask = (unsigned long)mask >> 1; - return (bit); + return (mask == 0 ? 0 : __builtin_ctzl(mask) + 1); } |