<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Fix detection of memccpy. (Apple's build worked around the broken test
by setting -D_lib_memccpy in CCFLAGS instead.)
https://github.com/ksh93/ksh/issues/373
https://github.com/ksh93/ksh/commit/5d8ae3604ac2dfa2b32056b296f243fff7e5c5d6
--- src/lib/libast/features/lib.orig
+++ src/lib/libast/features/lib
@@ -446,6 +446,9 @@ tst	lib_memcmp string.h note{ standard memcmp interface that works }end execute{
 }end
 
 tst	lib_memccpy string.h unistd.h stdlib.h fcntl.h signal.h sys/types.h sys/stat.h sys/mman.h fcntl.h note{ standard memccpy interface that works }end execute{
+	#ifndef MAP_FAILED
+	#define MAP_FAILED ((void*)-1)	/* introduced in POSIX-1.2017 */
+	#endif
 	#if _STD_
 	static void gotcha(int sig)
 	#else
@@ -490,7 +493,7 @@ tst	lib_memccpy string.h unistd.h stdlib.h fcntl.h signal.h sys/types.h sys/stat
 			return 1;
 		}
 		m = n * (sizeof(x)-1);
-		if (!(b = mmap((void*)0, m, PROT_READ|PROT_WRITE, MAP_PRIVATE, d, (off_t)0)))
+		if ((b = mmap((void*)0, m, PROT_READ|PROT_WRITE, MAP_PRIVATE, d, (off_t)0)) == MAP_FAILED)
 		{
 			close(d);
 			return 1;
@@ -544,9 +547,9 @@ tst	lib_memccpy string.h unistd.h stdlib.h fcntl.h signal.h sys/types.h sys/stat
 			return 0;
 		if ((fd = open("/dev/zero", O_RDWR)) &lt; 0)
 			return 0;
-		if (!(srcbuf = (char*)mmap(NULL, siz, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0)))
+		if ((srcbuf = (char*)mmap(NULL, siz, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED)
 			return 0;
-		if (!mmap(srcbuf + siz, siz, PROT_NONE, MAP_PRIVATE, fd, 0))
+		if (mmap(srcbuf + siz, siz, PROT_NONE, MAP_PRIVATE, fd, 0) == MAP_FAILED)
 			return 0;
 		for (i = 0; i &lt; siz; i++)
 			srcbuf[i] = 'x';
</pre></body></html>