29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
if (header -> kind != kmkind_heap) return kmcond_mismatch;
# ifdef KFenv_posix
/* currently allocation is handled on posix by naive use
* of MAP_ANONYMOUS. munmap needs to be told the size of
* the region to unmap (free), which kmheapa() stores at
* (ptr - sizeof sz). see kmheap.c for details. */
if(kmem_platform_munmap(header, total) == -1) {
/* we don't need to bother recovering errno;
* there's only one possible munmap error */
return kmcond_bad_address;
}
# else
Knoimpl(kmheapf,KVos);
# error missing implementation
# endif
return kmcond_ok;
}
|
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
if (header -> kind != kmkind_heap) return kmcond_mismatch;
# ifdef KFenv_posix
/* currently allocation is handled on posix by naive use
* of MAP_ANONYMOUS. munmap needs to be told the size of
* the region to unmap (free), which kmheapa() stores at
* (ptr - sizeof sz). see kmheap.c for details. */
k_platform_syscall_arg args[] = { (sz)header, total };
struct k_platform_syscall_answer r = k_platform_syscall
(k_platform_syscall_munmap, Kmsz(args), args);
if(r.error==0) {
/* we don't need to bother recovering the error
* code, there's only one possible munmap error */
return kmcond_bad_address;
}
# else
Knoimpl(kmheapf,KVos);
# error missing implementation
# endif
return kmcond_ok;
}
|