[libc-commits] [libc] [libc] implement stdc_leading_ones (C23) (PR #80082)
via libc-commits
libc-commits at lists.llvm.org
Wed Jan 31 11:36:42 PST 2024
================
@@ -0,0 +1,20 @@
+//===-- Implementation of stdc_leading_ones_ui ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdbit/stdc_leading_ones_ui.h"
+
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(unsigned, stdc_leading_ones_ui, (unsigned value)) {
+ return cpp::countl_one(value);
----------------
lntue wrote:
I think you need explicit cast here, since `cpp::countl_one` returns an `int` instead of `unsigned`?
https://github.com/llvm/llvm-project/pull/80082
More information about the libc-commits
mailing list