2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libgo / runtime / lfstack.c
blobcefe7b8fb388ac95309b5211da099e6c48347a4b
1 // AUTO-GENERATED by autogen.sh; DO NOT EDIT
3 #include "runtime.h"
4 #include "arch.h"
5 #if __SIZEOF_POINTER__ == 8
6 # define PTR_BITS 47
7 #else
8 # define PTR_BITS 32
9 #endif
10 #define PTR_MASK ((1ull<<PTR_BITS)-1)
11 #define CNT_MASK (0ull-1)
12 #if __SIZEOF_POINTER__ == 8 && (defined(__sparc__) || (defined(__sun__) && defined(__amd64__)))
13 #undef PTR_BITS
14 #undef CNT_MASK
15 #undef PTR_MASK
16 #define PTR_BITS 0
17 #define CNT_MASK 7
18 #define PTR_MASK ((0ull-1)<<3)
19 #endif
21 #line 33 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
22 void
23 runtime_lfstackpush ( uint64 *head , LFNode *node )
25 uint64 old , new;
26 #line 38 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
27 if ( ( uintptr ) node != ( ( uintptr ) node&PTR_MASK ) ) {
28 runtime_printf ( "p=%p\n" , node ) ;
29 runtime_throw ( "runtime_lfstackpush: invalid pointer" ) ;
31 #line 43 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
32 node->pushcnt++;
33 new = ( uint64 ) ( uintptr ) node| ( ( ( uint64 ) node->pushcnt&CNT_MASK ) <<PTR_BITS ) ;
34 for ( ;; ) {
35 old = runtime_atomicload64 ( head ) ;
36 node->next = ( LFNode* ) ( uintptr ) ( old&PTR_MASK ) ;
37 if ( runtime_cas64 ( head , old , new ) )
38 break;
41 #line 53 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
42 LFNode*
43 runtime_lfstackpop ( uint64 *head )
45 LFNode *node , *node2;
46 uint64 old , new;
47 #line 59 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
48 for ( ;; ) {
49 old = runtime_atomicload64 ( head ) ;
50 if ( old == 0 )
51 return nil;
52 node = ( LFNode* ) ( uintptr ) ( old&PTR_MASK ) ;
53 node2 = runtime_atomicloadp ( &node->next ) ;
54 new = 0;
55 if ( node2 != nil )
56 new = ( uint64 ) ( uintptr ) node2| ( ( ( uint64 ) node2->pushcnt&CNT_MASK ) <<PTR_BITS ) ;
57 if ( runtime_cas64 ( head , old , new ) )
58 return node;
61 void runtime_lfstackpush_go(uint64* head, LFNode* node) __asm__ (GOSYM_PREFIX "runtime.lfstackpush_go");
62 void runtime_lfstackpush_go(uint64* head, LFNode* node)
64 #line 73 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
66 runtime_lfstackpush(head, node);
68 LFNode* runtime_lfstackpop_go(uint64* head) __asm__ (GOSYM_PREFIX "runtime.lfstackpop_go");
69 LFNode* runtime_lfstackpop_go(uint64* head)
71 LFNode* node;
72 #line 77 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
74 node = runtime_lfstackpop(head);
75 return node;