예제 #1
0
파일: FMemory.cs 프로젝트: yimengfan/USharp
 /// <summary>
 /// Maps a named shared memory region into process address space (creates or opens it)
 /// </summary>
 /// <param name="name">unique name of the shared memory region (should not contain [back]slashes to remain cross-platform).</param>
 /// <param name="create">whether we're creating it or just opening existing (created by some other process).</param>
 /// <param name="accessMode">mode which we will be accessing it (use values from ESharedMemoryAccess)</param>
 /// <param name="size">size of the buffer (should be >0. Also, the real size is subject to platform limitations and may be increased to match page size)</param>
 /// <returns>pointer to FSharedMemoryRegion (or its descendants) if successful, NULL if not.</returns>
 public static FSharedMemoryRegion MapNamedSharedMemoryRegion(string name, bool create, ESharedMemoryAccess accessMode, IntPtr size)
 {
     using (FStringUnsafe nameUnsafe = new FStringUnsafe(name))
     {
         return(new FSharedMemoryRegion(Native_FMemory.MapNamedSharedMemoryRegion(ref nameUnsafe.Array, create, (uint)accessMode, size)));
     }
 }
예제 #2
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 /// <summary>
 /// Set up TLS caches on the current thread. These are the threads that we can trim.
 /// </summary>
 public static void SetupTLSCachesOnCurrentThread()
 {
     Native_FMemory.SetupTLSCachesOnCurrentThread();
 }
예제 #3
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Memzero(IntPtr dest, ulong count)
 {
     return(Native_FMemory.Memzero(dest, count));
 }
예제 #4
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Memmove(IntPtr dest, IntPtr src, ulong count)
 {
     return(Native_FMemory.Memmove(dest, src, count));
 }
예제 #5
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Memset(IntPtr dest, byte value, ulong count)
 {
     return(Native_FMemory.Memset(dest, value, count));
 }
예제 #6
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr GPURealloc(IntPtr original, ulong size, uint alignment = DEFAULT_ALIGNMENT)
 {
     return(Native_FMemory.GPURealloc(original, size, alignment));
 }
예제 #7
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 /// <summary>
 /// A helper function that will perform a series of random heap allocations to test
 /// the internal validity of the heap. Note, this function will "leak" memory, but another call
 /// will clean up previously allocated blocks before returning. This will help to A/B testing
 /// where you call it in a good state, do something to corrupt memory, then call this again
 /// and hopefully freeing some pointers will trigger a crash.
 /// </summary>
 public static void TestMemory()
 {
     Native_FMemory.TestMemory();
 }
예제 #8
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr SystemMalloc(ulong size)
 {
     return(Native_FMemory.SystemMalloc(size));
 }
예제 #9
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static void SystemFree(IntPtr ptr)
 {
     Native_FMemory.SystemFree(ptr);
 }
예제 #10
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static void Memswap(IntPtr ptr1, IntPtr ptr2, int size)
 {
     Native_FMemory.Memswap(ptr1, ptr2, (ulong)size);
 }
예제 #11
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static void Memswap(IntPtr ptr1, IntPtr ptr2, ulong size)
 {
     Native_FMemory.Memswap(ptr1, ptr2, size);
 }
예제 #12
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr StreamingMemcpy(IntPtr dest, IntPtr src, ulong count)
 {
     return(Native_FMemory.StreamingMemcpy(dest, src, count));
 }
예제 #13
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr BigBlockMemcpy(IntPtr dest, IntPtr src, ulong count)
 {
     return(Native_FMemory.BigBlockMemcpy(dest, src, count));
 }
예제 #14
0
파일: FMemory.cs 프로젝트: yimengfan/USharp
 /// <summary>
 /// Unmaps a name shared memory region
 /// </summary>
 /// <param name="memoryRegion">an object that encapsulates a shared memory region (will be destroyed even if function fails!)</param>
 /// <returns>true if successful</returns>
 public static bool UnmapNamedSharedMemoryRegion(FSharedMemoryRegion memoryRegion)
 {
     return(Native_FMemory.UnmapNamedSharedMemoryRegion(memoryRegion.Address));
 }
예제 #15
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 /// <summary>
 /// Clears the TLS caches on the current thread and disables any future caching.
 /// </summary>
 public static void ClearAndDisableTLSCachesOnCurrentThread()
 {
     Native_FMemory.ClearAndDisableTLSCachesOnCurrentThread();
 }
예제 #16
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Malloc(int count, uint alignment = DEFAULT_ALIGNMENT)
 {
     return(Native_FMemory.Malloc((ulong)count, alignment));
 }
예제 #17
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr GPUMalloc(ulong count, uint alignment = DEFAULT_ALIGNMENT)
 {
     return(Native_FMemory.GPUMalloc(count, alignment));
 }
예제 #18
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Realloc(IntPtr original, ulong count, uint alignment = DEFAULT_ALIGNMENT)
 {
     return(Native_FMemory.Realloc(original, count, alignment));
 }
예제 #19
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr GPUFree(IntPtr original)
 {
     return(Native_FMemory.GPUFree(original));
 }
예제 #20
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static void Free(IntPtr original)
 {
     Native_FMemory.Free(original);
 }
예제 #21
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 /// <summary>
 /// Called once main is started and we have -purgatorymallocproxy.
 /// This uses the purgatory malloc proxy to check if things are writing to stale pointers.
 /// </summary>
 public static void EnablePurgatoryTests()
 {
     Native_FMemory.EnablePurgatoryTests();
 }
예제 #22
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static ulong GetAllocSize(IntPtr original)
 {
     return(Native_FMemory.GetAllocSize(original));
 }
예제 #23
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static int Memcmp(IntPtr dest, IntPtr src, ulong count)
 {
     return(Native_FMemory.Memcmp(dest, src, count));
 }
예제 #24
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static ulong QuantizeSize(ulong count, uint alignment = DEFAULT_ALIGNMENT)
 {
     return(Native_FMemory.QuantizeSize(count, alignment));
 }
예제 #25
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Memzero(IntPtr dest, int count)
 {
     return(Native_FMemory.Memzero(dest, (ulong)count));
 }
예제 #26
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 /// <summary>
 /// Releases as much memory as possible. Must be called from the main thread.
 /// </summary>
 public static void Trim()
 {
     Native_FMemory.Trim();
 }
예제 #27
0
파일: FMemory.cs 프로젝트: iainmckay/USharp
 public static IntPtr Memcpy(IntPtr dest, IntPtr src, uint count)
 {
     return(Native_FMemory.Memcpy(dest, src, count));
 }
예제 #28
0
파일: FMemory.cs 프로젝트: yimengfan/USharp
 /// <summary>
 /// Changes the protection on a region of committed pages in the virtual address space.
 /// </summary>
 /// <param name="ptr">Address to the starting page of the region of pages whose access protection attributes are to be changed.</param>
 /// <param name="size">The size of the region whose access protection attributes are to be changed, in bytes.</param>
 /// <param name="canRead">Can the memory be read.</param>
 /// <param name="canWrite">Can the memory be written to.</param>
 /// <returns>True if the specified pages' protection mode was changed.</returns>
 public static bool PageProtect(IntPtr ptr, IntPtr size, bool canRead, bool canWrite)
 {
     return(Native_FMemory.PageProtect(ptr, size, canRead, canWrite));
 }