summaryrefslogtreecommitdiffhomepage
path: root/pkg/sleep/commit_amd64.s
blob: 51d4f918957441ecbbea90d992f4be45367aa10d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2016 The Netstack Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#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