func HasAnyAtomic(bits *int64, flags ...int) bool {
	return HasAnyMaskAtomic(bits, Mask(flags...))
}
HasAnyAtomic checks if *any* of a set of flags are set for ordinal bit position flags (logical OR)
using atomic compare-and-swap loop, safe for concurrent access
package bitflag
import "sync/atomic"
func SetMask(bits *int64, mask int64) {
	*bits |= mask
}
func SetMaskAtomic(bits *int64, mask int64) {
	for {
		cr := atomic.LoadInt64(bits)
		nw := cr | mask
		if atomic.CompareAndSwapInt64(bits, cr, nw) {
			break
		}
	}
}
func ClearMask(bits *int64, mask int64) {
	*bits &^= mask
}
func ClearMaskAtomic(bits *int64, mask int64) {
	for {
		cr := atomic.LoadInt64(bits)
		nw := cr &^ mask
		if atomic.CompareAndSwapInt64(bits, cr, nw) {
			break
		}
	}
}
func HasAnyMask(bits, mask int64) bool {
	return bits&mask != 0
}
func HasAllMask(bits, mask int64) bool {
	return bits&mask == mask
}
func HasAnyMaskAtomic(bits *int64, mask int64) bool {
	return (atomic.LoadInt64(bits) & mask) != 0
}
func HasAllMaskAtomic(bits *int64, mask int64) bool {
	return (atomic.LoadInt64(bits) & mask) == mask
}
func Mask(flags ...int) int64 {
	var mask int64
	for _, f := range flags {
		mask |= 1 << uint32(f)
	}
	return mask
}
func Set(bits *int64, flags ...int) {
	SetMask(bits, Mask(flags...))
}
func SetAtomic(bits *int64, flags ...int) {
	SetMaskAtomic(bits, Mask(flags...))
}
func SetState(bits *int64, state bool, flags ...int) {
	if state {
		Set(bits, flags...)
	} else {
		Clear(bits, flags...)
	}
}
func SetStateAtomic(bits *int64, state bool, flags ...int) {
	if state {
		SetAtomic(bits, flags...)
	} else {
		ClearAtomic(bits, flags...)
	}
}
func Clear(bits *int64, flags ...int) {
	ClearMask(bits, Mask(flags...))
}
func ClearAtomic(bits *int64, flags ...int) {
	ClearMaskAtomic(bits, Mask(flags...))
}
func Has(bits int64, flag int) bool {
	return bits&(1<<uint32(flag)) != 0
}
func HasAtomic(bits *int64, flag int) bool {
	return atomic.LoadInt64(bits)&(1<<uint32(flag)) != 0
}
func HasAny(bits int64, flags ...int) bool {
	return HasAnyMask(bits, Mask(flags...))
}
func HasAll(bits int64, flags ...int) bool {
	return HasAllMask(bits, Mask(flags...))
}