// Copyright 2016 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.//go:build !386// TODO finish intrinsifying 386, deadcode the assembly, remove build tags, merge w/ intrinsics_commonpackage sys// Copied from math/bits to avoid dependence.var deBruijn32tab = [32]byte{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9,}const deBruijn32 = 0x077CB531var deBruijn64tab = [64]byte{0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4,62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5,63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11,54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6,}const deBruijn64 = 0x03f79d71b4ca8b09const ntz8tab = "" +"\x08\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x06\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x07\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x06\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" +"\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00"// TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0.func ( uint32) int {if == 0 {return32 }// see comment in TrailingZeros64returnint(deBruijn32tab[(&-)*deBruijn32>>(32-5)])}// TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0.func ( uint64) int {if == 0 {return64 }// If popcount is fast, replace code below with return popcount(^x & (x - 1)). // // x & -x leaves only the right-most bit set in the word. Let k be the // index of that bit. Since only a single bit is set, the value is two // to the power of k. Multiplying by a power of two is equivalent to // left shifting, in this case by k bits. The de Bruijn (64 bit) constant // is such that all six bit, consecutive substrings are distinct. // Therefore, if we have a left shifted version of this constant we can // find by how many bits it was shifted by looking at which six bit // substring ended up at the top of the word. // (Knuth, volume 4, section 7.3.1)returnint(deBruijn64tab[(&-)*deBruijn64>>(64-6)])}// TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0.func ( uint8) int {returnint(ntz8tab[])}// Bswap64 returns its input with byte order reversed// 0x0102030405060708 -> 0x0807060504030201func ( uint64) uint64 { := uint64(0x00ff00ff00ff00ff) := >> 8 & := ( & ) << 8 = | := uint64(0x0000ffff0000ffff) = >> 16 & = ( & ) << 16 = | := uint64(0x00000000ffffffff) = >> 32 & = ( & ) << 32 = | return}// Bswap32 returns its input with byte order reversed// 0x01020304 -> 0x04030201func ( uint32) uint32 { := uint32(0x00ff00ff) := >> 8 & := ( & ) << 8 = | := uint32(0x0000ffff) = >> 16 & = ( & ) << 16 = | return}
The pages are generated with Goldsv0.6.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.