Skip to content

Instantly share code, notes, and snippets.

View xigh's full-sized avatar

Philippe Anel xigh

View GitHub Profile
@xigh
xigh / cond.go
Created August 23, 2018 14:02
How to use Golang sync/cond
package main
import (
"fmt"
"sync"
"time"
)
func main() {
c := sync.NewCond(&sync.Mutex{})
@xigh
xigh / asm_amd64.s
Last active May 20, 2024 09:48
DCAS for golang
TEXT ·CompareAndSwapDPointer(SB),4,$0
MOVQ addr+0(FP), SI
MOVQ old+8(FP), AX
MOVQ old+16(FP), DX
MOVQ new+24(FP), BX
MOVQ new+32(FP), CX
LOCK // forgot this one
// CMPXCHG16B (SI)
BYTE $0x48; BYTE $0x0F; BYTE $0xC7; BYTE $0x0E