Standard setup for writing C inspired by Casey Muratori, Ryan Fleury, Mr. 4th Programmer, and others in the handmade community.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

25 rindas
411 B

  1. #ifndef OS_IMPL_LINUX_CPP
  2. #define OS_IMPL_LINUX_CPP
  3. #include "os.h"
  4. #include <sys/mman.h>
  5. #include <sys/stat.h>
  6. void *os_alloc(size_t capacity) {
  7. return mmap(0, capacity, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  8. }
  9. void os_commit(void *ptr) {
  10. }
  11. void os_decommit(void *ptr) {
  12. }
  13. void os_free(void *ptr, size_t size) {
  14. int err = munmap(ptr, size);
  15. Assert(err != -1);
  16. }
  17. #endif