use sysconf(_SC_PAGESIZE)

This commit is contained in:
nick black 2021-12-06 06:57:10 -05:00 committed by nick black
parent eab3ca981e
commit 0acb9dfe4d

View File

@ -122,7 +122,12 @@ map_troff_data(int fd, size_t* len){
// the last four bytes have the uncompressed length // the last four bytes have the uncompressed length
uint32_t ulen; uint32_t ulen;
memcpy(&ulen, buf + *len - 4, 4); memcpy(&ulen, buf + *len - 4, 4);
size_t pgsize = 4096; // FIXME long sc = sysconf(_SC_PAGESIZE);
if(sc <= 0){
fprintf(stderr, "couldn't get page size\n");
return NULL;
}
size_t pgsize = sc;
void* ubuf = mmap(NULL, (ulen + pgsize - 1) / pgsize * pgsize, void* ubuf = mmap(NULL, (ulen + pgsize - 1) / pgsize * pgsize,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
if(ubuf == MAP_FAILED){ if(ubuf == MAP_FAILED){