本文整理匯總了Golang中C.longlong函數的典型用法代碼示例。如果您正苦於以下問題:Golang longlong函數的具體用法?Golang longlong怎麽用?Golang longlong使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了longlong函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getOffsetByUSec
func getOffsetByUSec(zone string, timestamp int64) int32 {
czone := C.CString(zone)
defer C.free(unsafe.Pointer(czone))
offset := C.get_offset_by_usec(czone, C.longlong(timestamp))
return int32(offset)
}
示例2: main
func main() {
xs := make([]int64, 4096)
for i := 0; i < len(xs); i++ {
xs[i] = int64(rand.Int())
}
fmt.Println(C.sum((*C.longlong)(unsafe.Pointer(&xs[0])), C.longlong(len(xs))))
}
示例3: getRawUSec
func getRawUSec(zone string, timestamp int64) int64 {
czone := C.CString(zone)
defer C.free(unsafe.Pointer(czone))
ret := C.get_rawoffset_usec(czone, C.longlong(timestamp))
return int64(ret)
}
示例4: BytesWritten
func (ptr *QWebSocket) BytesWritten(bytes int64) {
defer qt.Recovering("QWebSocket::bytesWritten")
if ptr.Pointer() != nil {
C.QWebSocket_BytesWritten(ptr.Pointer(), C.longlong(bytes))
}
}
示例5: SetReadBufferSize
func (ptr *QWebSocket) SetReadBufferSize(size int64) {
defer qt.Recovering("QWebSocket::setReadBufferSize")
if ptr.Pointer() != nil {
C.QWebSocket_SetReadBufferSize(ptr.Pointer(), C.longlong(size))
}
}
示例6: ReadAt
func ReadAt(fd int, off int64, size int) ([]byte, error) {
idx := <-idle_event
retch := aio_result_map[idx]
defer func() { idle_event <- idx }()
var cb *C.struct_iocb = &cbs[idx]
var read_buf unsafe.Pointer
C.posix_memalign(&read_buf, pagesize, C.size_t(size))
defer C.free(read_buf)
C.io_prep_pread(cb, C.int(fd), read_buf, C.size_t(size), C.longlong(off))
cbs[idx].data = unsafe.Pointer(&idx)
aio_lock.Lock()
rt := C.io_submit(ctx, 1, &cb)
if int(rt) < 0 {
aio_lock.Unlock()
return nil, errors.New("io submit failed")
}
aiocount++
aio_lock.Unlock()
select {
case have_aio_event <- 0:
default:
}
ret := <-retch
return ret.buf, ret.err
}
示例7: PushGoValue
func (lua *Lua) PushGoValue(value reflect.Value) {
switch t := value.Type(); t.Kind() {
case reflect.Bool:
if value.Bool() {
C.lua_pushboolean(lua.State, C.int(1))
} else {
C.lua_pushboolean(lua.State, C.int(0))
}
case reflect.String:
C.lua_pushstring(lua.State, C.CString(value.String()))
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
C.lua_pushnumber(lua.State, C.lua_Number(C.longlong(value.Int())))
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
C.lua_pushnumber(lua.State, C.lua_Number(C.ulonglong(value.Uint())))
case reflect.Float32, reflect.Float64:
C.lua_pushnumber(lua.State, C.lua_Number(C.double(value.Float())))
case reflect.Slice:
length := value.Len()
C.lua_createtable(lua.State, C.int(length), 0)
for i := 0; i < length; i++ {
C.lua_pushnumber(lua.State, C.lua_Number(i+1))
lua.PushGoValue(value.Index(i))
C.lua_settable(lua.State, -3)
}
case reflect.Interface:
lua.PushGoValue(value.Elem())
case reflect.Ptr, reflect.UnsafePointer:
C.lua_pushlightuserdata(lua.State, unsafe.Pointer(value.Pointer()))
default:
lua.Panic("wrong return value %v %v", value, t.Kind())
}
}
示例8: SetNum
// SetNum sets a number in the specified field of the engine configuration.
// Certain fields accept only 32-bit numbers, silently truncating the higher bits
// of the engine config. See dat.go for more information.
func (e *Engine) SetNum(field EngineField, num uint64) error {
err := C.cl_engine_set_num((*C.struct_cl_engine)(e), C.enum_cl_engine_field(field), C.longlong(num))
if ErrorCode(err) != Success {
return fmt.Errorf("%v", StrError(ErrorCode(err)))
}
return nil
}
示例9: cTraceRays
func cTraceRays(computator CComputationManager, startIndex, endIndex int64) [][]float32 {
indicesSize := endIndex - startIndex + 1
results := make([][]float32, indicesSize)
refResults := make([]*float32, indicesSize)
for i := range results {
data := make([]float32, 3)
results[i] = data
refResults[i] = (*float32)(unsafe.Pointer(&data[0]))
}
resultsPtr := (**C.float)(unsafe.Pointer((&refResults[0])))
C.traceRays(computator.p, C.longlong(startIndex), C.longlong(endIndex), resultsPtr)
return results
}
示例10: GetEyePoses
/// Returns the predicted head pose in outHmdTrackingState and offset eye poses in outEyePoses.
///
/// This is a thread-safe function where caller should increment frameIndex with every frame
/// and pass that index where applicable to functions called on the rendering thread.
/// Assuming outEyePoses are used for rendering, it should be passed as a part of ovrLayerEyeFov.
/// The caller does not need to worry about applying HmdToEyeOffset to the returned outEyePoses variables.
///
/// \param[in] hmd Specifies an ovrSession previously returned by ovr_Create.
/// \param[in] frameIndex Specifies the targeted frame index, or 0 to refer to one frame after
/// the last time ovr_SubmitFrame was called.
/// \param[in] HmdToEyeOffset Can be ovrEyeRenderDesc.HmdToEyeOffset returned from
/// ovr_GetRenderDesc. For monoscopic rendering, use a vector that is the average
/// of the two vectors for both eyes.
/// \param[in] latencyMarker Specifies that this call is the point in time where
/// the "App-to-Mid-Photon" latency timer starts from. If a given ovrLayer
/// provides "SensorSampleTimestamp", that will override the value stored here.
/// \param[out] outEyePoses The predicted eye poses.
/// \param[out] outSensorSampleTime The time when this function was called. May be NULL, in which case it is ignored.
func (s *Session) GetEyePoses(frameIndex uint64, latencyMarker bool, hmdToEyeOffset [2]Vector3f) ([2]Posef, float64) {
var cHmdToEyeViewOffset [2]C.ovrVector3f
cHmdToEyeViewOffset[0] = cVector3f(hmdToEyeOffset[0])
cHmdToEyeViewOffset[1] = cVector3f(hmdToEyeOffset[1])
var cEyePoses [2]C.ovrPosef
var cSensorSampleTime C.double
C.ovr_GetEyePoses(s.cSession, C.longlong(frameIndex), ovrBool(latencyMarker), &cHmdToEyeViewOffset[0], &cEyePoses[0], &cSensorSampleTime)
return [2]Posef{goPosef(cEyePoses[0]), goPosef(cEyePoses[1])}, float64(cSensorSampleTime)
}
示例11: x_GoReader_Seek
//export x_GoReader_Seek
func x_GoReader_Seek(pGoReader C.GoReaderPtr, offset int64, whence int) C.longlong {
reader := (*(*io.Reader)(pGoReader))
seeker := reader.(io.Seeker)
n, err := seeker.Seek(offset, whence)
if err != nil {
return -1
}
return C.longlong(n)
}
示例12: TypedParamsAddInt64
func (t *TypedParameters) TypedParamsAddInt64(val int64, name string) error {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
result := C.virTypedParamsAddLLong(&t.cptr, &t.length, &t.capacity, cname, C.longlong(val))
if result == -1 {
return GetLastError()
}
return nil
}
示例13: Read
func (sch *aioScheduler) Read(fd int, buf []byte, off uint64) (int, error) {
iocb := &C.iocb_t{}
sh := *(*reflect.SliceHeader)(unsafe.Pointer(&buf))
C.io_prep_pread(iocb, C.int(fd), unsafe.Pointer(sh.Data), C.size_t(sh.Len), C.longlong(off))
ev, err := sch.submit(iocb)
if err != nil {
return 0, err
}
return int(ev.wait()), nil
}
示例14: unpack_kv
func unpack_kv(pack *C.struct___0, v reflect.Value) *McpackError {
vt := v.Type()
for i := 0; i < v.NumField(); i++ {
vtf := vt.Field(i)
vf := v.Field(i)
realName := vtf.Tag.Get("mcpack")
if realName == "" {
realName = vtf.Name
}
switch vf.Kind() {
case reflect.Struct:
subpack := C.mc_pack_get_object(pack, C.CString(realName))
if err := unpack_kv(subpack, vf); err != nil {
return err
}
case reflect.Interface:
subpack := C.mc_pack_get_object(pack, C.CString(realName))
evf := vf.Elem().Elem()
if err := unpack_kv(subpack, evf); err != nil {
return err
}
case reflect.String:
value_c := C.mc_pack_get_str(pack, C.CString(realName))
vf.SetString(C.GoString(value_c))
case reflect.Int, reflect.Int32:
value_i := C.int(0)
C.go_mc_pack_get_int32(pack, C.CString(realName), &value_i)
vf.SetInt(int64(value_i))
case reflect.Int64:
value_i := C.longlong(0)
C.go_mc_pack_get_int64(pack, C.CString(realName), &value_i)
vf.SetInt(int64(value_i))
case reflect.Slice, reflect.Array:
if vf.Type().Elem().Kind() != reflect.Uint8 {
return &McpackError{"unspport slice type"}
}
value_len := C.int(0)
value_r := C.go_mc_pack_get_raw(pack, C.CString(realName), &value_len)
vf.SetBytes(C.GoBytes(unsafe.Pointer(value_r), value_len))
default:
return &McpackError{"unsupport type: " + v.Kind().String()}
}
}
return nil
}
示例15: SendProcessSignal
// SendProcessSignal sends a signal to the designated process in the guest.
func (dom Domain) SendProcessSignal(pid int64, signal DomainProcessSignal) error {
dom.log.Printf("sending signal %v to domain's process %v...\n", signal, pid)
cRet := C.virDomainSendProcessSignal(dom.virDomain, C.longlong(pid), C.uint(signal), 0)
ret := int32(cRet)
if ret == -1 {
err := LastError()
dom.log.Printf("an error occurred: %v\n", err)
return err
}
dom.log.Println("signal sent")
return nil
}