Recreate base64 project
This commit is contained in:
		
							
								
								
									
										37
									
								
								wapp/core/os/mem/win/mem_os_win.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								wapp/core/os/mem/win/mem_os_win.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
// vim:fileencoding=utf-8:foldmethod=marker
 | 
			
		||||
 | 
			
		||||
#include "../../../../common/aliases/aliases.h"
 | 
			
		||||
#include "../../../../common/platform/platform.h"
 | 
			
		||||
 | 
			
		||||
#ifdef WAPP_PLATFORM_WINDOWS
 | 
			
		||||
 | 
			
		||||
#include "mem_os_win.h"
 | 
			
		||||
#include "../mem_os_ops.h"
 | 
			
		||||
 | 
			
		||||
#define WIN32_LEAN_AND_MEAN
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
#include <memoryapi.h>
 | 
			
		||||
 | 
			
		||||
internal const i32 access_types[] = {
 | 
			
		||||
    [WAPP_MEM_ACCESS_NONE]            = PAGE_NOACCESS,
 | 
			
		||||
    [WAPP_MEM_ACCESS_READ_ONLY]       = PAGE_READONLY,
 | 
			
		||||
    [WAPP_MEM_ACCESS_EXEC_ONLY]       = PAGE_EXECUTE,
 | 
			
		||||
    [WAPP_MEM_ACCESS_READ_WRITE]      = PAGE_READWRITE,
 | 
			
		||||
    [WAPP_MEM_ACCESS_READ_EXEC]       = PAGE_EXECUTE_READ,
 | 
			
		||||
    [WAPP_MEM_ACCESS_READ_WRITE_EXEC] = PAGE_EXECUTE_READWRITE,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void *mem_util_allocate(void *addr, u64 size, MemAccess access, MemAllocFlags flags, MemInitType type) {
 | 
			
		||||
  // Ensure memory is committed if it's meant to be initialised
 | 
			
		||||
  if (type == WAPP_MEM_INIT_INITIALISED) {
 | 
			
		||||
    flags |= WAPP_MEM_ALLOC_COMMIT;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return VirtualAlloc(addr, (SIZE_T)size, flags, access_types[access]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mem_util_free(void *ptr, u64 size) {
 | 
			
		||||
  VirtualFree(ptr, size, MEM_RELEASE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // !WAPP_PLATFORM_WINDOWS
 | 
			
		||||
							
								
								
									
										29
									
								
								wapp/core/os/mem/win/mem_os_win.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								wapp/core/os/mem/win/mem_os_win.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
// vim:fileencoding=utf-8:foldmethod=marker
 | 
			
		||||
 | 
			
		||||
#ifndef MEM_OS_WIN_H
 | 
			
		||||
#define MEM_OS_WIN_H
 | 
			
		||||
 | 
			
		||||
#include "../../../../common/platform/platform.h"
 | 
			
		||||
 | 
			
		||||
#ifdef WAPP_PLATFORM_CPP
 | 
			
		||||
BEGIN_C_LINKAGE
 | 
			
		||||
#endif // !WAPP_PLATFORM_CPP
 | 
			
		||||
 | 
			
		||||
#ifdef WAPP_PLATFORM_WINDOWS
 | 
			
		||||
 | 
			
		||||
#define WIN32_LEAN_AND_MEAN
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
#include <memoryapi.h>
 | 
			
		||||
 | 
			
		||||
typedef enum mem_alloc_flags {
 | 
			
		||||
  WAPP_MEM_ALLOC_RESERVE = MEM_RESERVE,
 | 
			
		||||
  WAPP_MEM_ALLOC_COMMIT  = MEM_COMMIT,
 | 
			
		||||
} MemAllocFlags;
 | 
			
		||||
 | 
			
		||||
#endif // !WAPP_PLATFORM_WINDOWS
 | 
			
		||||
 | 
			
		||||
#ifdef WAPP_PLATFORM_CPP
 | 
			
		||||
END_C_LINKAGE
 | 
			
		||||
#endif // !WAPP_PLATFORM_CPP
 | 
			
		||||
 | 
			
		||||
#endif // !MEM_OS_WIN_H
 | 
			
		||||
		Reference in New Issue
	
	Block a user