#include "lib.h" #include #include #include "sys9.h" char end[]; static char *bloc = { end }; extern int _BRK_(void*); enum { Round = 7 }; char * brk(char *p) { uintptr_t bl; bl = ((uintptr_t)p + Round) & ~Round; if(_BRK_((void*)bl) < 0){ errno = ENOMEM; return (char *)-1; } bloc = (char*)bl; return 0; } void * sbrk(unsigned long n) { uintptr_t bl; bl = ((uintptr_t)bloc + Round) & ~Round; if(_BRK_((void *)(bloc+n)) < 0){ errno = ENOMEM; return (void *)-1; } bloc = (char*)bl + n; return (void*)bl; }