internal static bool IsDefined(Enumeration enumeration, uint value) { System.UIntPtr length = System.UIntPtr.Zero; Status status = Library.yepLibrary_GetString(enumeration, value, StringType.Description, System.IntPtr.Zero, ref length); return(status == Status.InsufficientBuffer); }
private static readonly long _HWCAP_S390_VX = (long)2048L; // vector facility private static void archauxv(System.UIntPtr tag, System.UIntPtr val) { if (tag == _AT_HWCAP) // CPU capability bit flags { cpu.S390X.HasVX = val & _HWCAP_S390_VX != 0L; } }
private static ptr <Process> newProcess(long pid, System.UIntPtr handle) { ptr <Process> p = addr(new Process(Pid: pid, handle: handle)); runtime.SetFinalizer(p, ptr <Process>); return(_addr_p !); }
; // declared for vet; do NOT call // Many of these are exported via linkname to assembly in the syscall // package. //go:nosplit //go:linkname syscall_sysvicall6 private static (System.UIntPtr, System.UIntPtr, System.UIntPtr) syscall_sysvicall6(System.UIntPtr fn, System.UIntPtr nargs, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3, System.UIntPtr a4, System.UIntPtr a5, System.UIntPtr a6) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; System.UIntPtr err = default; ref libcall call = ref heap(new libcall(fn: fn, n: nargs, args: uintptr(unsafe.Pointer(&a1)), ), out ptr <libcall> _addr_call);
private static void _() { unsafe.Pointer x = default; System.UIntPtr y = default; x = @unsafe.Pointer(y); // ERROR "possible misuse of unsafe.Pointer" _ = x; }
private static void archauxv(System.UIntPtr tag, System.UIntPtr val) { if (tag == _AT_HWCAP) { cpu.HWCap = uint(val); } }
internal static string GetString(Enumeration enumeration, uint value, StringType stringType) { System.UIntPtr length = System.UIntPtr.Zero; Status status = Library.yepLibrary_GetString(enumeration, value, stringType, System.IntPtr.Zero, ref length); if (status != Status.InsufficientBuffer) { throw new System.SystemException(); } int smallLength = checked ((int)length); System.IntPtr unmanagedBuffer = Marshal.AllocHGlobal(smallLength); try { status = yepLibrary_GetString(enumeration, value, stringType, unmanagedBuffer, ref length); if (status != Status.Ok) { throw new System.SystemException(); } byte[] managedBuffer = new byte[smallLength]; Marshal.Copy(unmanagedBuffer, managedBuffer, 0, smallLength); return(System.Text.Encoding.UTF8.GetString(managedBuffer)); } finally { Marshal.FreeHGlobal(unmanagedBuffer); } }
private void Stop(System.UIntPtr hive) { if (UnsafeNativeMethods.RegOverridePredefKey(hive, System.IntPtr.Zero) != 0) { throw new Win32Exception(); } }
// In syscall_syscall6 and syscall_rawsyscall6, r2 is always 0 // as it's never used on AIX // TODO: remove r2 from zsyscall_aix_$GOARCH.go // Syscall is needed because some packages (like net) need it too. // The best way is to return EINVAL and let Golang handles its failure // If the syscall can't fail, this function can redirect it to a real syscall. // // This is exported via linkname to assembly in the syscall package. // //go:nosplit //go:linkname syscall_Syscall private static (System.UIntPtr, System.UIntPtr, System.UIntPtr) syscall_Syscall(System.UIntPtr fn, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; System.UIntPtr err = default; return(0L, 0L, _EINVAL); }
private static (System.UIntPtr, errno) callgetsystemcfg(long label) { System.UIntPtr r1 = default; errno e1 = default; r1, _, e1 = syscall6(uintptr(@unsafe.Pointer(_addr_libc_getsystemcfg)), 1L, uintptr(label), 0L, 0L, 0L, 0L, 0L); return; }
public static extern XImage *XGetImage2( [NativeTypeName("Display *")] System.IntPtr display , [NativeTypeName("Drawable")] System.UIntPtr d , int x, int y , [NativeTypeName("unsigned int")] uint width , [NativeTypeName("unsigned int")] uint height , [NativeTypeName("unsigned long")] System.UIntPtr plane_mask , int format);
public static (System.UIntPtr, System.UIntPtr, syscall.Errno) RawSyscall6(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3, System.UIntPtr a4, System.UIntPtr a5, System.UIntPtr a6) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; syscall.Errno err = default; return(syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6)); }
public static (System.UIntPtr, System.UIntPtr, Errno) Syscall(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; Errno err = default; return(0L, 0L, ENOSYS); }
public static (System.UIntPtr, System.UIntPtr, Errno) RawSyscall6(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3, System.UIntPtr a4, System.UIntPtr a5, System.UIntPtr a6) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; Errno err = default; return(0L, 0L, ENOSYS); }
public static (System.UIntPtr, System.UIntPtr, syscall.Errno) RawSyscall(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; syscall.Errno err = default; return(syscall.RawSyscall(trap, a1, a2, a3)); }
// Caller reports file and line number information about function invocations on // the calling goroutine's stack. The argument skip is the number of stack frames // to ascend, with 0 identifying the caller of Caller. (For historical reasons the // meaning of skip differs between Caller and Callers.) The return values report the // program counter, file name, and line number within the file of the corresponding // call. The boolean ok is false if it was not possible to recover the information. public static (System.UIntPtr, @string, long, bool) Caller(long skip) { System.UIntPtr pc = default; @string file = default; long line = default; bool ok = default; var rpc = make_slice <System.UIntPtr>(1L); var n = callers(skip + 1L, rpc[..]);
private static void netpollinit() { iocphandle = stdcall4(_CreateIoCompletionPort, _INVALID_HANDLE_VALUE, 0L, 0L, _DWORD_MAX); if (iocphandle == 0L) { println("runtime: CreateIoCompletionPort failed (errno=", getlasterror(), ")"); throw("runtime: netpollinit failed"); } }
public static (System.UIntPtr, System.UIntPtr) RawSyscallNoError(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; var r = realSyscallNoError(trap, a1, a2, a3, 0L, 0L, 0L, 0L, 0L, 0L); return(r, 0L); }
public static (System.UIntPtr, System.UIntPtr, syscall.Errno) RawSyscall(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; syscall.Errno err = default; var(r, errno) = realSyscall(trap, a1, a2, a3, 0L, 0L, 0L, 0L, 0L, 0L); return(r, 0L, syscall.Errno(errno)); }
} // End Sub PerformanceTest public static void TestX11_Simple() { System.IntPtr display = LibX11Functions.XOpenDisplay(System.IntPtr.Zero); int defaultScreen = LibX11Functions.XDefaultScreen(display); System.UIntPtr window = LibX11Functions.XRootWindow(display, defaultScreen); int screen_width = LibX11Functions.DisplayWidth(display, defaultScreen); int screen_height = LibX11Functions.DisplayHeight(display, defaultScreen); XWindowAttributes xa = new XWindowAttributes(); LibX11Functions.XGetWindowAttributes(display, window, ref xa); System.Console.WriteLine(xa.width); System.Console.WriteLine(xa.height); int AllPlanes = ~0; System.UIntPtr AllPlanes2 = new System.UIntPtr((uint)AllPlanes); /* * XImage* img = LibX11Functions.XGetImage2(display, window, 0, 0, (uint) xa.width, (uint)xa.height * , AllPlanes2, LinScreen.ZPixmap); */ // System.IntPtr image = LibX11Functions.XGetImage(display, window, 0, 0, (uint) xa.width, (uint)xa.height // , AllPlanes2, LinScreen.ZPixmap); SafeX11.SlowScreenshot(display, window, 0, 0, (uint)xa.width, (uint)xa.height , AllPlanes2, LinScreen.ZPixmap, true); // XImage img = System.Runtime.InteropServices.Marshal.PtrToStructure<XImage>(image); // System.Console.WriteLine(img.bitmap_bit_order); // System.Console.WriteLine(img.bits_per_pixel); // System.Console.WriteLine(img.width); // System.Console.WriteLine(img.height); // System.Console.WriteLine(img.data); // // // // // // // System.Console.WriteLine(img->bitmap_bit_order); // System.Console.WriteLine(img->width); // System.Console.WriteLine(img->height); // System.Console.WriteLine(img->data); // rtaNetworking.Linux.tt.foo(); // LibX11Functions.XDestroyImage2(img); LibX11Functions.XCloseDisplay(display); }
public static (System.UIntPtr, System.UIntPtr) SyscallNoError(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; syscall.Entersyscall(); var r = realSyscallNoError(trap, a1, a2, a3, 0L, 0L, 0L, 0L, 0L, 0L); syscall.Exitsyscall(); return(r, 0L); }
public static (System.UIntPtr, System.UIntPtr, syscall.Errno) Syscall9(System.UIntPtr trap, System.UIntPtr a1, System.UIntPtr a2, System.UIntPtr a3, System.UIntPtr a4, System.UIntPtr a5, System.UIntPtr a6, System.UIntPtr a7, System.UIntPtr a8, System.UIntPtr a9) { System.UIntPtr r1 = default; System.UIntPtr r2 = default; syscall.Errno err = default; syscall.Entersyscall(); var(r, errno) = realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); syscall.Exitsyscall(); return(r, 0L, syscall.Errno(errno)); }
// readInt returns the size-bytes unsigned integer in native byte order at offset off. private static (ulong, bool) readInt(slice <byte> b, System.UIntPtr off, System.UIntPtr size) { ulong u = default; bool ok = default; if (len(b) < int(off + size)) { return(0L, false); } if (isBigEndian) { return(readIntBE(b[off..], size), true);
public static byte[] SlowScreenshot( System.IntPtr display , System.UIntPtr d , int x, int y , uint width , uint height , System.UIntPtr plane_mask , int format, bool withCursor) { byte[] ret = SlowScreenshotWithCursor(display, d, x, y, width, height, plane_mask, format, withCursor); return(ret); }
internal static System.IntPtr AllocateMemoryFuncInternalImplementation(System.UIntPtr sizeInBytes, System.UIntPtr alignment) { AllocateMemoryFunc callback; if (Helper.TryGetStaticCallback("AllocateMemoryFuncInternalImplementation", out callback)) { var funcResult = callback(sizeInBytes, alignment); return(funcResult); } return(Helper.GetDefault <System.IntPtr>()); }
//export GoCheckM public static void GoCheckM() { var m = runtime_getm_for_test(); if (savedM == 0L) { savedM = m; } else if (savedM != m) { fmt.Printf("m == %x want %x\n", m, savedM); os.Exit(1L); } }
// MulUintptr returns a * b and whether the multiplication overflowed. // On supported platforms this is an intrinsic lowered by the compiler. // MulUintptr returns a * b and whether the multiplication overflowed. // On supported platforms this is an intrinsic lowered by the compiler. public static (System.UIntPtr, bool) MulUintptr(System.UIntPtr a, System.UIntPtr b) { System.UIntPtr _p0 = default; bool _p0 = default; if (a | b < 1L << (int)((4L * sys.PtrSize)) || a == 0L) { return(a * b, false); } var overflow = b > MaxUintptr / a; return(a * b, overflow); }
private static void archauxv(System.UIntPtr tag, System.UIntPtr val) { if (tag == _AT_HWCAP) { // ppc64x doesn't have a 'cpuid' instruction // equivalent and relies on HWCAP/HWCAP2 bits for // hardware capabilities. cpu.HWCap = uint(val); } else if (tag == _AT_HWCAP2) { cpu.HWCap2 = uint(val); } }
private static void archauxv(System.UIntPtr tag, System.UIntPtr val) { if (tag == _AT_HWCAP) { // arm64 doesn't have a 'cpuid' instruction equivalent and relies on // HWCAP/HWCAP2 bits for hardware capabilities. var hwcap = uint(val); } if (GOOS == "android") { // The Samsung S9+ kernel reports support for atomics, but not all cores // actually support them, resulting in SIGILL. See issue #28431. // TODO(elias.naur): Only disable the optimization on bad chipsets. const long hwcap_ATOMICS = (long)1L << (int)(8L); hwcap &= ~uint(hwcap_ATOMICS); } cpu.HWCap = hwcap;
// Returns size of the memory block that mallocgc will allocate if you ask for the size. private static System.UIntPtr roundupsize(System.UIntPtr size) { if (size < _MaxSmallSize) { if (size <= smallSizeMax - 8L) { return(uintptr(class_to_size[size_to_class8[divRoundUp(size, smallSizeDiv)]])); } else { return(uintptr(class_to_size[size_to_class128[divRoundUp(size - smallSizeMax, largeSizeDiv)]])); } } if (size + _PageSize < size) { return(size); } return(alignUp(size, _PageSize)); }