summaryrefslogtreecommitdiffhomepage
path: root/pkg/sleep/commit_amd64.s
blob: a5b620bf830e4306cfd9533a9ed99bb0b9744dc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "textflag.h"

#define preparingG 1

// See commit_noasm.go for a description of commitSleep.
//
// func commitSleep(g uintptr, waitingG *uintptr) bool
TEXT ·commitSleep(SB),NOSPLIT,$0-24
	MOVQ waitingG+8(FP), CX
	MOVQ g+0(FP), DX

	// Store the G in waitingG if it's still preparingG. If it's anything
	// else it means a waker has aborted the sleep.
	MOVQ $preparingG, AX
	LOCK
	CMPXCHGQ DX, 0(CX)

	SETEQ AX
	MOVB AX, ret+16(FP)

	RET