X-Git-Url: https://deadsoftware.ru/gitweb?p=cpc.git;a=blobdiff_plain;f=src%2Fnative%2Fposix%2Fgeneric%2FSystem%2FMod%2FKernel.cp;h=5773b4ebcdedcbc3fe3124c6bb9fe428d8043569;hp=083c9977a5c89f92fbc11ed1444189e2ee5828f4;hb=b123c8223aaafee51efd0ddbad900015a2628bed;hpb=76d1e8d98f1d80d24fa52a15e6b2c6fb0a5f44d0 diff --git a/src/native/posix/generic/System/Mod/Kernel.cp b/src/native/posix/generic/System/Mod/Kernel.cp index 083c997..5773b4e 100644 --- a/src/native/posix/generic/System/Mod/Kernel.cp +++ b/src/native/posix/generic/System/Mod/Kernel.cp @@ -1,9 +1,9 @@ MODULE Kernel; - IMPORT S := SYSTEM, stdlib := C99stdlib, stdio := C99stdio, - time := C99time, wctype := C99wctype, sysmman := C99sys_mman, - dlfcn := C99dlfcn, types := C99types, fcntl := C99fcntl, - unistd := C99unistd, signal := C99signal, setjmp := C99setjmp; + IMPORT S := SYSTEM, stdlib := PosixCstdlib, stdio := PosixCstdio, + time := PosixCtime, wctype := PosixCwctype, sysmman := PosixCsys_mman, + dlfcn := PosixCdlfcn, types := PosixCtypes, fcntl := PosixCfcntl, + unistd := PosixCunistd, signal := PosixCsignal, setjmp := PosixCsetjmp; (* init fpu? *) (* add signal blocking to avoid race conditions in Try/Trap/TrapHandler *) @@ -459,12 +459,18 @@ MODULE Kernel; PROCEDURE AllocHeapMem (size: INTEGER; VAR c: Cluster); CONST N = 65536; (* cluster size for dll *) - VAR adr, allocated: INTEGER; + VAR adr, allocated, newsize: INTEGER; BEGIN INC(size, 16); ASSERT(size > 0, 100); adr := 0; - IF size < N THEN adr := stdlib.malloc(N) END; - IF adr = 0 THEN adr := stdlib.malloc(size); allocated := size ELSE allocated := N END; + IF size < N THEN + adr := AllocMem(N, newsize); + allocated := newsize + END; + IF adr = 0 THEN + adr := AllocMem(size, newsize); + allocated := newsize + END; IF adr = 0 THEN c := NIL ELSE c := S.VAL(Cluster, (adr + 15) DIV 16 * 16); c.max := adr; @@ -478,7 +484,7 @@ MODULE Kernel; PROCEDURE FreeHeapMem (c: Cluster); BEGIN DEC(used, c.size); DEC(total, c.size); - stdlib.free(S.VAL(ADDRESS, c.max)) + FreeMem(S.VAL(ADDRESS, c.max), c.size) END FreeHeapMem; PROCEDURE HeapFull (size: INTEGER): BOOLEAN;