mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
correctly support disabling caps with CAP REQ, fixes #337
This commit is contained in:
parent
6667585605
commit
f48af3ee44
5 changed files with 55 additions and 9 deletions
|
|
@ -89,3 +89,19 @@ func BitsetCopy(set []uint64, other []uint64) {
|
|||
atomic.StoreUint64(&set[i], data)
|
||||
}
|
||||
}
|
||||
|
||||
// BitsetSubtract modifies `set` to subtract the contents of `other`.
|
||||
// Similar caveats about race conditions as with `BitsetUnion` apply.
|
||||
func BitsetSubtract(set []uint64, other []uint64) {
|
||||
for i := 0; i < len(set); i++ {
|
||||
for {
|
||||
ourAddr := &set[i]
|
||||
ourBlock := atomic.LoadUint64(ourAddr)
|
||||
otherBlock := atomic.LoadUint64(&other[i])
|
||||
newBlock := ourBlock & (^otherBlock)
|
||||
if atomic.CompareAndSwapUint64(ourAddr, ourBlock, newBlock) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue