Example #1
0
        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);
        }
Example #2
0
        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;
            }
        }
Example #3
0
File: exec.cs Project: zjmit/go2cs
        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 !);
        }
Example #4
0
        ; // 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);
Example #5
0
 private static void _()
 {
     unsafe.Pointer x = default;
     System.UIntPtr y = default;
     x = @unsafe.Pointer(y); // ERROR "possible misuse of unsafe.Pointer"
     _ = x;
 }
Example #6
0
 private static void archauxv(System.UIntPtr tag, System.UIntPtr val)
 {
     if (tag == _AT_HWCAP)
     {
         cpu.HWCap = uint(val);
     }
 }
Example #7
0
        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);
            }
        }
Example #8
0
 private void Stop(System.UIntPtr hive)
 {
     if (UnsafeNativeMethods.RegOverridePredefKey(hive, System.IntPtr.Zero) != 0)
     {
         throw new Win32Exception();
     }
 }
Example #9
0
        // 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);
        }
Example #10
0
                        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;
                        }
Example #11
0
 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);
Example #12
0
                            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));
                            }
Example #13
0
        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);
        }
Example #14
0
        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);
        }
Example #15
0
                            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));
                            }
Example #16
0
        // 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[..]);
Example #17
0
 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");
     }
 }
Example #18
0
File: gccgo.cs Project: zjmit/go2cs
                            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);
                            }
Example #19
0
File: gccgo.cs Project: zjmit/go2cs
                            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));
                            }
Example #20
0
        } // 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);
        }
Example #21
0
File: gccgo.cs Project: zjmit/go2cs
                            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);
                            }
Example #22
0
File: gccgo.cs Project: zjmit/go2cs
                            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));
                            }
Example #23
0
        // 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);
Example #24
0
        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);
        }
Example #25
0
        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>());
        }
Example #26
0
        //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);
            }
        }
Example #27
0
File: math.cs Project: zjmit/go2cs
                // 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);
                }
Example #28
0
 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);
     }
 }
Example #29
0
        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;
Example #30
0
 // 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));
 }