1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
6 // The following code runs only on g0 stack.
12 func lfstackpush(head *uint64, node *lfnode) {
14 new := lfstackPack(node, node.pushcnt)
15 if node1, _ := lfstackUnpack(new); node1 != node {
16 println("runtime: lfstackpush invalid packing: node=", node, " cnt=", hex(node.pushcnt), " packed=", hex(new), " -> node=", node1, "\n")
17 gothrow("lfstackpush")
20 old := atomicload64(head)
22 if cas64(head, old, new) {
28 func lfstackpop(head *uint64) unsafe.Pointer {
30 old := atomicload64(head)
34 node, _ := lfstackUnpack(old)
35 next := atomicload64(&node.next)
36 if cas64(head, old, next) {
37 return unsafe.Pointer(node)