Index: shells/ksh93/Makefile =================================================================== --- shells/ksh93/Makefile +++ shells/ksh93/Makefile @@ -12,15 +12,13 @@ PORTNAME= ksh93 PORTVERSION= ${KSHVERSION:S/-//g} -PORTREVISION= 2 CATEGORIES= shells -MASTER_SITES= http://www2.research.att.com/~astopen/download/tgz/ \ - LOCAL/sunpoet/${PORTNAME} -DISTFILES= INIT.${INITVERSION}.tgz ast-ksh.${KSHVERSION}.tgz +MASTER_SITES= https://github.com/att/ast/archive/ +DISTFILES= ${PORTNAME}v.tar.gz DIST_SUBDIR= ${PORTNAME} MAINTAINER= saper@saper.info -COMMENT= Official AT&T release of KornShell 93 +COMMENT= KornShell 93 LICENSE= EPL @@ -28,13 +26,11 @@ OPTIONS_DEFINE= EXAMPLES STATIC -FETCH_ENV= HTTP_AUTH=basic:*:I\ accept\ www.opensource.org/licenses/cpl:. LDFLAGS+= -lm -MAKE_ENV= CCFLAGS="${CFLAGS}" -NO_WRKSUBDIR= yes +MAKE_ENV= CCFLAGS="-Wno-unused-value -Wno-parentheses -Wno-logical-op-parentheses ${CFLAGS}" +WRKSRC= ${WRKDIR}/ast-${PORTNAME}v -INITVERSION= 2013-05-24 -KSHVERSION= 2012-08-01 +KSHVERSION= 2014-12-24 STATIC_MAKE_ENV= LDFLAGS+=-static @@ -44,7 +40,7 @@ @${REINPLACE_CMD} -e 's|SF_FLAGS|SFIO_FLAGS|g' ${WRKSRC}/src/lib/libast/include/sfio*.h ${WRKSRC}/src/lib/libast/sfio/*.c do-build: - @cd ${WRKSRC}/ && ${SETENV} -i ${MAKE_ENV} ${SH} bin/package flat make + @cd ${WRKSRC}/ && ${SETENV} -i ${MAKE_ENV} ${SH} bin/package flat make ksh93 do-install: ${INSTALL_PROGRAM} ${WRKSRC}/bin/ksh ${STAGEDIR}${PREFIX}/bin/ksh93 Index: shells/ksh93/distinfo =================================================================== --- shells/ksh93/distinfo +++ shells/ksh93/distinfo @@ -1,4 +1,3 @@ -SHA256 (ksh93/INIT.2013-05-24.tgz) = 118b2c8a4d651727fcd680289be69941d3045951bf9e3a4d45dcb42f0658f014 -SIZE (ksh93/INIT.2013-05-24.tgz) = 383979 -SHA256 (ksh93/ast-ksh.2012-08-01.tgz) = e6192cfa52a6a9fd20618cbaf3fa81f0cc9fd83525500757e83017275e962851 -SIZE (ksh93/ast-ksh.2012-08-01.tgz) = 2053532 +TIMESTAMP = 1551054883 +SHA256 (ksh93/ksh93v.tar.gz) = 89e5aeec66c28692aa392105552c06053ba60b09a62e94dc555dadf967bca643 +SIZE (ksh93/ksh93v.tar.gz) = 26409086 Index: shells/ksh93/files/patch-src-lib-libast-features-wchar =================================================================== --- shells/ksh93/files/patch-src-lib-libast-features-wchar +++ /dev/null @@ -1,10 +0,0 @@ ---- src/lib/libast/features/wchar.orig 2012-01-12 07:40:22 UTC -+++ src/lib/libast/features/wchar -@@ -51,6 +51,7 @@ endif - run{ - cat < va) Index: shells/ksh93/files/patch-src-lib-libast-string-tokscan.c =================================================================== --- shells/ksh93/files/patch-src-lib-libast-string-tokscan.c +++ /dev/null @@ -1,19 +0,0 @@ ---- src/lib/libast/string/tokscan.c.orig 2006-11-07 22:29:31 UTC -+++ src/lib/libast/string/tokscan.c -@@ -233,7 +233,16 @@ tokscan(register char* s, char** nxt, co - prv_f = f; - f = va_arg(ap, char*); - va_copy(prv_ap, ap); -+#if __clang__ && __SIZEOF_POINTER__ == 4 -+ { -+ va_list np; -+ -+ np = va_listval(va_arg(ap, va_listarg)); -+ va_copy(ap, np); -+ } -+#else - va_copy(ap, va_listval(va_arg(ap, va_listarg))); -+#endif - continue; - case 'c': - p_char = va_arg(ap, char*); Index: shells/ksh93/files/patch-src_cmd_INIT_iffe.sh =================================================================== --- shells/ksh93/files/patch-src_cmd_INIT_iffe.sh +++ /dev/null @@ -1,20 +0,0 @@ ---- src/cmd/INIT/iffe.sh.orig 2013-03-06 16:33:17 UTC -+++ src/cmd/INIT/iffe.sh -@@ -3414,7 +3414,7 @@ $src - (eval "$src") <&$nullin || e=1 - ;; - mac*|nomac*) -- if compile $cc -E $tmp.c <&$nullin >$tmp.i -+ if compile $cc -E -P $tmp.c <&$nullin >$tmp.i - then sed -e '/<<[ ]*".*"[ ]*>>/!d' -e 's/<<[ ]*"//g' -e 's/"[ ]*>>//g' $tmp.i - else e=1 - fi -@@ -3705,7 +3705,7 @@ $inc - <<\"#define $v\">> $v <<\"/* native $v */\">> - <<\"#endif\">> - #endif" > $tmp.c -- if compile $cc -E $tmp.c <&$nullin >$tmp.i -+ if compile $cc -E -P $tmp.c <&$nullin >$tmp.i - then sed -e '/<<[ ]*".*"[ ]*>>/!d' -e 's/<<[ ]*"//g' -e 's/"[ ]*>>//g' $tmp.i > $tmp.t - if test -s $tmp.t - then success Index: shells/ksh93/files/patch-src_cmd_proto_proto.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_cmd_proto_proto.c @@ -0,0 +1,18 @@ +--- src/cmd/proto/proto.c.orig 2017-11-30 22:35:04 UTC ++++ src/cmd/proto/proto.c +@@ -396,6 +396,15 @@ proto(char* file, char* license, char* o + + #if !PROTO_STANDALONE + #undef error ++void ++error( int xit, const char *msg, ... ) ++{ ++ va_list ap; ++ va_start( ap, msg ); ++ vfprintf( stderr, msg, ap ); ++ va_end( ap ); ++ exit( xit ); ++} + #endif + + typedef struct Sufcom_s Index: shells/ksh93/files/patch-src_cmd_std_features_procfs =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_cmd_std_features_procfs @@ -0,0 +1,36 @@ +--- src/cmd/std/features/procfs.orig 2017-11-30 22:35:04 UTC ++++ src/cmd/std/features/procfs +@@ -1,6 +1,6 @@ + hdr kvm,procinfo,pstat,asm/param + +-sys procfs,sysctl ++sys procfs,sysctl,user + + lib getprocs + lib kvm_open,kvm_getprocs kvm.h sys/time.h sys/param.h sys/proc.h sys/sysctl.h -lkvm +@@ -10,7 +10,11 @@ mem extern_proc.p_pid,extern_proc.p_star + mem procsinfo64.pi_pri procinfo.h + mem prpsinfo.pr_clname,prpsinfo.pr_cstime,prpsinfo.pr_cstime.tv_sec,prpsinfo.pr_ctime,prpsinfo.pr_cutime,prpsinfo.pr_gid,prpsinfo.pr_lttydev,prpsinfo.pr_ntpid,prpsinfo.pr_pgid,prpsinfo.pr_pgrp,prpsinfo.pr_psargs,prpsinfo.pr_refcount,prpsinfo.pr_rssize,prpsinfo.pr_sid,prpsinfo.pr_sonproc,prpsinfo.pr_start,prpsinfo.pr_start.tv_sec,prpsinfo.pr_starttime,prpsinfo.pr_starttime.tv_sec,prpsinfo.pr_state,prpsinfo.pr_stime,prpsinfo.pr_tgrp,prpsinfo.pr_time,prpsinfo.pr_time.tv_sec,prpsinfo.pr_utime,prpsinfo.pr_zomb,prpsinfo.pr_pctcpu,prpsinfo.pr_cpu,prpsinfo.pr_lwp.pr_pctcpu,prpsinfo.pr_lwp.pr_cpu -D_STRUCTURED_PROC -Dprpsinfo=psinfo sys/types.h sys/procfs.h + ++num PIOCPSINFO ++ + typ struct.prpsinfo -D_STRUCTURED_PROC -Dprpsinfo=psinfo sys/types.h sys/procfs.h ++typ struct.kinfo_proc sys/types.h sys/procfs.h sys/user.h ++typ struct.kp_proc sys/types.h sys/procfs.h sys/user.h + + tst lib_info note{ info(2) kernel table api }end link{ + #include +@@ -587,11 +591,11 @@ cat{ + #define PSS_METHOD PSS_METHOD_getprocs + #endif + +-#if !PSS_METHOD && defined(_PS_dir) ++#if !PSS_METHOD && defined(_PS_dir) && (_PS_scan_binary || _num_PIOCPSINFO) + #define PSS_METHOD PSS_METHOD_procfs + #endif + +-#if !PSS_METHOD && _hdr_kvm && _sys_sysctl && _lib_kvm_open && _lib_kvm_getprocs ++#if !PSS_METHOD && _hdr_kvm && _sys_sysctl && _lib_kvm_open && _lib_kvm_getprocs && _typ_struct_kinfo_proc && _typ_struct_kp_proc + #define PSS_METHOD PSS_METHOD_kvm + #endif + Index: shells/ksh93/files/patch-src_cmd_std_pss-kvm.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_cmd_std_pss-kvm.c @@ -0,0 +1,12 @@ +--- src/cmd/std/pss-kvm.c.orig 2017-11-30 22:35:04 UTC ++++ src/cmd/std/pss-kvm.c +@@ -43,6 +43,9 @@ NoN(pss_kvm) + #if _sys_proc + #include + #endif ++#if _sys_user ++#include ++#endif + #include + #include + Index: shells/ksh93/files/patch-src_lib_libast_comp_setlocale.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_comp_setlocale.c @@ -0,0 +1,10 @@ +--- src/lib/libast/comp/setlocale.c.orig 2017-11-30 22:35:04 UTC ++++ src/lib/libast/comp/setlocale.c +@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + + #if ( _lib_wcwidth || _lib_wctomb ) && _hdr_wctype + #include Index: shells/ksh93/files/patch-src_lib_libast_features_mmap =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_features_mmap @@ -0,0 +1,191 @@ +--- src/lib/libast/features/mmap.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/features/mmap +@@ -16,14 +16,7 @@ tst lib_mmap note{ standard mmap interfa + + #define Failed(file) (remove(file),1) + +- int +- #if _STD_ +- main(int argc, char** argv) +- #else +- main(argc,argv) +- int argc; +- char** argv; +- #endif ++ int main(int argc, char** argv) + { + caddr_t mm; + char *file; +@@ -165,169 +158,18 @@ tst lib_mmap64 -D_LARGEFILE64_SOURCE not + } + }end + +-tst mmap_anon note{ use mmap MAP_ANON to get raw memory }end execute{ +- #if !_lib_mmap +- ( +- #endif +- #include +- #include +- #include +- #include +- #if defined(MAP_ANONYMOUS) && !defined(MAP_ANON) +- #define MAP_ANON MAP_ANONYMOUS +- #endif +- int +- main() +- { void *addr; +- addr = mmap(0,1024*1024,PROT_READ|PROT_WRITE,MAP_ANON|MAP_PRIVATE,-1,0); +- return (addr && addr != (void*)(-1)) ? 0 : 1; +- } +-}end +- +-tst mmap_devzero note{ use mmap on /dev/zero to get raw memory }end execute{ +- #if !_lib_mmap +- ( +- #endif +- #include +- #include +- #include +- #include +- int +- main() +- { int fd; +- void *addr; +- if((fd = open("/dev/zero", O_RDWR)) < 0) +- return 1; +- addr = mmap(0,1024*1024,PROT_READ|PROT_WRITE,MAP_PRIVATE,fd,0); +- return (addr && addr != (void*)(-1)) ? 0 : 1; +- } +-}end +- +-tst -D_LARGEFILE64_SOURCE note{ mmap is worth using }end output{ +- #if !_lib_mmap +- ( +- #endif +- #include +- #include +- #include +- #include +- #include +- #include +- #include +- +- #if _lib_mmap64 +- #undef mmap +- #define mmap mmap64 +- #endif +- +- #if _lib_munmap64 +- #undef munmap +- #define munmap munmap64 +- #endif +- +- #define MAPSIZE (64*1024) +- #define BUFSIZE (MAPSIZE/8) +- #define WRITE (64) +- #define RUN (64) +- +- #define Failed(file) (remove(file),1) +- +- int +- #if _STD_ +- main(int argc, char** argv) +- #else +- main(argc,argv) +- int argc; +- char** argv; +- #endif +- { +- caddr_t mm; +- char *file, *t; +- int i, fd, k, run; +- char buf[MAPSIZE]; +- struct tms stm, etm; +- clock_t rdtm, mmtm; +- +- file = argv[1]; +- if ((fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666)) < 0) +- return 1; +- +- for (i = 0; i < sizeof(buf); ++i) +- buf[i] = '0' + (i%10); +- for (i = 0; i < WRITE; ++i) +- if (write(fd,buf,sizeof(buf)) != sizeof(buf)) +- return Failed(file); +- close(fd); +- +- /* read time */ +- times(&stm); +- for(run = 0; run < RUN; ++run) +- { if((fd = open(file, O_RDWR)) < 0) +- return Failed(file); +- for (i = 0; i < WRITE; ++i) +- { for(k = 0; k < MAPSIZE; k += BUFSIZE) +- if (read(fd,buf,BUFSIZE) != BUFSIZE) +- return Failed(file); +- } +- close(fd); +- } +- times(&etm); +- rdtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime); +- +- /* mmap time */ +- times(&stm); +- for(run = 0; run < RUN; ++run) +- { if ((fd = open(file, O_RDWR)) < 0) +- return Failed(file); +- for(i = 0, mm = (caddr_t)0; i < WRITE; ++i) +- { if(mm) +- munmap(mm, MAPSIZE); +- mm = (caddr_t)mmap((caddr_t)0, MAPSIZE, +- (PROT_READ|PROT_WRITE), +- MAP_PRIVATE, fd, i*MAPSIZE ); +- if(mm == (caddr_t)(-1) || mm == (caddr_t)0) +- return Failed(file); +- +- /* the memcpy is < BUFSIZE to simulate the +- fact that functions like sfreserve/sfgetr do +- not do buffer copying. +- */ +- t = (char*)mm; +- for(k = 0; k < MAPSIZE; k += BUFSIZE, t += BUFSIZE) +- memcpy(buf,t,(3*BUFSIZE)/4); +- } +- close(fd); +- } +- times(&etm); +- mmtm = (etm.tms_utime-stm.tms_utime) + (etm.tms_stime-stm.tms_stime); +- +- remove(file); +- +- if(4*mmtm <= 3*rdtm) +- printf("#define _mmap_worthy 2 /* mmap outperforms read on 64Ki buffers -- use it */\n"); +- else if(4*mmtm <= 5*rdtm) +- printf("#define _mmap_worthy 2 /* mmap is slightly better than read on 64Ki buffers -- use it */\n"); +- else +- printf("#define _mmap_worthy 2 /* mmap worse than read on 64Ki buffers -- use it anyway */\n"); +- +- return 0; +- } +-}end +- + cat{ ++ /* assume MAP_ANON works */ ++ #define _mmap_anon 1 + + /* some systems get it wrong but escape concise detection */ +- #ifndef _NO_MMAP + #if __CYGWIN__ + #define _NO_MMAP 1 + #endif +- #endif + + #if _NO_MMAP + #undef _lib_mmap + #undef _lib_mmap64 +- #undef _mmap_anon +- #undef _mmap_devzero +- #undef _mmap_worthy ++ #undef _mmap_anon + #endif + }end Index: shells/ksh93/files/patch-src_lib_libast_features_standards =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_features_standards @@ -0,0 +1,23 @@ +--- src/lib/libast/features/standards.orig 2017-11-30 22:35:04 UTC ++++ src/lib/libast/features/standards +@@ -1,5 +1,19 @@ + set stdio +-if tst note{ _GNU_SOURCE works }end compile{ ++# In FreeBSD, definitions like _POSIX_SOURCE and such are used to *limit* ++# functionality to known API; they don't enable anything. The general intent in ++# BSD is to enable everything by default (effectively, providing the ++# _KITCHEN_SINK_SOURCE mentioned below). So we look for that here, but stay ++# careful that we don't get fooled by presence of FreeBSD that underpins some ++# subsystems in Mac OS X; there are other Apple-specific portability hacks ++# elsewhere we should not interfere with. ++if tst note{ FreeBSD }end compile{ ++ #include ++ #if !defined(__FreeBSD__) || defined(APPLE) ++ #error not a FreeBSD system ++ #endif ++ }end { ++ } ++elif tst note{ _GNU_SOURCE works }end compile{ + #define _GNU_SOURCE 1 + #include + #include Index: shells/ksh93/files/patch-src_lib_libast_features_vmalloc =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_features_vmalloc @@ -0,0 +1,10 @@ +--- src/lib/libast/features/vmalloc.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/features/vmalloc +@@ -217,7 +217,4 @@ cat{ + #if _mmap_anon + #define _mem_mmap_anon 1 + #endif +- #if _mmap_devzero +- #define _mem_mmap_zero 1 +- #endif + }end Index: shells/ksh93/files/patch-src_lib_libast_features_wchar =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_features_wchar @@ -0,0 +1,10 @@ +--- src/lib/libast/features/wchar.orig 2017-11-30 22:35:04 UTC ++++ src/lib/libast/features/wchar +@@ -6,6 +6,7 @@ set include . + cat{ + #ifndef _AST_WCHAR_H + #define _AST_WCHAR_H 1 ++ #define _STDFILE_DECLARED + }end + + lib mbstowcs,wctomb,wcscmp,wcscoll,wcslen,wcstombs,wcsxfrm,wcwidth stdlib.h stdio.h wchar.h Index: shells/ksh93/files/patch-src_lib_libast_port_astcopy.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_port_astcopy.c @@ -0,0 +1,17 @@ +--- src/lib/libast/port/astcopy.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/port/astcopy.c +@@ -30,14 +30,10 @@ + #include + #include + +-#if _mmap_worthy > 1 +- + #include + + #define MAPSIZE (1024*256) + +-#endif +- + #undef BUFSIZ + #define BUFSIZ 4096 + Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfclose.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfclose.c @@ -0,0 +1,14 @@ +--- src/lib/libast/sfio/sfclose.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfclose.c +@@ -104,11 +104,9 @@ Sfio_t* f; + + if(f->data && (!local || (f->flags&SF_STRING) || (f->bits&SF_MMAP) ) ) + { /* free buffer */ +-#if _mmap_worthy + if(f->bits&SF_MMAP) + SFMUNMAP(f,f->data,f->endb-f->data); + else +-#endif + if(f->flags&SF_MALLOC) + data = (Void_t*)f->data; + Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfhdr.h =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfhdr.h @@ -0,0 +1,12 @@ +--- src/lib/libast/sfio/sfhdr.h.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfhdr.h +@@ -209,9 +209,6 @@ + + /* see if we can use memory mapping for io */ + #if _LARGEFILE64_SOURCE && !_lib_mmap64 +-#undef _mmap_worthy +-#endif +-#if !_mmap_worthy + #undef _hdr_mman + #undef _sys_mman + #endif Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfmode.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfmode.c @@ -0,0 +1,45 @@ +--- src/lib/libast/sfio/sfmode.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfmode.c +@@ -404,7 +404,6 @@ reg int local; /* a local call */ + + if(f->mode&SF_GETR) + { f->mode &= ~SF_GETR; +-#if _mmap_worthy + if(f->bits&SF_MMAP) + { + if (!++f->ngetr) +@@ -415,7 +414,6 @@ reg int local; /* a local call */ + f->ngetr = f->tiny[0] = 0; + } + } +-#endif + if(f->getr) + { f->next[-1] = f->getr; + f->getr = 0; +@@ -519,12 +517,10 @@ reg int local; /* a local call */ + if((f->flags&(SF_SHARE|SF_PUBLIC)) == (SF_SHARE|SF_PUBLIC) && + (addr = SFSK(f,0,SEEK_CUR,f->disc)) != f->here) + { +-#if _mmap_worthy + if((f->bits&SF_MMAP) && f->data) + { SFMUNMAP(f,f->data,f->endb-f->data); + f->data = NIL(uchar*); + } +-#endif + f->endb = f->endr = f->endw = f->next = f->data; + f->here = addr; + } +@@ -567,13 +563,11 @@ reg int local; /* a local call */ + } + + f->mode = SF_WRITE|SF_LOCK; +-#if _mmap_worthy + if(f->bits&SF_MMAP) + { if(f->data) + SFMUNMAP(f,f->data,f->endb-f->data); + (void)SFSETBUF(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND); + } +-#endif + if(f->data == f->tiny) + { f->endb = f->data = f->next = NIL(uchar*); + f->size = 0; Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfpurge.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfpurge.c @@ -0,0 +1,18 @@ +--- src/lib/libast/sfio/sfpurge.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfpurge.c +@@ -54,7 +54,6 @@ Sfio_t* f; + SFLOCK(f,0); + + /* if memory map must be a read stream, pretend data is gone */ +-#if _mmap_worthy + if(f->bits&SF_MMAP) + { f->here -= f->endb - f->next; + if(f->data) +@@ -64,7 +63,6 @@ Sfio_t* f; + SFOPEN(f,0); + SFMTXRETURN(f, 0); + } +-#endif + + switch(f->mode&~SF_LOCK) + { Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfrd.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfrd.c @@ -0,0 +1,31 @@ +--- src/lib/libast/sfio/sfrd.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfrd.c +@@ -92,12 +92,10 @@ Sfdisc_t* disc; + { f->endb = f->next = f->endr = f->data; + f->mode &= ~SF_SYNCED; + } +-#if _mmap_worthy + if((f->bits&SF_MMAP) && f->data) + { SFMUNMAP(f, f->data, f->endb-f->data); + f->data = NIL(uchar*); + } +-#endif + f->next = f->endb = f->endr = f->endw = f->data; + } + } +@@ -132,7 +130,6 @@ Sfdisc_t* disc; + } + } + +-#if _mmap_worthy + if(f->bits&SF_MMAP) + { reg ssize_t a, round; + sfstat_t st; +@@ -230,7 +227,6 @@ Sfdisc_t* disc; + } + } + } +-#endif + + /* sync unseekable write streams to prevent deadlock */ + if(!dosync && f->extent < 0) Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfseek.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfseek.c @@ -0,0 +1,43 @@ +--- src/lib/libast/sfio/sfseek.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfseek.c +@@ -34,12 +34,10 @@ Sfio_t* f; + Sfoff_t p; + #endif + { +-#if _mmap_worthy + if((f->bits&SF_MMAP) && f->data) + { SFMUNMAP(f, f->data, f->endb-f->data); + f->data = NIL(uchar*); + } +-#endif + f->next = f->endr = f->endw = f->data; + f->endb = (f->mode&SF_WRITE) ? f->data+f->size : f->data; + if((f->here = p) < 0) +@@ -201,23 +199,13 @@ int type; /* 0: from org, 1: from here, + if((p += type == SEEK_CUR ? s : 0) < 0) + goto done; + +-#if _mmap_worthy + if(f->bits&SF_MMAP) + { /* if mmap is not great, stop mmaping if moving around too much */ +-#if _mmap_worthy < 2 +- if((f->next - f->data) < ((f->endb - f->data)/4) ) +- { SFSETBUF(f,(Void_t*)f->tiny,(size_t)SF_UNBOUND); +- hardseek = 1; /* this forces a hard seek below */ +- } +- else +-#endif +- { /* for mmap, f->here can be virtual except for hardseek */ +- newpos(f,p); +- if(!hardseek) +- goto done; +- } ++ /* for mmap, f->here can be virtual except for hardseek */ ++ newpos(f,p); ++ if(!hardseek) ++ goto done; + } +-#endif + + if(f->endb > f->next) + { /* reduce wastage in future buffer fillings */ Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfsetbuf.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfsetbuf.c @@ -0,0 +1,34 @@ +--- src/lib/libast/sfio/sfsetbuf.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfsetbuf.c +@@ -302,7 +302,6 @@ size_t size; /* buffer size, -1 for defa + okmmap = (buf || (f->flags&SF_STRING) || (f->flags&SF_RDWR) == SF_RDWR) ? 0 : 1; + + /* save old buffer info */ +-#if _mmap_worthy + if(f->bits&SF_MMAP) + { if(f->data) + { if(f->getr && (f->mode&SF_GETR) && f->next) +@@ -311,7 +310,6 @@ size_t size; /* buffer size, -1 for defa + f->data = NIL(uchar*); + } + } else +-#endif + if(f->data == f->tiny) + { f->data = NIL(uchar*); + f->size = 0; +@@ -438,7 +436,6 @@ size_t size; /* buffer size, -1 for defa + } + } + +-#if _mmap_worthy + if(okmmap && size && (f->mode&SF_READ) && f->extent >= 0 ) + { /* see if we can try memory mapping */ + if(!disc) +@@ -457,7 +454,6 @@ size_t size; /* buffer size, -1 for defa + } + } + } +-#endif + + /* get buffer space */ + setbuf: Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfsetfd.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfsetfd.c @@ -0,0 +1,15 @@ +--- src/lib/libast/sfio/sfsetfd.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfsetfd.c +@@ -108,12 +108,10 @@ int newfd; + SFMTXRETURN(f, -1); + } + +-#if _mmap_worthy + if((f->bits&SF_MMAP) && f->data) + { SFMUNMAP(f,f->data,f->endb-f->data); + f->data = NIL(uchar*); + } +-#endif + + /* make stream appears uninitialized */ + f->endb = f->endr = f->endw = f->data; Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfsize.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfsize.c @@ -0,0 +1,15 @@ +--- src/lib/libast/sfio/sfsize.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfsize.c +@@ -80,12 +80,10 @@ Sfio_t* f; + + if(f->here != s && (f->mode&SF_READ) ) + { /* buffered data is known to be invalid */ +-#if _mmap_worthy + if((f->bits&SF_MMAP) && f->data) + { SFMUNMAP(f,f->data,f->endb-f->data); + f->data = NIL(uchar*); + } +-#endif + f->next = f->endb = f->endr = f->endw = f->data; + } + Index: shells/ksh93/files/patch-src_lib_libast_sfio_sfsk.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_sfio_sfsk.c @@ -0,0 +1,15 @@ +--- src/lib/libast/sfio/sfsk.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/sfio/sfsk.c +@@ -49,12 +49,10 @@ Sfdisc_t* disc; + SFMTXRETURN(f, (Sfoff_t)(-1)); + if(SFSYNC(f) < 0) + SFMTXRETURN(f, (Sfoff_t)(-1)); +-#if _mmap_worthy + if(f->mode == SF_READ && (f->bits&SF_MMAP) && f->data) + { SFMUNMAP(f, f->data, f->endb-f->data); + f->data = NIL(uchar*); + } +-#endif + f->next = f->endb = f->endr = f->endw = f->data; + } + Index: shells/ksh93/files/patch-src_lib_libast_string_strexpr.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_string_strexpr.c @@ -0,0 +1,87 @@ +--- src/lib/libast/string/strexpr.c.orig 2017-11-30 22:35:04 UTC ++++ src/lib/libast/string/strexpr.c +@@ -44,7 +44,7 @@ + #define peekchr(ex) (*(ex)->nextchr) + #define ungetchr(ex) ((ex)->nextchr--) + +-#define error(ex,msg) return(seterror(ex,msg)) ++#define err(ex,msg) return(seterror(ex,msg)) + + typedef struct /* expression handle */ + { +@@ -87,7 +87,7 @@ expr(register Expr_t* ex, register int p + case 0: + ungetchr(ex); + if (!precedence) return(0); +- error(ex, "more tokens expected"); ++ err(ex, "more tokens expected"); + case '-': + n = -expr(ex, 13); + break; +@@ -113,17 +113,17 @@ expr(register Expr_t* ex, register int p + case 0: + goto done; + case ')': +- if (!precedence) error(ex, "too many )'s"); ++ if (!precedence) err(ex, "too many )'s"); + goto done; + case '(': + n = expr(ex, 1); + if (getchr(ex) != ')') + { + ungetchr(ex); +- error(ex, "closing ) expected"); ++ err(ex, "closing ) expected"); + } + gotoperand: +- if (operand) error(ex, "operator expected"); ++ if (operand) err(ex, "operator expected"); + operand = 1; + continue; + case '?': +@@ -140,7 +140,7 @@ expr(register Expr_t* ex, register int p + if (getchr(ex) != ':') + { + ungetchr(ex); +- error(ex, ": expected for ? operator"); ++ err(ex, ": expected for ? operator"); + } + if (n) + { +@@ -189,7 +189,7 @@ expr(register Expr_t* ex, register int p + break; + case '=': + case '!': +- if (peekchr(ex) != '=') error(ex, "operator syntax error"); ++ if (peekchr(ex) != '=') err(ex, "operator syntax error"); + if (precedence > 7) goto done; + getchr(ex); + x = expr(ex, 8); +@@ -237,7 +237,7 @@ expr(register Expr_t* ex, register int p + if (precedence > 11) goto done; + x = expr(ex, 12); + if (c == '*') n *= x; +- else if (x == 0) error(ex, "divide by zero"); ++ else if (x == 0) err(ex, "divide by zero"); + else if (c == '/') n /= x; + else n %= x; + break; +@@ -246,15 +246,15 @@ expr(register Expr_t* ex, register int p + pos = --ex->nextchr; + if (isdigit(c)) n = strton(ex->nextchr, &ex->nextchr, NiL, 0); + else if (ex->convert) n = (*ex->convert)(ex->nextchr, &ex->nextchr, ex->handle); +- if (ex->nextchr == pos) error(ex, "syntax error"); ++ if (ex->nextchr == pos) err(ex, "syntax error"); + goto gotoperand; + } + if (ex->errmsg) return(0); +- if (!operand) error(ex, "operand expected"); ++ if (!operand) err(ex, "operand expected"); + } + done: + ungetchr(ex); +- if (!operand) error(ex, "operand expected"); ++ if (!operand) err(ex, "operand expected"); + return(n); + } + Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_malloc.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_malloc.c @@ -0,0 +1,20 @@ +--- src/lib/libast/vmalloc/malloc.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/malloc.c +@@ -906,7 +906,7 @@ union Alloca_u + { char* addr; + Alloca_t* next; + } head; +- char array[ALIGN]; ++ char array[MEM_ALIGN]; + }; + struct Alloca_s + { union Alloca_u head; +@@ -914,7 +914,7 @@ struct Alloca_s + }; + + extern Void_t* alloca(size_t size) +-{ char array[ALIGN]; ++{ char array[MEM_ALIGN]; + char* file; + int line; + Void_t* func; Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmbest.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmbest.c @@ -0,0 +1,101 @@ +--- src/lib/libast/vmalloc/vmbest.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmbest.c +@@ -64,19 +64,19 @@ void _STUB_vmbest(){} + #define PK_ALLOW 128 /* min #packs allowed to be created */ + + /* Small requests are rounded to 0%SM_RNDx */ +-#define SM_RND0 (1*ALIGN) /* round value: 1*ALIGN == 16 */ ++#define SM_RND0 (1*MEM_ALIGN) /* round value: 1*MEM_ALIGN == 16 */ + #define SM_BIT0 4 /* (1<= BODYSIZE && (BDSZ(node)%ALIGN) == 0 ); ++ /**/DEBUG_ASSERT(BDSZ(node) >= BODYSIZE && (BDSZ(node)%MEM_ALIGN) == 0 ); + + if(SIZE(node) & (BUSY|PFREE)) /* should be BITS-free */ + { /**/DEBUG_MESSAGE("Free block corrupted"); /**/DEBUG_ASSERT(0); return -1; } +@@ -252,7 +252,7 @@ static int bestfree(Vmalloc_t* vm, Void_ + if((Vmuchar_t*)data < vm->data->segmin || (Vmuchar_t*)data >= vm->data->segmax) + return -1; + +- blk = BLOCK(data); /**/DEBUG_ASSERT((SIZE(blk)&BUSY) && (BDSZ(blk)%ALIGN) == 0 ); ++ blk = BLOCK(data); /**/DEBUG_ASSERT((SIZE(blk)&BUSY) && (BDSZ(blk)%MEM_ALIGN) == 0 ); + pack = PACK(blk); /**/DEBUG_ASSERT(pack->best == (Vmbest_t*)vm->data); + if((sz = SIZE(blk))&SMALL ) + listp = &pack->small[SMDECODE(sz)].free; +@@ -339,7 +339,7 @@ static Block_t* bestpackextend(Vmalloc_t + + /**/DEBUG_ASSERT(!wild || (PACK(wild) == pack && BDSZ(wild) < size && PACKWILD(pack,wild)) ); + blkz = BDSZ(pack->pblk); /**/DEBUG_ASSERT(blkz >= _Vmpagesize); +- size += blkz - (wild ? BDSZ(wild) : 0) + EXTRA(pack); /**/DEBUG_ASSERT(size%ALIGN == 0); ++ size += blkz - (wild ? BDSZ(wild) : 0) + EXTRA(pack); /**/DEBUG_ASSERT(size%MEM_ALIGN == 0); + if(_Vmassert & VM_debug) debug_printf(2, "%s:%d: PACK(%p) WILD(%p)=%zd BDSZ(%p)=%zd blkz=%zd size=%zu\n", __FILE__, __LINE__, pack, wild, wild ? BDSZ(wild) : 0, pack->pblk, BDSZ(pack->pblk), blkz, size); + if(!(pblk = (*_Vmsegalloc)(vm, pack->pblk, size, segtype)) ) + pblk = pack->pblk; +@@ -383,7 +383,7 @@ static Block_t* bestpackextract(Pack_t* + + l = r = &link; + if((root = pack->root) ) do /* top-down splay tree search */ +- { /**/DEBUG_ASSERT((size%ALIGN) == 0 && !(SIZE(root)&(BUSY|PFREE)) ); ++ { /**/DEBUG_ASSERT((size%MEM_ALIGN) == 0 && !(SIZE(root)&(BUSY|PFREE)) ); + if(size == (sz = BDSZ(root)) ) + break; + if(size < sz) +@@ -508,7 +508,7 @@ static int bestlistreclaim(Vmalloc_t* vm + continue; + + /**/DEBUG_ASSERT((SIZE(fp)&(BUSY|MARK)) == (BUSY|MARK) ); +- /**/DEBUG_ASSERT(BDSZ(fp) >= sizeof(Body_t) && BDSZ(fp)%ALIGN == 0); ++ /**/DEBUG_ASSERT(BDSZ(fp) >= sizeof(Body_t) && BDSZ(fp)%MEM_ALIGN == 0); + SIZE(fp) &= ~BITS; + t = NEXT(fp); + SIZE(t) |= PFREE; /**/DEBUG_ASSERT(SIZE(NEXT(fp))&BUSY); +@@ -563,7 +563,7 @@ static Block_t* bestpackalloc(Vmalloc_t* + ssize_t sz; + Block_t *tp, *np, *pblk; + Vmbest_t *best = (Vmbest_t*)vm->data; +- /**/DEBUG_ASSERT(size >= sizeof(Body_t) && size%ALIGN == 0); ++ /**/DEBUG_ASSERT(size >= sizeof(Body_t) && size%MEM_ALIGN == 0); + + if((tp = pack->alloc) ) /* fast allocation from recent memory */ + { pack->alloc = NIL(Block_t*); +@@ -719,9 +719,9 @@ static Void_t* bestalloc(Vmalloc_t* vm, + asospindecl(); + + /**/DEBUG_COUNT(N_alloc); +- /**/DEBUG_ASSERT((ALIGN%(BITS+1)) == 0 ); +- /**/DEBUG_ASSERT((sizeof(Head_t)%ALIGN) == 0 ); +- /**/DEBUG_ASSERT((sizeof(Body_t)%ALIGN) == 0 ); ++ /**/DEBUG_ASSERT((MEM_ALIGN%(BITS+1)) == 0 ); ++ /**/DEBUG_ASSERT((sizeof(Head_t)%MEM_ALIGN) == 0 ); ++ /**/DEBUG_ASSERT((sizeof(Body_t)%MEM_ALIGN) == 0 ); + /**/DEBUG_ASSERT(sizeof(Block_t) == (sizeof(Body_t)+sizeof(Head_t)) ); + /**/DEBUG_ASSERT(chkregion((Vmbest_t*)vm->data, local) >= 0); + +@@ -902,7 +902,7 @@ static Void_t* bestalign(Vmalloc_t* vm, + return NIL(Void_t*); + + algz = LGROUND(size); +- algn = (*_Vmlcm)(align,ALIGN); ++ algn = (*_Vmlcm)(align,MEM_ALIGN); + + /* non-Vmbest methods may require extra header space */ + if(METHOD(best) != VM_MTBEST && vm->meth.eventf) Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmdcshare.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmdcshare.c @@ -0,0 +1,20 @@ +--- src/lib/libast/vmalloc/vmdcshare.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmdcshare.c +@@ -61,7 +61,7 @@ void _STUB_vmdcshare(){} + #define MM_REMOVE 02 /* remove files/segments */ + + /* macros to get the data section and size */ +-#define MMHEAD(name) ROUND(sizeof(Mmvm_t)+strlen(name), ALIGN) ++#define MMHEAD(name) ROUND(sizeof(Mmvm_t)+strlen(name), MEM_ALIGN) + #define MMDATA(mmvm) ((Vmuchar_t*)(mmvm)->base + MMHEAD(mmvm->name)) + #define MMSIZE(mmvm) ((mmvm)->size - MMHEAD(mmvm->name)) + +@@ -178,7 +178,7 @@ static int mminit(Mmdisc_t* mmdc) + /* fixed size region so make it reasonably large */ + if((size = mmdc->size) < MM_MINSIZE ) + size = MM_MINSIZE; +- size += MMHEAD(mmdc->name) + ALIGN; ++ size += MMHEAD(mmdc->name) + MEM_ALIGN; + size = ROUND(size, _Vmpagesize); + + /* get/create the initial segment of data */ Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmdcsystem.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmdcsystem.c @@ -0,0 +1,126 @@ +--- src/lib/libast/vmalloc/vmdcsystem.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmdcsystem.c +@@ -66,18 +66,16 @@ static Vmemory_f _Vmemoryf = 0; + + #if _std_malloc + #undef _mem_mmap_anon +-#undef _mem_mmap_zero + #undef _mem_sbrk + #undef _mem_win32 + #endif + + #if _mem_win32 + #undef _mem_mmap_anon +-#undef _mem_mmap_zero + #undef _mem_sbrk + #endif + +-#if _mem_mmap_anon || _mem_mmap_zero /* may get space using mmap */ ++#if _mem_mmap_anon /* may get space using mmap */ + #include + #ifndef MAP_ANON + #ifdef MAP_ANONYMOUS +@@ -86,7 +84,7 @@ static Vmemory_f _Vmemoryf = 0; + #define MAP_ANON 0 + #endif /*MAP_ANONYMOUS*/ + #endif /*MAP_ANON*/ +-#endif /*_mem_mmap_anon || _mem_mmap_zero*/ ++#endif /*_mem_mmap_anon*/ + + /* + * hint at "transparent huge pages" (=largepages) if +@@ -259,73 +257,6 @@ static Void_t* mmapanonmem(Vmalloc_t* vm + } + #endif /* _mem_mmap_anon */ + +-#if _mem_mmap_zero /* get space by mmapping from /dev/zero */ +-#include +-#ifndef OPEN_MAX +-#define OPEN_MAX 64 +-#endif +-#define FD_PRIVATE (3*OPEN_MAX/4) /* private file descriptor */ +-#define FD_NONE (-2) /* no mapping with file desc */ +- +-/* this is called after an initial successful call of mmapzeromeminit() */ +-static Void_t* mmapzeromem(Vmalloc_t* vm, Void_t* caddr, size_t csize, size_t nsize, Vmdisc_t* disc) +-{ +- Memdisc_t* mmdc = (Memdisc_t*)disc; +- off_t offset; +- +- GETMEMCHK(vm, caddr, csize, nsize, disc); +- if(csize == 0) +- { nsize = ROUND(nsize, _Vmpagesize); +- offset = asoaddoff(&mmdc->offset, nsize); +- RESTARTMEM(caddr, mmap(NIL(Void_t*), nsize, PROT_READ|PROT_WRITE, MAP_PRIVATE, mmdc->fd, offset)); +- ADVISE(vm, caddr, nsize); +- RETURN(vm, caddr, nsize); +- } +- else if(nsize == 0) +- { Vmuchar_t *addr = (Vmuchar_t*)sbrk(0); +- if(addr < (Vmuchar_t*)caddr ) /* in sbrk space */ +- return NIL(Void_t*); +- (void)munmap(caddr, csize); +- RETURN(vm, caddr, nsize); +- } +- else return NIL(Void_t*); +-} +- +-/* if this call succeeds then mmapzeromem() is the implementation */ +-static Void_t* mmapzeromeminit(Vmalloc_t* vm, Void_t* caddr, size_t csize, size_t nsize, Vmdisc_t* disc) +-{ +- Memdisc_t* mmdc = (Memdisc_t*)disc; +- int fd; +- +- GETMEMCHK(vm, caddr, csize, nsize, disc); +- if(mmdc->fd != FD_INIT) +- return NIL(Void_t*); +- RESTARTSYS(fd, open("/dev/zero", O_RDONLY|O_CLOEXEC)); +- if(fd < 0) +- { mmdc->fd = FD_NONE; +- return NIL(Void_t*); +- } +-#if O_CLOEXEC == 0 +- else +- SETCLOEXEC(fd); +-#endif +- if(fd >= FD_PRIVATE || (mmdc->fd = fcntl(fd, F_DUPFD_CLOEXEC, FD_PRIVATE)) < 0) +- mmdc->fd = fd; +- else +- { close(fd); +-#if F_DUPFD_CLOEXEC == F_DUPFD +- SETCLOEXEC(mmdc->fd); +-#endif +- } +- RESTARTMEM(caddr, mmapzeromem(vm, caddr, csize, nsize, disc)); +- if(!caddr) +- { close(mmdc->fd); +- mmdc->fd = FD_NONE; +- } +- RETURN(vm, caddr, nsize); +-} +-#endif /* _mem_mmap_zero */ +- + #if _std_malloc /* using native malloc as a last resort */ + static Void_t* mallocmem(Vmalloc_t* vm, Void_t* caddr, size_t csize, size_t nsize, Vmdisc_t* disc) + { +@@ -364,12 +295,6 @@ static Void_t* getmemory(Vmalloc_t* vm, + return (Void_t*)addr; + } + #endif +-#if _mem_mmap_zero +- if((_Vmassert & VM_zero) && (addr = mmapzeromeminit(vm, caddr, csize, nsize, disc))) +- { GETMEMUSE(mmapzeromem, disc); +- return (Void_t*)addr; +- } +-#endif + #if _mem_sbrk + if((_Vmassert & VM_break) && (addr = sbrkmem(vm, caddr, csize, nsize, disc))) + { GETMEMUSE(sbrkmem, disc); +@@ -386,6 +311,7 @@ static Void_t* getmemory(Vmalloc_t* vm, + if((_Vmassert & VM_native) && (addr = mallocmem(vm, caddr, csize, nsize, disc))) + { GETMEMUSE(mallocmem, disc); + return (Void_t*)addr; ++ } + #endif + write(2, "vmalloc: panic: all memory allocation disciplines failed\n", 57); + abort(); Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmdebug.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmdebug.c @@ -0,0 +1,29 @@ +--- src/lib/libast/vmalloc/vmdebug.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmdebug.c +@@ -335,7 +335,7 @@ int local; + if(vm->data->mode&VM_DBCHECK) + vmdbcheck(vm); + +- sz = ROUND(size,ALIGN) + DB_EXTRA; ++ sz = ROUND(size,MEM_ALIGN) + DB_EXTRA; + sz = sz >= sizeof(Body_t) ? sz : sizeof(Body_t); + if(!(data = (Vmuchar_t*)KPVALLOC(vm, sz, (*(Vmbest->allocf))) ) ) + { dbwarn(vm, NIL(Vmuchar_t*), DB_ALLOC, file, line, func, DB_ALLOC); +@@ -483,7 +483,7 @@ int local; + oldline = DBLINE(addr); + + /* do the resize */ +- sz = ROUND(size,ALIGN) + DB_EXTRA; ++ sz = ROUND(size,MEM_ALIGN) + DB_EXTRA; + sz = sz >= sizeof(Body_t) ? sz : sizeof(Body_t); + data = (Vmuchar_t*)KPVRESIZE(vm, (Void_t*)data, sz, (type&~VM_RSZERO), (*(Vmbest->resizef)) ); + if(!data) /* failed, reset data for old block */ +@@ -632,7 +632,7 @@ int local; + + asolock(&vm->data->dlck, KEY_DEBUG, ASO_LOCK); + +- if((sz = ROUND(size,ALIGN) + DB_EXTRA) < sizeof(Body_t)) ++ if((sz = ROUND(size,MEM_ALIGN) + DB_EXTRA) < sizeof(Body_t)) + sz = sizeof(Body_t); + + if((data = (Vmuchar_t*)KPVALIGN(vm, sz, align, (*(Vmbest->alignf)))) ) Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmhdr.h =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmhdr.h @@ -0,0 +1,86 @@ +--- src/lib/libast/vmalloc/vmhdr.h.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmhdr.h +@@ -86,7 +86,7 @@ + #if defined(_WIN32) + #define _mem_win32 1 /* use the VirtualAlloc interface */ + #endif +-#if !_mem_win32 && !_mem_sbrk && !_mem_mmap_anon && !_mem_mmap_zero ++#if !_mem_win32 && !_mem_sbrk && !_mem_mmap_anon + #undef _std_malloc + #define _std_malloc 1 /* use native malloc/free/realloc */ + #endif +@@ -160,11 +160,11 @@ extern void _vmmessage _ARG_((const cha + (ABORT() ? (abort(),0) : PAUSE() ? (pause(),0) : 0)) ) + #define COUNT(n) ((n) += 1) + #define ACCOUNT(a,b) ((a) += (b)) +-#define INITMEMORY(m,z) ((m) ? (memset((m), 'i', (z) > 2*ALIGN ? 2*ALIGN : (z)), 0) : 0 ) +-#define SETBUSYMEM(m,z) (memset(((char*)(m))+2*ALIGN, 'b', (z) <= 2*ALIGN ? 0 : ALIGN ) ) +-#define CHKBUSYMEM(m,z) (memcmp(((char*)(m))+2*ALIGN, "bbbbbbbb", (z) <= 2*ALIGN ? 0 : 8) == 0 ? 1 : 0 ) +-#define SETFREEMEM(m,z) (memset(((char*)(m))+2*ALIGN, 'f', (z) <= 2*ALIGN ? 0 : ALIGN ) ) +-#define CHKFREEMEM(m,z) (memcmp(((char*)(m))+2*ALIGN, "ffffffff", (z) <= 2*ALIGN ? 0 : 8) == 0 ? 1 : 0 ) ++#define INITMEMORY(m,z) ((m) ? (memset((m), 'i', (z) > 2*MEM_ALIGN ? 2*MEM_ALIGN : (z)), 0) : 0 ) ++#define SETBUSYMEM(m,z) (memset(((char*)(m))+2*MEM_ALIGN, 'b', (z) <= 2*MEM_ALIGN ? 0 : MEM_ALIGN ) ) ++#define CHKBUSYMEM(m,z) (memcmp(((char*)(m))+2*MEM_ALIGN, "bbbbbbbb", (z) <= 2*MEM_ALIGN ? 0 : 8) == 0 ? 1 : 0 ) ++#define SETFREEMEM(m,z) (memset(((char*)(m))+2*MEM_ALIGN, 'f', (z) <= 2*MEM_ALIGN ? 0 : MEM_ALIGN ) ) ++#define CHKFREEMEM(m,z) (memcmp(((char*)(m))+2*MEM_ALIGN, "ffffffff", (z) <= 2*MEM_ALIGN ? 0 : 8) == 0 ? 1 : 0 ) + #define DEBUGDECL(_ty_,_ob_) _ty_ _ob_; + #else + #define ABORT() (0) +@@ -203,7 +203,7 @@ extern void _vmmessage _ARG_((const cha + #define BITS (BUSY|PFREE|SMALL|MARK) + #define ALIGNB (BITS+1) /* to guarantee blksize == 0%(BITS+1) */ + +-/* ALIGN is chosen for three conditions: ++/* MEM_ALIGN is chosen for three conditions: + ** 1. Able to address all primitive types. + ** 2. A multiple of ALIGNB==(BITS+1) as discussed above. + ** 3. Large enough to cover two pointers. Note that on some machines +@@ -238,9 +238,9 @@ struct _two_s + void* two; + }; + #define ALIGNA (sizeof(struct _a_s) - sizeof(union _align_u)) +-#undef ALIGN /* Blocks will be aligned on both ALIGNA & ALIGNB */ ++#undef MEM_ALIGN /* Blocks will be aligned on both ALIGNA & ALIGNB */ + #define ALIGNAB MULTIPLE(ALIGNA,ALIGNB) +-#define ALIGN MULTIPLE(ALIGNAB, sizeof(struct _two_s)) ++#define MEM_ALIGN MULTIPLE(ALIGNAB, sizeof(struct _two_s)) + + typedef union _word_u + { size_t size; /* to store a size_t */ +@@ -252,7 +252,7 @@ struct _head_s /* a block header has two + { Word_t one; + Word_t two; + }; +-#define HEADSIZE ROUND(sizeof(struct _head_s), ALIGN) ++#define HEADSIZE ROUND(sizeof(struct _head_s), MEM_ALIGN) + union _head_u + { Vmuchar_t data[HEADSIZE]; /* to standardize size */ + struct _head_s head; +@@ -264,15 +264,15 @@ struct _body_s /* Note that self is actu + Block_t* left; /* left child in free tree */ + Block_t** self; /* self pointer when free */ + }; +-#define BODYSIZE ROUND(sizeof(struct _body_s), ALIGN) ++#define BODYSIZE ROUND(sizeof(struct _body_s), MEM_ALIGN) + union _body_u + { Vmuchar_t data[BODYSIZE]; /* to standardize size */ + struct _body_s body; + }; + + /* After all the songs and dances, we should now have: +-** sizeof(Head_t)%ALIGN == 0 +-** sizeof(Body_t)%ALIGN == 0 ++** sizeof(Head_t)%MEM_ALIGN == 0 ++** sizeof(Body_t)%MEM_ALIGN == 0 + ** and sizeof(Block_t) = sizeof(Head_t)+sizeof(Body_t) + */ + struct _block_s +@@ -321,7 +321,7 @@ struct _block_s + #define ENDB(sgb) ((Block_t*)((Vmuchar_t*)NEXT(sgb) - sizeof(Head_t)) ) + + /* the start of allocatable memory in a segment */ +-#define SEGDATA(sg) ((Vmuchar_t*)(sg) + ROUND(sizeof(Seg_t),ALIGN) ) ++#define SEGDATA(sg) ((Vmuchar_t*)(sg) + ROUND(sizeof(Seg_t),MEM_ALIGN) ) + + /* testing to see if "sg" is the root segment of a region */ + #define SEGROOT(sg) ((Vmuchar_t*)(sg)->vmdt >= (sg)->base && \ Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmlast.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmlast.c @@ -0,0 +1,40 @@ +--- src/lib/libast/vmalloc/vmlast.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmlast.c +@@ -61,7 +61,7 @@ int local; + + LASTLOCK(last, local); + +- size = size < ALIGN ? ALIGN : ROUND(size,ALIGN); ++ size = size < MEM_ALIGN ? MEM_ALIGN : ROUND(size,MEM_ALIGN); + + last->last = NIL(Vmuchar_t*); /* wipe record of last allocation */ + +@@ -119,7 +119,7 @@ int local; + if(data != (Void_t*)last->last ) + data = NIL(Void_t*); + else +- { size = last->data - last->last; /**/DEBUG_ASSERT(size > 0 && size%ALIGN == 0); ++ { size = last->data - last->last; /**/DEBUG_ASSERT(size > 0 && size%MEM_ALIGN == 0); + last->data -= size; + last->size += size; + last->last = NIL(Vmuchar_t*); +@@ -166,8 +166,8 @@ int local; + if(data != (Void_t*)last->last ) + data = NIL(Void_t*); + else +- { oldz = last->data - last->last; /**/DEBUG_ASSERT(oldz > 0 && oldz%ALIGN == 0); +- size = ROUND(size, ALIGN); ++ { oldz = last->data - last->last; /**/DEBUG_ASSERT(oldz > 0 && oldz%MEM_ALIGN == 0); ++ size = ROUND(size, MEM_ALIGN); + if(size <= oldz) /* getting smaller */ + { sz = oldz - size; + last->data -= sz; +@@ -249,7 +249,7 @@ int local; + + LASTLOCK(last, local); + +- size = ROUND(size,ALIGN); ++ size = ROUND(size,MEM_ALIGN); + align = (*_Vmlcm)(align, 2*sizeof(Block_t)); + + if((data = (Vmuchar_t*)KPVALLOC(vm, size + align, lastalloc)) ) Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmmaddress.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmmaddress.c @@ -0,0 +1,11 @@ +--- src/lib/libast/vmalloc/vmmaddress.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmmaddress.c +@@ -96,7 +96,7 @@ ssize_t _vmpagesize(void) + if ((_Vmpagesize = getpagesize()) <= 0) + #endif + _Vmpagesize = VM_PAGESIZE; +- _Vmpagesize = (*_Vmlcm)(_Vmpagesize, ALIGN); ++ _Vmpagesize = (*_Vmlcm)(_Vmpagesize, MEM_ALIGN); + } + #if VMCHKMEM + _Vmchkmem = _vmchkmem; /* _vmchkmem() can check memory availability */ Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmopen.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmopen.c @@ -0,0 +1,61 @@ +--- src/lib/libast/vmalloc/vmopen.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmopen.c +@@ -97,10 +97,10 @@ int mode; /* type of region */ + write(9, "vmalloc: panic: heap initialization error #2\n", 45); + return NIL(Vmalloc_t*); + } +- /**/DEBUG_ASSERT(VMLONG(vd)%ALIGN == 0); ++ /**/DEBUG_ASSERT(VMLONG(vd)%MEM_ALIGN == 0); + + if(vd->mode & VM_MEMORYF) /* point addr to Vmalloc_t */ +- addr -= ROUND(sizeof(Vmalloc_t), ALIGN); ++ addr -= ROUND(sizeof(Vmalloc_t), MEM_ALIGN); + } + } + +@@ -110,7 +110,7 @@ int mode; /* type of region */ + incr = disc->round <= 0 ? _Vmpagesize : ROUND(disc->round, _Vmpagesize); + + /* size of Vmalloc_t if embedded in the same initial segment */ +- vmsz = (mode&VM_MEMORYF) ? ROUND(sizeof(Vmalloc_t),ALIGN) : 0; ++ vmsz = (mode&VM_MEMORYF) ? ROUND(sizeof(Vmalloc_t),MEM_ALIGN) : 0; + + vdsz = 0; /* get actual size of Vmdata_t including method specific data */ + if(!meth->eventf || (*meth->eventf)(vmp, VM_OPEN, &vdsz) < 0 || vdsz <= 0 ) +@@ -118,13 +118,13 @@ int mode; /* type of region */ + write(9, "vmalloc: panic: heap initialization error #3\n", 45); + return NIL(Vmalloc_t*); + } +- vdsz = ROUND(vdsz, ALIGN); ++ vdsz = ROUND(vdsz, MEM_ALIGN); + +- sgsz = ROUND(sizeof(Seg_t), ALIGN); /* size of segment structure */ ++ sgsz = ROUND(sizeof(Seg_t), MEM_ALIGN); /* size of segment structure */ + + /* get initial memory segment containing Vmdata_t, Seg_t and some extra */ + size = vmsz + vdsz + sgsz + 8*_Vmpagesize; +- size = ROUND(size,incr); /**/DEBUG_ASSERT(size%ALIGN == 0 ); ++ size = ROUND(size,incr); /**/DEBUG_ASSERT(size%MEM_ALIGN == 0 ); + if(!(base = (Vmuchar_t*)(*disc->memoryf)(vmp, NIL(Void_t*), 0, size, disc)) ) + { if(initheap) + write(9, "vmalloc: panic: heap initialization error #4\n", 45); +@@ -136,14 +136,14 @@ int mode; /* type of region */ + memset(base, 0, vmsz + vdsz + sgsz); + + /* make sure memory is properly aligned */ +- if((algn = (ssize_t)(VMLONG(base)%ALIGN)) == 0 ) ++ if((algn = (ssize_t)(VMLONG(base)%MEM_ALIGN)) == 0 ) + addr = base; +- else addr = base + (ALIGN-algn); +- /**/DEBUG_ASSERT(VMLONG(addr)%ALIGN == 0 ); ++ else addr = base + (MEM_ALIGN-algn); ++ /**/DEBUG_ASSERT(VMLONG(addr)%MEM_ALIGN == 0 ); + + /* addresses of Vmdata_t and root segment */ +- vd = (Vmdata_t*)(addr + vmsz); /**/DEBUG_ASSERT(VMLONG(vd)%ALIGN == 0); +- seg = (Seg_t*)(addr + vmsz + vdsz); /**/DEBUG_ASSERT(VMLONG(seg)%ALIGN == 0); ++ vd = (Vmdata_t*)(addr + vmsz); /**/DEBUG_ASSERT(VMLONG(vd)%MEM_ALIGN == 0); ++ seg = (Seg_t*)(addr + vmsz + vdsz); /**/DEBUG_ASSERT(VMLONG(seg)%MEM_ALIGN == 0); + + /* set Vmdata_t data */ + vd->mode = mode; Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmpool.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmpool.c @@ -0,0 +1,20 @@ +--- src/lib/libast/vmalloc/vmpool.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmpool.c +@@ -47,7 +47,7 @@ typedef struct _vmpool_s + Pool_t* free; /* list of free blocks */ + } Vmpool_t; + +-#define POOLSIZE(sz) ROUND(ROUND((sz), sizeof(Pool_t)), ALIGN) ++#define POOLSIZE(sz) ROUND(ROUND((sz), sizeof(Pool_t)), MEM_ALIGN) + + #ifdef DEBUG + static int N_pool; /* counter for Vmpool calls */ +@@ -206,7 +206,7 @@ static int poolstat(Vmalloc_t* vm, Vmsta + if(pool->size <= 0 ) + return -1; + +- size = ROUND(pool->size, ALIGN); ++ size = ROUND(pool->size, MEM_ALIGN); + + for(pl = pool->free; pl; pl = pl->next ) + st->n_free += 1; Index: shells/ksh93/files/patch-src_lib_libast_vmalloc_vmsegment.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libast_vmalloc_vmsegment.c @@ -0,0 +1,32 @@ +--- src/lib/libast/vmalloc/vmsegment.c.orig 2016-02-28 17:09:23 UTC ++++ src/lib/libast/vmalloc/vmsegment.c +@@ -194,7 +194,7 @@ static Block_t* _vmseginit(Vmdata_t* vmd + + /* available memory in Seg_t for allocation usage */ + size = (base+size) - SEGDATA(seg); +- size = (size/ALIGN)*ALIGN; /* must be multiple of ALIGN's */ ++ size = (size/MEM_ALIGN)*MEM_ALIGN; /* must be multiple of MEM_ALIGN's */ + + /* block at start of memory */ + seg->begb = (Block_t*)SEGDATA(seg); +@@ -256,7 +256,7 @@ static Block_t* _vmsegalloc(Vmalloc_t* v + static size_t Segunit = 0; + /**/DEBUG_COUNT(N_segalloc); + /**/DEBUG_ASSERT(!blk || (isblock(vmdt, blk) && (SIZE(blk)&BUSY) ) ); +- /**/DEBUG_ASSERT(_Vmpagesize > 0 && _Vmpagesize%ALIGN == 0 ); ++ /**/DEBUG_ASSERT(_Vmpagesize > 0 && _Vmpagesize%MEM_ALIGN == 0 ); + + /* transition to a fixed place to unlock before returning */ + #undef RETURN +@@ -381,9 +381,9 @@ static Block_t* _vmsegalloc(Vmalloc_t* v + } + + /* segment must start at an aligned address */ +- if((sz = (size_t)(VMLONG(base)%ALIGN)) == 0) ++ if((sz = (size_t)(VMLONG(base)%MEM_ALIGN)) == 0) + seg = (Seg_t*)base; +- else seg = (Seg_t*)(base + ALIGN-sz); ++ else seg = (Seg_t*)(base + MEM_ALIGN-sz); + blk = _vmseginit(vmdt, seg, base, segsz, 0); + } + Index: shells/ksh93/files/patch-src_lib_libcmd_ls.c =================================================================== --- /dev/null +++ shells/ksh93/files/patch-src_lib_libcmd_ls.c @@ -0,0 +1,32 @@ +--- src/lib/libcmd/ls.c.orig 2017-11-30 22:35:04 UTC ++++ src/lib/libcmd/ls.c +@@ -1257,7 +1257,7 @@ ls(State_t* state, register FTSENT* ent) + if (!VISIBLE(state, ent)) + { + fts_set(NiL, ent, FTS_SKIP); +- return; ++ return 0; + } + switch (ent->fts_info) + { +@@ -1265,17 +1265,17 @@ ls(State_t* state, register FTSENT* ent) + if (ent->fts_parent->fts_info == FTS_DNX) + break; + error(2, "%s: not found", ent->fts_path); +- return; ++ return 1; + case FTS_DC: + if (state->lsflags & LS_DIRECTORY) + break; + error(2, "%s: directory causes cycle", ent->fts_path); +- return; ++ return 1; + case FTS_DNR: + if (state->lsflags & LS_DIRECTORY) + break; + error(2, "%s: cannot read directory", ent->fts_path); +- return 0; ++ return 1; + case FTS_DOT: + #if 0 + fts_set(NiL, ent, FTS_SKIP);