00d86ac99f
From-SVN: r212837
77 lines
2.3 KiB
C
77 lines
2.3 KiB
C
// AUTO-GENERATED by autogen.sh; DO NOT EDIT
|
|
|
|
#include "runtime.h"
|
|
#include "arch.h"
|
|
#if __SIZEOF_POINTER__ == 8
|
|
# define PTR_BITS 47
|
|
#else
|
|
# define PTR_BITS 32
|
|
#endif
|
|
#define PTR_MASK ((1ull<<PTR_BITS)-1)
|
|
#define CNT_MASK (0ull-1)
|
|
#if __SIZEOF_POINTER__ == 8 && (defined(__sparc__) || (defined(__sun__) && defined(__amd64__)))
|
|
#undef PTR_BITS
|
|
#undef CNT_MASK
|
|
#undef PTR_MASK
|
|
#define PTR_BITS 0
|
|
#define CNT_MASK 7
|
|
#define PTR_MASK ((0ull-1)<<3)
|
|
#endif
|
|
|
|
#line 33 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
void
|
|
runtime_lfstackpush ( uint64 *head , LFNode *node )
|
|
{
|
|
uint64 old , new;
|
|
#line 38 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
if ( ( uintptr ) node != ( ( uintptr ) node&PTR_MASK ) ) {
|
|
runtime_printf ( "p=%p\n" , node ) ;
|
|
runtime_throw ( "runtime_lfstackpush: invalid pointer" ) ;
|
|
}
|
|
#line 43 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
node->pushcnt++;
|
|
new = ( uint64 ) ( uintptr ) node| ( ( ( uint64 ) node->pushcnt&CNT_MASK ) <<PTR_BITS ) ;
|
|
for ( ;; ) {
|
|
old = runtime_atomicload64 ( head ) ;
|
|
node->next = ( LFNode* ) ( uintptr ) ( old&PTR_MASK ) ;
|
|
if ( runtime_cas64 ( head , old , new ) )
|
|
break;
|
|
}
|
|
}
|
|
#line 53 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
LFNode*
|
|
runtime_lfstackpop ( uint64 *head )
|
|
{
|
|
LFNode *node , *node2;
|
|
uint64 old , new;
|
|
#line 59 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
for ( ;; ) {
|
|
old = runtime_atomicload64 ( head ) ;
|
|
if ( old == 0 )
|
|
return nil;
|
|
node = ( LFNode* ) ( uintptr ) ( old&PTR_MASK ) ;
|
|
node2 = runtime_atomicloadp ( &node->next ) ;
|
|
new = 0;
|
|
if ( node2 != nil )
|
|
new = ( uint64 ) ( uintptr ) node2| ( ( ( uint64 ) node2->pushcnt&CNT_MASK ) <<PTR_BITS ) ;
|
|
if ( runtime_cas64 ( head , old , new ) )
|
|
return node;
|
|
}
|
|
}
|
|
void runtime_lfstackpush_go(uint64* head, LFNode* node) __asm__ (GOSYM_PREFIX "runtime.lfstackpush_go");
|
|
void runtime_lfstackpush_go(uint64* head, LFNode* node)
|
|
{
|
|
#line 73 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
|
|
runtime_lfstackpush(head, node);
|
|
}
|
|
LFNode* runtime_lfstackpop_go(uint64* head) __asm__ (GOSYM_PREFIX "runtime.lfstackpop_go");
|
|
LFNode* runtime_lfstackpop_go(uint64* head)
|
|
{
|
|
LFNode* node;
|
|
#line 77 "../../../trunk/libgo/runtime/../../../trunk/libgo/runtime/lfstack.goc"
|
|
|
|
node = runtime_lfstackpop(head);
|
|
return node;
|
|
}
|