Differences From
Artifact [e98ef79662]:
- File
mod/kmem/heapao.fn.c
— part of check-in
[e50a476efe]
at
2019-08-22 02:52:20
on branch trunk
— removed sneaky segfault in x86-64 syscall fn where %r8 (the register that contains the pointer to the syscall arguments from the C syscall wrapper, which need to be copied into the correct registers before the kernel is invoked) gets overwritten if the syscall valency > 5, because of overlapping ccall and syscall ABI argument registers - r8 is clobbered by argument 5 and any further attempts to use it as a ptr segfault at best. also modified the report function so that it immediate cancels compilation if a sub-process reports failure. changed allocator function signatures so they can return a condition code if the kernel reports an error; updated example code so it compiles and runs without fault.
(user:
lexi,
size: 500)
[annotate]
[blame]
[check-ins using]
1 1 #include <k/core.h>
2 2 #include <k/mem.h>
3 -/* heapao.fn.c - kmheapao() "allocate heap object"
3 +/* heapo.fn.c - kmheapo() "allocate heap object"
4 4 * ~ lexi hale <lexi@hale.su>
5 - * kmheapao() allocates a region in heap memory
5 + * kmheapo() allocates a region in heap memory
6 6 * and returns a kmptr struct referencing that
7 7 * newly allocated region.
8 8 */
9 9
10 -kmcond kmheapao(kmptr* where, sz size) {
10 +kmcond kmheapo(kmptr* where, sz size) {
11 11 void* ptr;
12 12 kmcond e = kmheapa(&ptr, size);
13 13 if (e != kmcond_ok) return e;
14 14 kmptr p = {
15 15 .kind = (ptr != null ? kmkind_heap : kmkind_fail),
16 16 .ref = ptr,
17 17 .shred = false,
18 18 };
19 19 *where = p;
20 20 return kmcond_ok;
21 21 }