From: Alan Cox Date: Mon, 19 Oct 2015 20:48:41 +0000 (+0100) Subject: brk: revert the MSP340 change to brk() X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9508a62d83bb3f16b284b29e6f6ccc0873872f37;p=FUZIX.git brk: revert the MSP340 change to brk() brk sets the memory address to the one asked. If you misalign in then it's your problem in userspace. Some of our sbrk() users in userspace may well be wrong, but they need to be fixed not brk()! --- diff --git a/Kernel/syscall_proc.c b/Kernel/syscall_proc.c index a48016c4..e56081e5 100644 --- a/Kernel/syscall_proc.c +++ b/Kernel/syscall_proc.c @@ -225,17 +225,16 @@ arg_t _brk(void) need to make this something like if (brk_valid(addr)) so we can keep it portable */ - uaddr_t aligned = (uaddr_t) ALIGNUP(addr); - if (aligned >= brk_limit()) { + if (addr >= brk_limit()) { kprintf("%d: out of memory\n", udata.u_ptab->p_pid); udata.u_error = ENOMEM; return -1; } /* If we have done a break that gives us more room we must zero the extra as we no longer guarantee it is clear already */ - if (aligned > udata.u_break) - uzero((void *)udata.u_break, aligned - udata.u_break); - udata.u_break = aligned; + if (addr > udata.u_break) + uzero((void *)udata.u_break, addr - udata.u_break); + udata.u_break = addr; return 0; }