summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ql/l.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-04-10 23:11:25 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-04-10 23:11:25 +0200
commit1d3644a1684bd191f3a36568d94c2587c2d9f24f (patch)
treed846fb9fe81f38078db378a7264a9f02321f477d /sys/src/cmd/ql/l.h
parente610ffaf1b7847e82c18a1b9c687cdd7676f86c2 (diff)
cc, ?l: fix gethunk() to actually grow allocation
the compilers and linkers use ther own memory allocator. free memory is between hunk and hunk+nhunk. allocation works by checking if nhunk is bigger or equal to the amount needed, and if not, repeatedly call gethunk() until there is. after that, the allocated amount is added from hunk and subtracted from nhunk by the user. the problem was when the needed amount was bigger than the default NHUNK size gethunk() allocates per call. gethunk() would not actually grow nhunk, but instead just set hunk and nhunk variables to the last allocated block. this resulted in a infinite loop of calls to gethunk() until sbrk() would hit the maximum size for the BSS segment. this change makes gethunk() actually grow the hunk space, increasing nhunk, and only updating hunk when nhunk was previously zero. we assume that mysbrk() retuns increasing addresses and that the space between the previous hunk+nhunk and the new block base returned by mysbrk() is usable.
Diffstat (limited to 'sys/src/cmd/ql/l.h')
-rw-r--r--sys/src/cmd/ql/l.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/cmd/ql/l.h b/sys/src/cmd/ql/l.h
index e7822d01e..ec364d0fd 100644
--- a/sys/src/cmd/ql/l.h
+++ b/sys/src/cmd/ql/l.h
@@ -234,7 +234,7 @@ EXTERN long symsize;
EXTERN long staticgen;
EXTERN Prog* textp;
EXTERN long textsize;
-EXTERN uintptr tothunk;
+EXTERN uintptr thunk;
EXTERN char xcmp[C_NCLASS][C_NCLASS];
EXTERN int version;
EXTERN Prog zprg;