Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add low level OS memory API and arena. Also fixes some compile errors with GCC from recent changes. #102

Closed
wants to merge 8 commits into from

Conversation

Samdal
Copy link
Contributor

@Samdal Samdal commented Jul 29, 2024

added functionality:

GS_API_DECL void*  gs_memory_reserve(uint32_t size);
GS_API_DECL bool32 gs_memory_commit(void* ptr, uint32_t size);
GS_API_DECL void   gs_memory_decommit(void* ptr, uint32_t size);
GS_API_DECL void   gs_memory_release(void* ptr, uint32_t size);



GS_API_DECL gs_arena*    gs_arena_alloc(void);
GS_API_DECL void         gs_arena_release(gs_arena* arena);

GS_API_DECL void*        _gs_arena_push(gs_arena* arena, uint64_t size_bytes, uint64_t align_bytes);
GS_API_DECL void*        _gs_arena_push_nz(gs_arena* arena, uint64_t size_bytes, uint64_t align_bytes);
GS_API_DECL void         gs_arena_reset(gs_arena* arena);

#define gs_arena_push(a,T) (T*)(_gs_arena_push((a), sizeof(T), _Alignof(T)))
#define gs_arena_push_array(a,T,c) (T*)(_gs_arena_push((a), sizeof(T)*(c), _Alignof(T)))
#define gs_arena_push_no_zero(a,T) (T*)(_gs_arena_push_nz((a), sizeof(T), _Alignof(T)))
#define gs_arena_push_array_no_zero(a,T,c) (T*)(_gs_arena_push_nz((a), sizeof(T)*(c), _Alignof(T)))

GS_API_DECL gs_arena_temp gs_arena_begin_temp(gs_arena* arena);
GS_API_DECL void          gs_arena_end_temp(gs_arena_temp temp);

GS_API_DECL gs_arena_temp gs_arena_get_scratch(gs_arena **conflicts, uint64_t count);
#define gs_arena_release_scratch(scratch) gs_arena_end_temp(scratch)

@Samdal
Copy link
Contributor Author

Samdal commented Jul 29, 2024

closed, see #103

@Samdal Samdal closed this Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant