Skip to content

Commit

Permalink
devel/ksh93: remove sbrk() use
Browse files Browse the repository at this point in the history
ksh supports multiple sources of heap memory.  Completely disable the
use of sbrk() as a memory source in favor of mmap().  This allows
compilation on aarch64 (and presumably riscv64).

Approved by:	cy
Differential Revision: https://reviews.freebsd.org/D37312
  • Loading branch information
brooksdavis committed Nov 9, 2022
1 parent 1b29ddc commit f9809df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
5 changes: 1 addition & 4 deletions shells/ksh93/Makefile
Expand Up @@ -14,7 +14,7 @@

PORTNAME= ksh93
DISTVERSION= 93u
PORTREVISION= 1
PORTREVISION= 2
PORTEPOCH= 2
CATEGORIES= shells
DIST_SUBDIR= ksh93
Expand All @@ -25,9 +25,6 @@ WWW= http://www.kornshell.com/

LICENSE= EPL

BROKEN_aarch64= Fails to compile: needs sbrk
BROKEN_riscv64= Fails to compile: needs sbrk

USES= compiler:c11

USE_GITHUB= yes
Expand Down
25 changes: 25 additions & 0 deletions shells/ksh93/files/patch-src_lib_libast_vmalloc_vmbest.c
@@ -0,0 +1,25 @@
--- src/lib/libast/vmalloc/vmbest.c.orig
+++ src/lib/libast/vmalloc/vmbest.c
@@ -1169,6 +1169,7 @@
}
#endif /* _mem_win32 */

+#undef _mem_sbrk
#if _mem_sbrk /* getting space via brk/sbrk - not concurrent-ready */
static Void_t* sbrkmem(Void_t* caddr, size_t csize, size_t nsize)
{
@@ -1265,10 +1266,13 @@
}
}
else if(nsize == 0)
- { Vmuchar_t *addr = (Vmuchar_t*)sbrk(0);
+ {
+#if 0
+ Vmuchar_t *addr = (Vmuchar_t*)sbrk(0);
if(addr < (Vmuchar_t*)caddr ) /* in sbrk space */
return NIL(Void_t*);
else
+#endif
{ (void)munmap(caddr, csize);
return caddr;
}

0 comments on commit f9809df

Please sign in to comment.