aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/string/ffsl.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/string/ffsl.c')
-rw-r--r--lib/libc/string/ffsl.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/libc/string/ffsl.c b/lib/libc/string/ffsl.c
index dbd894b9655b..c3a87a902526 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
@@ -29,9 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <strings.h>
/*
@@ -40,11 +41,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);
}