builtin64.go 629 B

123456789101112131415161718192021222324
  1. // Copyright 2024 The Libc Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64)
  5. package libc // import "modernc.org/libc"
  6. import (
  7. mbits "math/bits"
  8. )
  9. func X__builtin_ctzl(tls *TLS, x ulong) int32 {
  10. return int32(mbits.TrailingZeros64(x))
  11. }
  12. func X__builtin_clzl(t *TLS, n ulong) int32 {
  13. return int32(mbits.LeadingZeros64(n))
  14. }
  15. // int __builtin_popcountl (unsigned long x)
  16. func X__builtin_popcountl(t *TLS, x ulong) int32 {
  17. return int32(mbits.OnesCount64(x))
  18. }