Broom 1.0.0
A thread-local C++ Garbage Collector
Loading...
Searching...
No Matches
platform.cc
Go to the documentation of this file.
1#ifdef _WIN32
2// clang-format off
3#include <windows.h>
4// clang-format on
5
6#include <intrin.h>
7#include <memoryapi.h>
8#include <processthreadsapi.h>
9
10#include "src/globals.h"
11#include "src/macros.h"
13
14namespace broom {
15namespace platform {
16
17void* GetStackBottom() {
21 return SafeCast<void*>(high);
22}
23
24void UnmapMemorySpace(const MemorySpace& space) {
25 BENSURE(VirtualFree(space.StartPtr(), 0, MEM_RELEASE), "VirtualFree failed");
26}
27
29 switch (permissions) {
31 return PAGE_READONLY;
33 return PAGE_READWRITE;
35 return PAGE_READWRITE;
37 return 0;
38 }
39 ABORT("Unexpected permissions");
40}
41
44 void* maybe_pointer =
46 return MemorySpace{maybe_pointer, space_size};
47}
48} // namespace platform
49} // namespace broom
50#endif
#define BENSURE(x, m,...)
Definition macros.h:22
void * GetStackBottom()
void UnmapMemorySpace(const MemorySpace &space)
MemorySpace MapMemorySpace(size_t space_size, MemoryPermissions permissions=Allocator::kDefaultPermissions)
MemoryPermissions
Definition allocator.h:111
std::queue< T, broom::deque< T > > queue
Definition broom-queue.h:12
#define ABORT(m,...)