Skip to content

Commit

Permalink
[libc] Fix PATH bug in execvpe, update ewcc includes, speed up amalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Jan 4, 2025
1 parent 60c2fe0 commit ff138d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 2 additions & 4 deletions elks/tools/objtools/ewcc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ if [ -z "$WATCOM" ]
fi

ELKSLIBCINCLUDE=$TOPDIR/libc/include
ELKSINCLUDE1=$TOPDIR/include
ELKSINCLUDE2=$TOPDIR/elks/include
WATCINCLUDE=$WATCOM/h
ELKSINCLUDE1=$TOPDIR/elks/include
ELKSINCLUDE2=$TOPDIR/libc/include/watcom

# owcc options:
# -bnone # no target specific setup
Expand Down Expand Up @@ -68,7 +67,6 @@ CCFLAGS="\
-I$ELKSLIBCINCLUDE \
-I$ELKSINCLUDE1 \
-I$ELKSINCLUDE2 \
-I$WATCINCLUDE \
"

while true; do
Expand Down
7 changes: 6 additions & 1 deletion libc/malloc/amalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ __amalloc(size_t nbytes)
ASSERT(allocp>=(NPTR)allocs && allocp<=alloct);
ASSERT(malloc_check_heap());
/* combine free areas at heap start before allocating from free area past allocp */
allocp = (NPTR)allocs;
//allocp = (NPTR)allocs; /* NOTE: start at last allocation for speed */
for(p=allocp; ; ) {
//f = nb = n = 0;
for(temp=0; ; ) {
if(!testbusy(next(p))) {
while(!testbusy(next(q = next(p)))) {
Expand All @@ -147,12 +148,15 @@ __amalloc(size_t nbytes)
(next(p) - p) * sizeof(union store),
(next(q) - q) * sizeof(union store));
next(p) = next(q);
//f++;
}
/*debug2("q %04x p %04x nw %d p+nw %04x ", (unsigned)q, (unsigned)p,
nw, (unsigned)(p+nw));*/
//nb++;
if(q>=p+nw && p+nw>=p)
goto found;
}
//n++;
q = p;
p = clearbusy(next(p));
if(p>q) {
Expand Down Expand Up @@ -211,6 +215,7 @@ __amalloc(size_t nbytes)
#endif
}
found:
//__dprintf("n %d, nb %d, f %d\n", n, nb, f);
allocp = p + nw;
ASSERT(allocp<=alloct);
if(q>allocp) {
Expand Down
3 changes: 2 additions & 1 deletion libc/system/execvpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ execvpe(const char *fname, char **argv, char **envp)
strcpy(pname, path);
strcat(pname, "/");
strcat(pname, fname);
if(p) *p++ = ':';

tryrun(pname, argv, envp);
if( errno == EACCES ) besterr = EACCES;
if( errno == ENOMEM || errno == E2BIG || errno == ENOEXEC ) goto out;

brk((char *)pname);
brk(pname);
pname = (char *)fname;
if(p) *p++ = ':';
path=p;
Expand Down

0 comments on commit ff138d6

Please sign in to comment.