git: f9809df4c15f - main - devel/ksh93: remove sbrk() use

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Wed, 09 Nov 2022 21:27:37 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f9809df4c15f6b0f3b0c5a236aa70374d9d1637c

commit f9809df4c15f6b0f3b0c5a236aa70374d9d1637c
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2022-11-09 21:27:29 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2022-11-09 21:27:29 +0000

    devel/ksh93: remove sbrk() use
    
    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
---
 shells/ksh93/Makefile                              |  5 +----
 .../files/patch-src_lib_libast_vmalloc_vmbest.c    | 25 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/shells/ksh93/Makefile b/shells/ksh93/Makefile
index 438365ce743d..9814c5114408 100644
--- a/shells/ksh93/Makefile
+++ b/shells/ksh93/Makefile
@@ -14,7 +14,7 @@
 
 PORTNAME=	ksh93
 DISTVERSION=	93u
-PORTREVISION=	1
+PORTREVISION=	2
 PORTEPOCH=	2
 CATEGORIES=	shells
 DIST_SUBDIR=	ksh93
@@ -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
diff --git a/shells/ksh93/files/patch-src_lib_libast_vmalloc_vmbest.c b/shells/ksh93/files/patch-src_lib_libast_vmalloc_vmbest.c
new file mode 100644
index 000000000000..07cfd72b922c
--- /dev/null
+++ b/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;
+ 		}