builtin32.go 583 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 && (386 || arm)
  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.TrailingZeros32(x))
  11. }
  12. func X__builtin_clzl(t *TLS, n ulong) int32 {
  13. return int32(mbits.LeadingZeros32(n))
  14. }
  15. // int __builtin_popcountl (unsigned long x)
  16. func X__builtin_popcountl(t *TLS, x ulong) int32 {
  17. return int32(mbits.OnesCount32(x))
  18. }