Source file src/runtime/export_windows_test.go

     1  // Copyright 2014 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.
     4  
     5  // Export guts for testing.
     6  
     7  package runtime
     8  
     9  import "unsafe"
    10  
    11  const MaxArgs = maxArgs
    12  
    13  var (
    14  	OsYield                 = osyield
    15  	TimeBeginPeriodRetValue = &timeBeginPeriodRetValue
    16  )
    17  
    18  func NumberOfProcessors() int32 {
    19  	var info systeminfo
    20  	stdcall1(_GetSystemInfo, uintptr(unsafe.Pointer(&info)))
    21  	return int32(info.dwnumberofprocessors)
    22  }
    23  
    24  type ContextStub struct {
    25  	context
    26  }
    27  
    28  func (c ContextStub) GetPC() uintptr {
    29  	return c.ip()
    30  }
    31  
    32  func NewContextStub() *ContextStub {
    33  	var ctx context
    34  	ctx.set_ip(getcallerpc())
    35  	ctx.set_sp(getcallersp())
    36  	fp := getfp()
    37  	// getfp is not implemented on windows/386 and windows/arm,
    38  	// in which case it returns 0.
    39  	if fp != 0 {
    40  		ctx.set_fp(*(*uintptr)(unsafe.Pointer(fp)))
    41  	}
    42  	return &ContextStub{ctx}
    43  }
    44  

View as plain text