/* lini.fn.c - kmlini() - initiate a linear segment * ~ lexi hale * this function is the initiator function for the * linear memory store. it simply returns the current * heap position by invoking the brk syscall with the * value `0`. (note that the brk syscall and the libc * wrapper have different behavior.) */ #include #include #ifdef KFenv_posix # include #endif /* returns void* instead of kmres because kmlini has * no failure state */ void* kmlini(void) { k_platform_syscall_arg zero = 0; /* brk adjusts the heap break then returns the new * break. by passing zero, we can get retrieve the * current heap break. */ struct k_platform_syscall_answer a = k_platform_syscall (k_platform_syscall_brk, 1, &zero); /* no point in checking for errors, since none can * actually occur; just return the kernel's answer. */ return (void*)a.ret; }