當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.__u64函數代碼示例

本文整理匯總了Golang中C.__u64函數的典型用法代碼示例。如果您正苦於以下問題:Golang __u64函數的具體用法?Golang __u64怎麽用?Golang __u64使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了__u64函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SetFpuState

func (vcpu *Vcpu) SetFpuState(state Fpu) error {

	// Prepare our data.
	var kvm_fpu C.struct_kvm_fpu
	for i := 0; i < len(state.FPR); i += 1 {
		for j := 0; j < len(state.FPR[i]); j += 1 {
			kvm_fpu.fpr[i][j] = C.__u8(state.FPR[i][j])
		}
	}
	kvm_fpu.fcw = C.__u16(state.FCW)
	kvm_fpu.fsw = C.__u16(state.FSW)
	kvm_fpu.ftwx = C.__u8(state.FTWX)
	kvm_fpu.last_opcode = C.__u16(state.LastOpcode)
	kvm_fpu.last_ip = C.__u64(state.LastIp)
	kvm_fpu.last_dp = C.__u64(state.LastDp)
	for i := 0; i < len(state.XMM); i += 1 {
		for j := 0; j < len(state.XMM[i]); j += 1 {
			kvm_fpu.xmm[i][j] = C.__u8(state.XMM[i][j])
		}
	}
	kvm_fpu.mxcsr = C.__u32(state.MXCSR)

	// Execute the ioctl.
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vcpu.fd),
		uintptr(C.IoctlSetFpu),
		uintptr(unsafe.Pointer(&kvm_fpu)))
	if e != 0 {
		return e
	}

	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:34,代碼來源:kvm_fpu.go

示例2: MapUserMemory

func (vm *Vm) MapUserMemory(
	start Paddr,
	size uint64,
	mmap []byte) error {

	// See NOTE above about read-only memory.
	// As we will not support it for the moment,
	// we do not expose it through the interface.
	// Leveraging that feature will likely require
	// a small amount of re-architecting in any case.
	var region C.struct_kvm_userspace_memory_region
	region.slot = C.__u32(vm.mem_region)
	region.flags = C.__u32(0)
	region.guest_phys_addr = C.__u64(start)
	region.memory_size = C.__u64(size)
	region.userspace_addr = C.__u64(uintptr(unsafe.Pointer(&mmap[0])))

	// Execute the ioctl.
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vm.fd),
		uintptr(C.IoctlSetUserMemoryRegion),
		uintptr(unsafe.Pointer(&region)))
	if e != 0 {
		return e
	}

	// We're set, bump our slot.
	vm.mem_region += 1
	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:31,代碼來源:kvm_memory.go

示例3: SetDescriptor

func (vcpu *Vcpu) SetDescriptor(
	desc Descriptor,
	val DescriptorValue,
	sync bool) error {

	err := vcpu.refreshSRegs(true)
	if err != nil {
		return err
	}

	switch desc {
	case GDT:
		vcpu.sregs.gdt.base = C.__u64(val.Base)
		vcpu.sregs.gdt.limit = C.__u16(val.Limit)
	case IDT:
		vcpu.sregs.idt.base = C.__u64(val.Base)
		vcpu.sregs.idt.limit = C.__u16(val.Limit)
	default:
		return UnknownRegister
	}

	if sync {
		err = vcpu.flushSRegs()
		if err != nil {
			return err
		}
	}

	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:30,代碼來源:kvm_x86.go

示例4: ffiPropertySetReadonly

func ffiPropertySetReadonly(path string, readOnly bool) error {
	var flags C.__u64
	if readOnly {
		flags |= C.__u64(C.BTRFS_SUBVOL_RDONLY)
	} else {
		flags = flags &^ C.__u64(C.BTRFS_SUBVOL_RDONLY)
	}
	return ffiIoctl(path, C.BTRFS_IOC_SUBVOL_SETFLAGS, uintptr(unsafe.Pointer(&flags)))
}
開發者ID:plar,項目名稱:pachyderm,代碼行數:9,代碼來源:ffi.go

示例5: C

func (ila *inodeLookupArgs) C() C.struct_btrfs_ioctl_ino_lookup_args {
	var args C.struct_btrfs_ioctl_ino_lookup_args
	args.objectid = C.__u64(ila.ObjectID)
	args.treeid = C.__u64(ila.TreeID)
	if ila.Name != "" {
		str := [C.BTRFS_INO_LOOKUP_PATH_MAX]C.char{}
		for i := 0; i < len(ila.Name) && i < C.BTRFS_INO_LOOKUP_PATH_MAX; i++ {
			str[i] = C.char(ila.Name[i])
		}
		args.name = str
	}
	return args
}
開發者ID:kissthink,項目名稱:go-btrfs,代碼行數:13,代碼來源:lookup.go

示例6: SetAttr

// sched_setattr(2)
func SetAttr(pid int, attr SchedAttr) error {
	cAttr := C.struct_sched_attr{
		C.__u32(C.SCHED_ATTR_SIZE),
		C.__u32(attr.Policy),
		C.__u64(attr.Flags),
		C.__s32(attr.Nice),
		C.__u32(attr.Priority),
		C.__u64(attr.Runtime.Nanoseconds()),
		C.__u64(attr.Deadline.Nanoseconds()),
		C.__u64(attr.Period.Nanoseconds()),
	}
	_, err := C.sched_setattr(C.pid_t(pid), &cAttr, C.uint(0))
	return err
}
開發者ID:AkihiroSuda,項目名稱:go-linuxsched,代碼行數:15,代碼來源:linuxsched.go

示例7: huurr

func huurr(dirpath string) ([]string, error) {
	inoArgs, err := inodeLookup(dirpath)
	if err != nil {
		return nil, err
	}

	var searchKey C.struct_btrfs_ioctl_search_key
	searchKey.min_objectid = C.__u64(inoArgs.TreeID)
	searchKey.max_objectid = C.__u64(inoArgs.TreeID)
	searchKey.min_type = C.BTRFS_ROOT_ITEM_KEY
	searchKey.max_type = C.BTRFS_ROOT_ITEM_KEY
	searchKey.max_offset = (1<<48 - 1)
	searchKey.max_transid = (1<<48 - 1)

	return nil, nil
}
開發者ID:kissthink,項目名稱:go-btrfs,代碼行數:16,代碼來源:lookup.go

示例8: SetEventFd

func (vm *Vm) SetEventFd(
	eventfd *EventFd,
	paddr Paddr,
	size uint,
	is_pio bool,
	unbind bool,
	has_value bool,
	value uint64) error {

	var ioeventfd C.struct_kvm_ioeventfd
	ioeventfd.addr = C.__u64(paddr)
	ioeventfd.len = C.__u32(size)
	ioeventfd.fd = C.__s32(eventfd.Fd())
	ioeventfd.datamatch = C.__u64(value)

	if is_pio {
		ioeventfd.flags |= C.__u32(C.IoctlIoEventFdFlagPio)
	}
	if unbind {
		ioeventfd.flags |= C.__u32(C.IoctlIoEventFdFlagDeassign)
	}
	if has_value {
		ioeventfd.flags |= C.__u32(C.IoctlIoEventFdFlagDatamatch)
	}

	// Bind / unbind the eventfd.
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vm.fd),
		uintptr(C.IoctlIoEventFd),
		uintptr(unsafe.Pointer(&ioeventfd)))
	if e != 0 {
		return e
	}

	// Success.
	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:38,代碼來源:kvm_eventfd.go

示例9: ffiSubvolumeSnapshot

func ffiSubvolumeSnapshot(src string, dest string, readOnly bool) error {
	srcDir, err := ffiOpenDir(src)
	if err != nil {
		return err
	}
	defer ffiCloseDir(srcDir)
	var args C.struct_btrfs_ioctl_vol_args_v2
	args.fd = C.__s64(ffiGetDirFd(srcDir))
	if readOnly {
		args.flags |= C.__u64(C.BTRFS_SUBVOL_RDONLY)
	}
	for i, c := range []byte(filepath.Base(dest)) {
		args.name[i] = C.char(c)
	}
	return ffiIoctl(filepath.Dir(dest), C.BTRFS_IOC_SNAP_CREATE_V2, uintptr(unsafe.Pointer(&args)))
}
開發者ID:plar,項目名稱:pachyderm,代碼行數:16,代碼來源:ffi.go

示例10: SetClock

func (vm *Vm) SetClock(clock Clock) error {

	// Execute the ioctl.
	var kvm_clock_data C.struct_kvm_clock_data
	kvm_clock_data.clock = C.__u64(clock.Time)
	kvm_clock_data.flags = C.__u32(clock.Flags)
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vm.fd),
		uintptr(C.IoctlSetClock),
		uintptr(unsafe.Pointer(&kvm_clock_data)))
	if e != 0 {
		return e
	}

	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:17,代碼來源:kvm_clock.go

示例11: subvolLimitQgroup

func subvolLimitQgroup(path string, size uint64) error {
	dir, err := openDir(path)
	if err != nil {
		return err
	}
	defer closeDir(dir)

	var args C.struct_btrfs_ioctl_qgroup_limit_args
	args.lim.max_referenced = C.__u64(size)
	args.lim.flags = C.BTRFS_QGROUP_LIMIT_MAX_RFER
	_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QGROUP_LIMIT,
		uintptr(unsafe.Pointer(&args)))
	if errno != 0 {
		return fmt.Errorf("Failed to limit qgroup for %s: %v", dir, errno.Error())
	}

	return nil
}
開發者ID:harche,項目名稱:docker,代碼行數:18,代碼來源:btrfs.go

示例12: MapSpecialMemory

func (vm *Vm) MapSpecialMemory(addr Paddr) error {

	// We require 1 page for the identity map.
	err := vm.MapReservedMemory(addr, PageSize)
	if err != nil {
		return err
	}

	// Set the EPT identity map.
	// (This requires a single page).
	ept_identity_addr := C.__u64(addr)
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vm.fd),
		uintptr(C.IoctlSetIdentityMapAddr),
		uintptr(unsafe.Pointer(&ept_identity_addr)))
	if e != 0 {
		log.Printf("Unable to set identity map to %08x!", addr)
		return e
	}

	// We require 3 pages for the TSS address.
	err = vm.MapReservedMemory(addr+PageSize, 3*PageSize)
	if err != nil {
		return err
	}

	// Set the TSS address to above.
	// (This requires three pages).
	_, _, e = syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vm.fd),
		uintptr(C.IoctlSetTssAddr),
		uintptr(addr+PageSize))
	if e != 0 {
		log.Printf("Unable to set TSS ADDR to %08x!", addr+PageSize)
		return e
	}

	// We're okay.
	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:42,代碼來源:kvm_x86.go

示例13: SetMsr

func (vcpu *Vcpu) SetMsr(index uint32, value uint64) error {

	// Setup our structure.
	data := make([]byte, C.msr_size(), C.msr_size())

	// Set our index and value.
	C.msr_set(unsafe.Pointer(&data[0]), C.__u32(index), C.__u64(value))

	// Execute our ioctl.
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vcpu.fd),
		uintptr(C.IoctlSetMsrs),
		uintptr(unsafe.Pointer(&data[0])))
	if e != 0 {
		return e
	}

	return nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:20,代碼來源:kvm_msrs.go

示例14: GetMsr

func (vcpu *Vcpu) GetMsr(index uint32) (uint64, error) {

	// Setup our structure.
	data := make([]byte, C.msr_size(), C.msr_size())

	// Set our index to retrieve.
	C.msr_set(unsafe.Pointer(&data[0]), C.__u32(index), C.__u64(0))

	// Execute our ioctl.
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vcpu.fd),
		uintptr(C.IoctlGetMsrs),
		uintptr(unsafe.Pointer(&data[0])))
	if e != 0 {
		return 0, e
	}

	// Return our value.
	return uint64(C.msr_get(unsafe.Pointer(&data[0]))), nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:21,代碼來源:kvm_msrs.go

示例15: Translate

func (vcpu *Vcpu) Translate(
	vaddr Vaddr) (Paddr, bool, bool, bool, error) {

	// Perform the translation.
	var translation C.struct_kvm_translation
	translation.linear_address = C.__u64(vaddr)
	_, _, e := syscall.Syscall(
		syscall.SYS_IOCTL,
		uintptr(vcpu.fd),
		uintptr(C.IoctlTranslate),
		uintptr(unsafe.Pointer(&translation)))
	if e != 0 {
		return Paddr(0), false, false, false, e
	}

	paddr := Paddr(translation.physical_address)
	valid := translation.valid != C.__u8(0)
	writeable := translation.writeable != C.__u8(0)
	usermode := translation.valid != C.__u8(0)

	return paddr, valid, writeable, usermode, nil
}
開發者ID:XenServerBestPractice,項目名稱:novm,代碼行數:22,代碼來源:kvm_memory.go


注:本文中的C.__u64函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。