VOL-2017 voltha-lib moved from voltha-go;
release version 2.2.1
Based on voltha-go commit 5259f8e52b3e3f5c7ad422a4b0e506e1d07f6b36
Change-Id: I8bbecdf456e420714a4016120eafc0d237c80565
diff --git a/vendor/github.com/boljen/go-bitmap/uintmap.go b/vendor/github.com/boljen/go-bitmap/uintmap.go
new file mode 100644
index 0000000..72cbf4a
--- /dev/null
+++ b/vendor/github.com/boljen/go-bitmap/uintmap.go
@@ -0,0 +1,32 @@
+package bitmap
+
+import (
+ "sync/atomic"
+ "unsafe"
+)
+
+// SetAtomicUint32 sets the target bit to the target value inside the uint32
+// encded bitmap.
+func SetAtomicUint32(bitmap []uint32, targetBit int, targetValue bool) {
+ targetIndex := targetBit / 32
+ BitOffset := targetBit % 32
+
+ for {
+ localValue := atomic.LoadUint32(&bitmap[targetIndex])
+ targetBytes := (*[4]byte)(unsafe.Pointer(&localValue))[:]
+ if Get(targetBytes, BitOffset) == targetValue {
+ return
+ }
+ referenceValue := localValue
+ Set(targetBytes, BitOffset, targetValue)
+ if atomic.CompareAndSwapUint32(&bitmap[targetIndex], referenceValue, localValue) {
+ break
+ }
+ }
+}
+
+// GetAtomicUint32 gets the target bit from an uint32 encoded bitmap.
+func GetAtomicUint32(bitmap []uint32, targetBit int) bool {
+ data := (*[4]byte)(unsafe.Pointer(&bitmap[targetBit/32]))[:]
+ return Get(data, targetBit%32)
+}