Merge pull request #33 from carmiker/master

Whitespace consistency in OpenBSD-specific code
This commit is contained in:
Kawa 2021-07-31 14:45:49 +02:00 committed by GitHub
commit fba00e5d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -87,25 +87,25 @@
#if defined (__OpenBSD__) #if defined (__OpenBSD__)
#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) #if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE)
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
static void* malloc_obsd(size_t size) { static void* malloc_obsd(size_t size) {
long pagesize = sysconf(_SC_PAGESIZE); long pagesize = sysconf(_SC_PAGESIZE);
char* memory = (char*)mmap(NULL, size + pagesize, PROT_READ|PROT_WRITE, MAP_STACK|MAP_PRIVATE|MAP_ANON, -1, 0); char* memory = (char*)mmap(NULL, size + pagesize, PROT_READ|PROT_WRITE, MAP_STACK|MAP_PRIVATE|MAP_ANON, -1, 0);
if (memory == MAP_FAILED) return NULL; if (memory == MAP_FAILED) return NULL;
*(size_t*)memory = size + pagesize; *(size_t*)memory = size + pagesize;
memory += pagesize; memory += pagesize;
return (void*)memory; return (void*)memory;
} }
static void free_obsd(void *ptr) { static void free_obsd(void *ptr) {
char* memory = (char*)ptr - sysconf(_SC_PAGESIZE); char* memory = (char*)ptr - sysconf(_SC_PAGESIZE);
munmap(memory, *(size_t*)memory); munmap(memory, *(size_t*)memory);
} }
#define LIBCO_MALLOC malloc_obsd #define LIBCO_MALLOC malloc_obsd
#define LIBCO_FREE free_obsd #define LIBCO_FREE free_obsd
#endif #endif
#endif #endif