Beispiel #1
0
        /// <summary>
        /// Get the <see cref="CopyDelegate"/> defined by hosting system, if possible.
        /// </summary>
        /// <returns></returns>
        private static CopyDelegate GetPlatformMemcpy()
        {
            IntPtr memoryCopyPtr;

            switch (Platform.CurrentPlatformId)
            {
            case Platform.Id.WindowsNT:
                memoryCopyPtr = GetProcAddressOS.GetProcAddress("msvcrt.dll", "memcpy");
                if (memoryCopyPtr != IntPtr.Zero)
                {
                    return((CopyDelegate)Marshal.GetDelegateForFunctionPointer(memoryCopyPtr, typeof(CopyDelegate)));
                }
                return(null);

            case Platform.Id.Linux:
                memoryCopyPtr = GetProcAddressOS.GetProcAddress("libc.so.6", "memcpy");
                if (memoryCopyPtr != IntPtr.Zero)
                {
                    return((CopyDelegate)Marshal.GetDelegateForFunctionPointer(memoryCopyPtr, typeof(CopyDelegate)));
                }
                return(null);

            default:
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Ensure <see cref="MemoryCopy"/> functionality.
        /// </summary>
        private static void EnsureMemoryCopy()
        {
            if (MemoryCopyPointer == null)
            {
                IntPtr memoryCopyPtr;

                switch (Platform.CurrentPlatformId)
                {
                case Platform.Id.WindowsNT:
                    memoryCopyPtr = GetProcAddressOS.GetProcAddress("msvcrt.dll", "memcpy");
                    if (memoryCopyPtr != IntPtr.Zero)
                    {
                        MemoryCopyPointer = (MemoryCopyDelegate)Marshal.GetDelegateForFunctionPointer(memoryCopyPtr, typeof(MemoryCopyDelegate));
                        return;
                    }

                    throw new NotSupportedException("no suitable memcpy support");

                case Platform.Id.Linux:
                    memoryCopyPtr = GetProcAddressOS.GetProcAddress("libc.so.6", "memcpy");
                    if (memoryCopyPtr != IntPtr.Zero)
                    {
                        MemoryCopyPointer = (MemoryCopyDelegate)Marshal.GetDelegateForFunctionPointer(memoryCopyPtr, typeof(MemoryCopyDelegate));
                        return;
                    }

                    throw new NotSupportedException("no suitable memcpy support");

                default:
                    throw new NotSupportedException("no suitable memcpy support");
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static GetGLProcAddressGLX()
        {
            IntPtr functionPtr = GetProcAddressOS.GetProcAddress(Library, "glXGetProcAddress");

            if (functionPtr != IntPtr.Zero)
            {
                Delegates.pglXGetProcAddress = (Delegates.glXGetProcAddress)Marshal.GetDelegateForFunctionPointer(functionPtr, typeof(Delegates.glXGetProcAddress));
            }
        }