diff --git a/bin/package b/bin/package index 06871bf76..9ab80eff3 100755 --- a/bin/package +++ b/bin/package @@ -682,64 +682,6 @@ use) case $1 in 32|64) bit=$1 ;; esac shift - - # HOSTTYPE specific setup - - case $HOSTTYPE in - win32.*)sys=uwin - wow=$(uname -i) - case $bit in - 32) case $HOSTTYPE in - *-64) HOSTTYPE=${HOSTTYPE%-64} ;; - esac - ;; - 64) case $HOSTTYPE in - *-64) ;; - *) HOSTTYPE=$HOSTTYPE-64 ;; - esac - case $wow in - */32) err_out "cannot build $bit-bit on $wow $sys" ;; - esac - ;; - esac - case $bit in - '') PS1="($sys) " ;; - *) PS1="($sys-$bit) " ;; - esac - - $exec umask 002 - $exec unset MAKESKIP - - P=$PWD - A=$P/arch/$HOSTTYPE - - $exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package - $exec export INSTALLROOT=$A - $exec export PACKAGEROOT=$P - $exec export PATH=$A/bin:$P/bin:$PATH - $exec export PS1="$PS1" - $exec export VPATH=$A:$P - $exec export nativepp=/usr/lib - - if test -n "$INSTALLROOT" && test -d "$INSTALLROOT/include/ast" - then $exec export PACKAGE_ast=$INSTALLROOT - elif test -d ${PWD%/*}/ast/arch/$HOSTTYPE - then $exec export PACKAGE_ast=${PWD%/*}/ast/arch/$HOSTTYPE - fi - - # run the command - - case $# in - 0) case $show in - ':') $exec exec $SHELL ;; - esac - ;; - *) $exec exec $SHELL -c "$@" - ;; - esac - exit - ;; - esac PACKAGEROOT=$PWD $show export PACKAGEROOT esac diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index 06871bf76..9ab80eff3 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -682,64 +682,6 @@ use) case $1 in 32|64) bit=$1 ;; esac shift - - # HOSTTYPE specific setup - - case $HOSTTYPE in - win32.*)sys=uwin - wow=$(uname -i) - case $bit in - 32) case $HOSTTYPE in - *-64) HOSTTYPE=${HOSTTYPE%-64} ;; - esac - ;; - 64) case $HOSTTYPE in - *-64) ;; - *) HOSTTYPE=$HOSTTYPE-64 ;; - esac - case $wow in - */32) err_out "cannot build $bit-bit on $wow $sys" ;; - esac - ;; - esac - case $bit in - '') PS1="($sys) " ;; - *) PS1="($sys-$bit) " ;; - esac - - $exec umask 002 - $exec unset MAKESKIP - - P=$PWD - A=$P/arch/$HOSTTYPE - - $exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package - $exec export INSTALLROOT=$A - $exec export PACKAGEROOT=$P - $exec export PATH=$A/bin:$P/bin:$PATH - $exec export PS1="$PS1" - $exec export VPATH=$A:$P - $exec export nativepp=/usr/lib - - if test -n "$INSTALLROOT" && test -d "$INSTALLROOT/include/ast" - then $exec export PACKAGE_ast=$INSTALLROOT - elif test -d ${PWD%/*}/ast/arch/$HOSTTYPE - then $exec export PACKAGE_ast=${PWD%/*}/ast/arch/$HOSTTYPE - fi - - # run the command - - case $# in - 0) case $show in - ':') $exec exec $SHELL ;; - esac - ;; - *) $exec exec $SHELL -c "$@" - ;; - esac - exit - ;; - esac PACKAGEROOT=$PWD $show export PACKAGEROOT esac diff --git a/src/cmd/INIT/probe.win32 b/src/cmd/INIT/probe.win32 index 2774bb34c..4c449ec2b 100644 --- a/src/cmd/INIT/probe.win32 +++ b/src/cmd/INIT/probe.win32 @@ -37,9 +37,6 @@ done for i in $probe_header do echo "#include <$i>" done -echo '#ifdef _UWIN' -echo "int _Pr0b3_uwin=_UWIN;" -echo '#endif' echo '#ifdef __BORLANDC__' echo "int _Pr0b3_version_BORLAND=__BORLANDC__;" echo '#endif' @@ -67,7 +64,6 @@ echo '#endif' } > easy.c include= -uwin= $cc -E easy.c 2>&1 | egrep -i '^(#(line)? 1 .*\.[hH]| *int +_Pr0b3_[a-zA-Z_]* *= *[0-9])' | @@ -213,18 +209,10 @@ CC.STATIC = -Bstatic then stdlib="$stdlib $d" fi done - case $uwin in - [0-9]*) cat </dev/null 2>&1 || true done libast.a generated done ast virtual diff --git a/src/lib/libast/aso/aso-fcntl.c b/src/lib/libast/aso/aso-fcntl.c index 2fe9cb669..8a165566b 100644 --- a/src/lib/libast/aso/aso-fcntl.c +++ b/src/lib/libast/aso/aso-fcntl.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,7 +23,7 @@ #include "asohdr.h" -#if defined(_UWIN) && defined(_BLD_ast) || !_aso_fcntl +#if !_aso_fcntl NoN(aso_meth_fcntl) diff --git a/src/lib/libast/aso/aso-sem.c b/src/lib/libast/aso/aso-sem.c index aabe7b69b..779be49a0 100644 --- a/src/lib/libast/aso/aso-sem.c +++ b/src/lib/libast/aso/aso-sem.c @@ -23,7 +23,7 @@ #include "asohdr.h" -#if defined(_UWIN) && defined(_BLD_ast) || !_aso_semaphore +#if !_aso_semaphore NoN(aso_meth_semaphore) diff --git a/src/lib/libast/aso/aso.c b/src/lib/libast/aso/aso.c index 0fc95568f..b47885ed0 100644 --- a/src/lib/libast/aso/aso.c +++ b/src/lib/libast/aso/aso.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -24,12 +24,6 @@ #include "asohdr.h" #include "FEATURE/aso" -#if defined(_UWIN) && defined(_BLD_ast) - -NoN(aso) - -#else - /* * AST atomic scalar operations * AT&T Research @@ -45,20 +39,12 @@ NoN(aso) #if !_PACKAGE_ast -#if _UWIN - -extern ssize_t sfsprintf(char*, size_t, const char*, ...); - -#else - #include #define sfsprintf snprintf #endif -#endif - #if defined(_aso_casptr) && (defined(_aso_cas32) || defined(_aso_cas64)) #define ASO_METHOD (&_aso_meth_intrinsic) #define ASO_LOCKF 0 @@ -863,5 +849,3 @@ asocasptr(void volatile* p, void* o, void* n) lock(state.data, k, p); return o; } - -#endif diff --git a/src/lib/libast/aso/asohdr.h b/src/lib/libast/aso/asohdr.h index 4804da076..a1e319fe6 100644 --- a/src/lib/libast/aso/asohdr.h +++ b/src/lib/libast/aso/asohdr.h @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -56,11 +56,6 @@ #include "FEATURE/asometh" -#if _UWIN -#undef _aso_fcntl -#undef _aso_semaphore -#endif - #include "aso.h" #define HASH(p,z) ((integralof(p)*FNV_MULT)%(z)) diff --git a/src/lib/libast/aso/asolock.c b/src/lib/libast/aso/asolock.c index 7ac2ff32c..326e07f9d 100644 --- a/src/lib/libast/aso/asolock.c +++ b/src/lib/libast/aso/asolock.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,12 +23,6 @@ #include "asohdr.h" -#if defined(_UWIN) && defined(_BLD_ast) - -NoN(asolock) - -#else - int asolock(unsigned int volatile* lock, unsigned int key, int type) { @@ -51,5 +45,3 @@ asolock(unsigned int volatile* lock, unsigned int key, int type) } return -1; } - -#endif diff --git a/src/lib/libast/aso/asometh.c b/src/lib/libast/aso/asometh.c index 222a9e691..dc5c286d9 100644 --- a/src/lib/libast/aso/asometh.c +++ b/src/lib/libast/aso/asometh.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,12 +23,6 @@ #include "asohdr.h" -#if defined(_UWIN) && defined(_BLD_ast) - -NoN(asometh) - -#else - /* * this is the default user visible asometh() * -ltaso intercepts asometh() to prepend ASO_THREAD methods @@ -39,5 +33,3 @@ asometh(int type, void* data) { return _asometh(type, data); } - -#endif diff --git a/src/lib/libast/aso/asorelax.c b/src/lib/libast/aso/asorelax.c index 0fdf5f56b..83a7fcc3a 100644 --- a/src/lib/libast/aso/asorelax.c +++ b/src/lib/libast/aso/asorelax.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,12 +23,6 @@ #include "asohdr.h" -#if defined(_UWIN) && defined(_BLD_ast) - -NoN(asorelax) - -#else - #if _PACKAGE_ast #include #else @@ -52,5 +46,3 @@ asorelax(long nsec) return nanosleep(&ts, 0); #endif } - -#endif diff --git a/src/lib/libast/cdt/dttree.c b/src/lib/libast/cdt/dttree.c index 74dc1b2f9..679a57ca9 100644 --- a/src/lib/libast/cdt/dttree.c +++ b/src/lib/libast/cdt/dttree.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -636,15 +636,6 @@ static int treeevent(Dt_t* dt, int event, void* arg) else return 0; } -#if _UWIN - -void* dtfinger(Dt_t* dt) -{ - return (dt && dt->meth && (dt->meth->type & DT_ORDERED)) ? (void*)((Dttree_t*)dt->data)->root : NIL(void*); -} - -#endif - /* make this method available */ static Dtmethod_t _Dtoset = { dttree, DT_OSET, treeevent, "Dtoset" }; static Dtmethod_t _Dtobag = { dttree, DT_OBAG, treeevent, "Dtobag" }; diff --git a/src/lib/libast/comp/hsearch.c b/src/lib/libast/comp/hsearch.c deleted file mode 100644 index 2ad6466b5..000000000 --- a/src/lib/libast/comp/hsearch.c +++ /dev/null @@ -1,121 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -/* - * hsearch() for systems that have but no hsearch() - * why would such a system provide the interface but not the - * implementation? that's what happens when one slimes their - * way through standards compliance - * - * NOTE: please excuse the crude feature test - */ - -#if !_UWIN - -void _STUB_hsearch(){} - -#else - -#if _PACKAGE_ast -#include -#endif - -#define hcreate ______hcreate -#define hdestroy ______hdestroy -#define hsearch ______hsearch - -#include - -#undef hcreate -#undef hdestroy -#undef hsearch - -#include "dthdr.h" - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -/* POSIX hsearch library based on libdt -** Written by Kiem-Phong Vo (AT&T Research, 07/19/95) -*/ - -/* type of objects in hash table */ -typedef struct _hash_s -{ Dtlink_t link; - ENTRY item; -} Hash_t; - -/* object delete function */ -static void hashfree(Dt_t* dt, void* obj, Dtdisc_t* disc) -{ - free(((Hash_t*)obj)->item.key); - free(obj); -} - -static Dt_t* Hashtab; /* object dictionary */ -static Dtdisc_t Hashdisc = /* discipline */ -{ sizeof(Dtlink_t), -1, - 0, - NIL(Dtmake_f), hashfree, - NIL(Dtcompar_f), /* always use strcmp */ - NIL(Dthash_f), - NIL(Dtmemory_f), - NIL(Dtevent_f) -}; - -extern -int hcreate(size_t nel) -{ - if(Hashtab) /* already opened */ - return 0; - - if(!(Hashtab = dtopen(&Hashdisc,Dtset)) ) - return 0; - - return 1; -} - -extern void hdestroy() -{ if(Hashtab) - dtclose(Hashtab); - Hashtab = NIL(Dt_t*); -} - -extern -ENTRY* hsearch(ENTRY item, ACTION action) -{ - reg Hash_t* o; - - if(!Hashtab) - return NIL(ENTRY*); - - if(!(o = (Hash_t*)dtmatch(Hashtab,item.key)) && action == ENTER && - (o = (Hash_t*)malloc(sizeof(Hash_t)) ) ) - { o->item = item; - o = (Hash_t*)dtinsert(Hashtab,o); - } - - return o ? &(o->item) : NIL(ENTRY*); -} - -#endif diff --git a/src/lib/libast/comp/iconv.c b/src/lib/libast/comp/iconv.c index e01aa7426..f2871925e 100644 --- a/src/lib/libast/comp/iconv.c +++ b/src/lib/libast/comp/iconv.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -144,263 +144,6 @@ static const _ast_iconv_list_t codes[] = { 0 }, }; -#if _UWIN - -#include - -#ifndef CP_UCS2 -#define CP_UCS2 0x0000 -#endif - -static char _win_maps[] = "/reg/local_machine/SOFTWARE/Classes/MIME/Database/Charset"; - -/* - * return the codeset index given its name or alias - * the map is in the what? oh, the registry - */ - -static int -_win_codeset(const char* name) -{ - register char* s; - char* e; - int n; - Sfio_t* sp; - char aka[128]; - char tmp[128]; - -#if DEBUG_TRACE -error(DEBUG_TRACE, "AHA#%d _win_codeset name=%s", __LINE__, name); -#endif - if (name == name_native) - return CP_ACP; - if (!strcasecmp(name, "utf") || !strcasecmp(name, "utf8") || !strcasecmp(name, "utf-8")) - return CP_UTF8; - if (!strcasecmp(name, "ucs") || !strcasecmp(name, "ucs2") || !strcasecmp(name, "ucs-2")) - return CP_UCS2; - if (name[0] == '0' && name[1] == 'x' && (n = strtol(name, &e, 0)) > 0 && !*e) - return n; - for (;;) - { - sfsprintf(tmp, sizeof(tmp), "%s/%s", _win_maps, name); - if (!(sp = sfopen(0, tmp, "r"))) - { - s = (char*)name; - if ((s[0] == 'c' || s[0] == 'C') && (s[1] == 'p' || s[1] == 'P')) - s += 2; - if (!isdigit(s[0])) - break; - sfsprintf(tmp, sizeof(tmp), "%s/windows-%s", _win_maps, s); - if (!(sp = sfopen(0, tmp, "r"))) - break; - } - for (;;) - { - if (!(s = sfgetr(sp, '\n', 0))) - { - sfclose(sp); - return -1; - } - if (!strncasecmp(s, "AliasForCharSet=", 16)) - { - n = sfvalue(sp) - 17; - s += 16; - if (n >= sizeof(aka)) - n = sizeof(aka) - 1; - memcpy(aka, s, n); - aka[n] = 0; - sfclose(sp); - name = (const char*)aka; - break; - } - if (!strncasecmp(s, "CodePage=", 9)) - { - s += 9; - n = strtol(s, 0, 0); - sfclose(sp); - return n; - } - } - } - return -1; -} - -/* - * get and check the codeset indices - */ - -static _ast_iconv_t -_win_iconv_open(register Conv_t* cc, const char* t, const char* f) -{ -#if DEBUG_TRACE -error(DEBUG_TRACE, "AHA#%d _win_iconv_open f=%s t=%s\n", __LINE__, f, t); -#endif - if ((cc->from.index = _win_codeset(f)) < 0) - return (_ast_iconv_t)(-1); - if ((cc->to.index = _win_codeset(t)) < 0) - return (_ast_iconv_t)(-1); -#if DEBUG_TRACE -error(DEBUG_TRACE, "AHA#%d _win_iconv_open f=0x%04x t=0x%04x\n", __LINE__, cc->from.index, cc->to.index); -#endif - return (_ast_iconv_t)cc; -} - -/* - * even though the indices already check out - * they could still be rejected - */ - -static size_t -_win_iconv(_ast_iconv_t cd, char** fb, size_t* fn, char** tb, size_t* tn) -{ - Conv_t* cc = (Conv_t*)cd; - size_t un; - size_t tz; - size_t fz; - size_t bz; - size_t pz; - size_t oz; - LPWSTR ub; - -#if DEBUG_TRACE -error(DEBUG_TRACE, "AHA#%d _win_iconv from=0x%04x to=0x%04x\n", __LINE__, cc->from.index, cc->to.index); -#endif - if (cc->from.index == cc->to.index || cc->from.index != CP_UCS2 && cc->to.index == 0) - { - /* - * easy - */ - - fz = tz = (*fn < *tn) ? *fn : *tn; - memcpy(*tb, *fb, fz); - } - else - { - ub = 0; - un = *fn; - - /* - * from => UCS-2 - */ - - if (cc->to.index == CP_UCS2) - { - if ((tz = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)*fn, (LPWSTR)*tb, *tn)) && tz <= *tn) - { - fz = *fn; - tz *= sizeof(WCHAR); - } - else - { - /* - * target too small - * binary search on input size to make it fit - */ - - oz = 0; - pz = *fn / 2; - fz = *fn - pz; - for (;;) - { - while (!(tz = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)fz, (LPWSTR)*tb, 0))) - if (++fz >= *fn) - goto nope; - tz *= sizeof(WCHAR); - if (tz == *tn) - break; - if (!(pz /= 2)) - { - if (!(fz = oz)) - goto nope; - break; - } - if (tz > *tn) - fz -= pz; - else - { - oz = fz; - fz += pz; - } - } - } - } - else - { - if (cc->from.index == CP_UCS2) - { - un = *fn / sizeof(WCHAR); - ub = (LPWSTR)*fb; - } - else if (!(un = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)*fn, (LPWSTR)*tb, 0))) - goto nope; - else if (!(ub = (LPWSTR)malloc(un * sizeof(WCHAR)))) - goto nope; - else if (!(un = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)*fn, (LPWSTR)ub, un))) - goto nope; - - /* - * UCS-2 => to - */ - - if (tz = WideCharToMultiByte(cc->to.index, 0, (LPCWSTR)ub, un, *tb, *tn, 0, 0)) - fz = *fn; - else - { - /* - * target too small - * binary search on input size to make it fit - */ - - oz = 0; - pz = *fn / 2; - bz = *fn - pz; - for (;;) - { - while (!(fz = MultiByteToWideChar(cc->from.index, 0, (LPCSTR)*fb, (int)bz, (LPWSTR)ub, un))) - if (++bz > *fn) - goto nope; - if (!(tz = WideCharToMultiByte(cc->to.index, 0, (LPCWSTR)ub, fz, *tb, 0, 0, 0))) - goto nope; - if (tz == *tn) - break; - if (!(pz /= 2)) - { - if (!(fz = oz)) - goto nope; - break; - } - if (tz > *tn) - bz -= pz; - else - { - oz = bz; - bz += pz; - } - } - if (!(tz = WideCharToMultiByte(cc->to.index, 0, (LPCWSTR)ub, fz, *tb, tz, 0, 0))) - goto nope; -#if DEBUG_TRACE -error(DEBUG_TRACE, "AHA#%d _win_iconv *fn=%u fz=%u[%u] *tn=%u tz=%u\n", __LINE__, *fn, fz, fz * sizeof(WCHAR), *tn, tz); -#endif - } - if (ub != (LPWSTR)*fb) - free(ub); - } - } - *fb += fz; - *fn -= fz; - *tb += tz; - *tn -= tz; - return fz; - nope: - if (ub && ub != (LPWSTR)*fb) - free(ub); - errno = EINVAL; - return (size_t)(-1); -} - -#endif - /* * return canonical character code set name for m * if b!=0 then canonical name placed in b of size n @@ -1106,10 +849,6 @@ error(DEBUG_TRACE, "AHA#%d _ast_iconv_open f=%s:%s:%d t=%s:%s:%d\n", __LINE__, f #if _lib_iconv_open else if ((cc->cvt = iconv_open(t, f)) != (iconv_t)(-1) || (cc->cvt = iconv_open(to, fr)) != (iconv_t)(-1)) cc->from.fun = (_ast_iconv_f)iconv; -#endif -#if _UWIN - else if ((cc->cvt = _win_iconv_open(cc, t, f)) != (_ast_iconv_t)(-1) || (cc->cvt = _win_iconv_open(cc, to, fr)) != (_ast_iconv_t)(-1)) - cc->from.fun = (_ast_iconv_f)_win_iconv; #endif else { @@ -1556,34 +1295,8 @@ _ast_iconv_move(_ast_iconv_t cd, Sfio_t* ip, Sfio_t* op, size_t n, Iconv_disc_t* _ast_iconv_list_t* _ast_iconv_list(_ast_iconv_list_t* cp) { -#if _UWIN - struct dirent* ent; - - if (!cp) - { - if (!(cp = newof(0, _ast_iconv_list_t, 1, 0))) - return ccmaplist(NiL); - if (!(cp->data = opendir(_win_maps))) - { - free(cp); - return ccmaplist(NiL); - } - } - if (cp->data) - { - if (ent = readdir((DIR*)cp->data)) - { - cp->name = cp->match = cp->desc = (const char*)ent->d_name; - return cp; - } - closedir((DIR*)cp->data); - free(cp); - return ccmaplist(NiL); - } -#else if (!cp) return ccmaplist(NiL); -#endif if (cp->ccode >= 0) return (cp = ccmaplist(cp)) ? cp : (_ast_iconv_list_t*)codes; return (++cp)->name ? cp : (_ast_iconv_list_t*)0; diff --git a/src/lib/libast/comp/memccpy.c b/src/lib/libast/comp/memccpy.c index 0c7f930c9..b1c10b463 100644 --- a/src/lib/libast/comp/memccpy.c +++ b/src/lib/libast/comp/memccpy.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,7 +23,7 @@ #include -#if _lib_memccpy && !_UWIN +#if _lib_memccpy NoN(memccpy) diff --git a/src/lib/libast/comp/putenv.c b/src/lib/libast/comp/putenv.c index 20bac3609..b67510c62 100644 --- a/src/lib/libast/comp/putenv.c +++ b/src/lib/libast/comp/putenv.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,10 +23,6 @@ #define putenv ______putenv -#if _UWIN -#define _STDLIB_H_ 1 -#endif - #include #undef putenv diff --git a/src/lib/libast/comp/setlocale.c b/src/lib/libast/comp/setlocale.c index ff5843a00..8be66ed2c 100644 --- a/src/lib/libast/comp/setlocale.c +++ b/src/lib/libast/comp/setlocale.c @@ -82,103 +82,6 @@ header(void) } } -#if _UWIN - -#include - -#undef _lib_setlocale -#define _lib_setlocale 1 - -#define setlocale(c,l) native_setlocale(c,l) - -extern char* uwin_setlocale(int, const char*); - -/* - * convert locale to native locale name in buf - */ - -static char* -native_locale(const char* locale, char* buf, size_t siz) -{ - Lc_t* lc; - const Lc_attribute_list_t* ap; - int i; - unsigned long lcid; - unsigned long langidx; - unsigned long ctry; - char lbuf[128]; - char cbuf[128]; - - if (locale && *locale) - { - if (!(lc = lcmake(locale))) - return 0; - langidx = lc->language->index; - ctry = 0; - for (ap = lc->attributes; ap; ap = ap->next) - if (ctry = ap->attribute->index) - break; - if (!ctry) - { - for (i = 0; i < elementsof(lc->territory->languages); i++) - if (lc->territory->languages[i] == lc->language) - { - ctry = lc->territory->indices[i]; - break; - } - if (!ctry) - { - if (!langidx) - return 0; - ctry = SUBLANG_DEFAULT; - } - } - lcid = MAKELCID(MAKELANGID(langidx, ctry), SORT_DEFAULT); - } - else - lcid = GetUserDefaultLCID(); - if (GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lbuf, sizeof(lbuf)) <= 0 || - GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, cbuf, sizeof(cbuf)) <= 0) - return 0; - if (lc->charset->ms) - sfsprintf(buf, siz, "%s_%s.%s", lbuf, cbuf, lc->charset->ms); - else - sfsprintf(buf, siz, "%s_%s", lbuf, cbuf); - return buf; -} - -/* - * locale!=0 here - */ - -static char* -native_setlocale(int category, const char* locale) -{ - char* usr; - char* sys; - char buf[256]; - - if (!(usr = native_locale(locale, buf, sizeof(buf)))) - return 0; - - /* - * Win32 doesn't have LC_MESSAGES - */ - - if (category == LC_MESSAGES) - return (char*)locale; - sys = uwin_setlocale(category, usr); - if (ast.locale.set & AST_LC_debug) - sfprintf(sfstderr, "locale uwin %17s %-24s %-24s\n", lc_categories[lcindex(category, 0)].name, usr, sys); - return sys; -} - -#else - -#define native_locale(a,b,c) ((char*)0) - -#endif - /* * LC_COLLATE and LC_CTYPE native support */ @@ -2432,8 +2335,7 @@ default_setlocale(int category, const char* locale) #endif -#if !_UWIN - +/* [2022-07-21]: remove this and _vmkeep? obsolete? */ /* * workaround for Solaris and FreeBSD systems * they call free() with addresses that look like they came from the stack @@ -2454,8 +2356,7 @@ _sys_setlocale(int category, const char* locale) } #define setlocale(a,b) _sys_setlocale(a,b) - -#endif +/* */ /* * set a single AST_LC_* locale category @@ -2796,7 +2697,7 @@ _ast_setlocale(int category, const char* locale) u = 0; if ((s = getenv("LANG")) && *s) { - if (streq(s, local) && (u || (u = native_locale(locale, tmp, sizeof(tmp))))) + if (u && streq(s, local)) s = u; lang = lcmake(s); } @@ -2804,7 +2705,7 @@ _ast_setlocale(int category, const char* locale) lang = 0; if ((s = getenv("LC_ALL")) && *s) { - if (streq(s, local) && (u || (u = native_locale(locale, tmp, sizeof(tmp))))) + if (u && streq(s, local)) s = u; lc_all = lcmake(s); } @@ -2815,7 +2716,7 @@ _ast_setlocale(int category, const char* locale) /* explicitly set by setlocale() */; else if ((s = getenv(lc_categories[i].name)) && *s) { - if (streq(s, local) && (u || (u = native_locale(locale, tmp, sizeof(tmp))))) + if (u && streq(s, local)) s = u; lc_categories[i].prev = lcmake(s); } diff --git a/src/lib/libast/comp/strtoll.c b/src/lib/libast/comp/strtoll.c index 16779e9ea..0e96ecc7e 100644 --- a/src/lib/libast/comp/strtoll.c +++ b/src/lib/libast/comp/strtoll.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -31,14 +31,10 @@ #undef strtoll -#if !_UWIN - #undef _def_map_ast #include -#endif - #define S2I_function strtoll #define S2I_number intmax_t #define S2I_unumber uintmax_t diff --git a/src/lib/libast/comp/strtoull.c b/src/lib/libast/comp/strtoull.c index ee8aa8a86..967fa91e4 100644 --- a/src/lib/libast/comp/strtoull.c +++ b/src/lib/libast/comp/strtoull.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -31,14 +31,10 @@ #undef strtoull -#if !_UWIN - #undef _def_map_ast #include -#endif - #define S2I_function strtoull #define S2I_number intmax_t #define S2I_unumber uintmax_t diff --git a/src/lib/libast/comp/syslog.c b/src/lib/libast/comp/syslog.c index af9c53c0e..4415d411c 100644 --- a/src/lib/libast/comp/syslog.c +++ b/src/lib/libast/comp/syslog.c @@ -43,9 +43,6 @@ Syslog_state_t log = { LOG_USER, -1, 0, ~0 }; static const Namval_t attempt[] = { -#if _UWIN - "/var/log/syslog", 0, -#endif "/dev/log", 0, "var/log/syslog", 0, "lib/syslog/log", 0, @@ -92,161 +89,6 @@ const Namval_t log_severity[] = 0, 0 }; -#if _UWIN - -/* - * open /dev/(fdp|tcp|udp)/HOST/SERVICE for read - */ - -#include -#include -#include -#include -#include -#include - -#if !defined(htons) && !_lib_htons -# define htons(x) (x) -#endif -#if !defined(htonl) && !_lib_htonl -# define htonl(x) (x) -#endif - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001L -#endif - -/* - * convert s to sockaddr_in - * -1 returned on error - */ - -static int -str2inet(register char* s, char* prot, struct sockaddr_in* addr) -{ - register int c; - register int v; - register int n = 0; - unsigned long a = 0; - unsigned short p = 0; - - if (!strncmp(s, "local/", 6)) - { - a = INADDR_LOOPBACK; - n = 4; - s += 6; - } - else if (!isdigit(*s)) - { - struct hostent* hp; - char* e = strchr(s, '/'); - - if (!(e = strchr(s, '/'))) - return -1; - *e = 0; - hp = gethostbyname(s); - *e = '/'; - if (!hp || hp->h_addrtype != AF_INET || hp->h_length > sizeof(struct in_addr)) - return -1; - a = (unsigned long)((struct in_addr*)hp->h_addr)->s_addr; - n = 6; - s = e + 1; - } - for (;;) - { - v = 0; - while ((c = *s++) >= '0' && c <= '9') - v = v * 10 + c - '0'; - if (++n <= 4) - a = (a << 8) | (v & 0xff); - else - { - if (n <= 5) - a = htonl(a); - if (c) - { - struct servent* sp; - - if (!(sp = getservbyname(s - 1, prot))) - return -1; - p = sp->s_port; - } - else - p = htons(v); - break; - } - if (c != '.' && c != '/') - return -1; - } - memset((char*)addr, 0, sizeof(*addr)); - addr->sin_family = AF_INET; - addr->sin_addr.s_addr = a; - addr->sin_port = p; - return 0; -} - -/* - * call this after open fails to see if path is a socket - */ - -int -sockopen(const char* path) -{ - int fd; - struct sockaddr_in addr; - char buf[PATH_MAX]; - - if (pathgetlink(path, buf, sizeof(buf)) <= 0) - { - if (strlen(path) >= sizeof(buf)) - return -1; - strcpy(buf, path); - } -#if LOCAL - { - int ul; - struct sockaddr_un ua; - struct stat st; - - if ((ul = strlen(buf)) < sizeof(ua.sun_path) && !stat(buf, &st) && S_ISSOCK(st.st_mode)) - { - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) - return -1; - ua.sun_family = AF_UNIX; - strcpy(ua.sun_path, buf); - ul += sizeof(ua.sun_family) + 1; - if (!connect(fd, (struct sockaddr*)&ua, ul)) - return fd; - close(fd); - return -1; - } - } -#endif - if (!strmatch(buf, "/dev/(tcp|udp)/*/*")) - return -1; - buf[8] = 0; - if (str2inet(buf + 9, buf + 5, &addr)) - return -1; - if ((fd = socket(AF_INET, buf[5] == 't' ? SOCK_STREAM : SOCK_DGRAM, 0)) < 0) - return -1; - if (connect(fd, (struct sockaddr*)&addr, sizeof(addr))) - { - close(fd); - return -1; - } - return fd; -} - -#else - -int -sockopen(const char* path) -{ - return -1; -} - -#endif - void sendlog(const char* msg) { @@ -268,7 +110,7 @@ sendlog(const char* msg) continue; if (*(s = p->name) != '/' && !(s = pathpath(buf, s, "", PATH_REGULAR|PATH_READ, sizeof(buf)))) continue; - if ((log.fd = open(s, O_WRONLY|O_APPEND|O_NOCTTY|O_cloexec)) < 0 && (log.fd = sockopen(s)) < 0) + if ((log.fd = open(s, O_WRONLY|O_APPEND|O_NOCTTY|O_cloexec)) < 0) continue; #if !O_cloexec fcntl(log.fd, F_SETFD, FD_CLOEXEC); diff --git a/src/lib/libast/comp/tsearch.c b/src/lib/libast/comp/tsearch.c deleted file mode 100644 index 26be79352..000000000 --- a/src/lib/libast/comp/tsearch.c +++ /dev/null @@ -1,199 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -/* - * tsearch() for systems that have but no tsearch() - * why would such a system provide the interface but not the - * implementation? that's what happens when one slimes their - * way through standards compliance - * - * NOTE: please excuse the crude feature test - */ - -#if !_UWIN - -void _STUB_tsearch(){} - -#else - -#if _PACKAGE_ast -#include -#endif - -#define tdelete ______tdelete -#define tfind ______tfind -#define tsearch ______tsearch -#define twalk ______twalk - -#include - -#undef tdelete -#undef tfind -#undef tsearch -#undef twalk - -#include "dthdr.h" - -extern void* dtfinger(Dt_t*); - -/* POSIX tsearch library based on libcdt -** Written by Kiem-Phong Vo (AT&T Research, 07/19/95) -*/ - -typedef struct _tree_s -{ Dtlink_t link; - void* key; -} Tree_t; - -typedef struct _treedisc_s -{ Dtdisc_t disc; - int(* comparf)(const void*, const void*); -} Treedisc_t; - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -/* compare function */ -static int treecompare(Dt_t* dt, char* one, char* two, Dtdisc_t* disc) -{ - return (*((Treedisc_t*)disc)->comparf)((void*)one,(void*)two); -} - -static Treedisc_t Treedisc = -{ { sizeof(Dtlink_t), -1, /* object is key */ - 0, - NIL(Dtmake_f), NIL(Dtfree_f), - treecompare, - NIL(Dthash_f), - NIL(Dtmemory_f), - NIL(Dtevent_f) - }, - 0 -}; - -extern -void* tsearch(const void* key, void** rootp, - int(*comparf)(const void*,const void*) ) -{ - reg Dt_t* dt; - reg Tree_t* o; - - if(!rootp || - (!(dt = *((Dt_t**)rootp)) && !(dt = dtopen((Dtdisc_t*)(&Treedisc),Dtoset))) ) - return NIL(void*); - - /* dangerous to set comparf on each call but that's tsearch */ - Treedisc.comparf = comparf; - - if(!(o = (Tree_t*)dtmatch(dt,key)) ) - { if(!(o = (Tree_t*)malloc(sizeof(Tree_t))) ) - return NIL(void*); - o->key = (void*)key; - dtinsert(dt,o); - } - - if(o) - *rootp = (void*)dt; - else if(*rootp == NIL(void*) ) - dtclose(dt); - - return (void*)(&o->key); -} - -extern -void* tfind(const void* key, void*const* rootp, - int(*comparf)(const void*, const void*) ) -{ - reg Dt_t* dt; - reg Tree_t* o; - - if(!rootp || !(dt = *((Dt_t**)rootp)) ) - return NIL(void*); - Treedisc.comparf = comparf; - - return (o = (Tree_t*)dtmatch(dt,key)) ? (void*)(&o->key) : NIL(void*); -} - -/* the original tdelete() specifies that it will return the parent pointer -** in the tree if there is one. Since we are using a splay tree, a deleted -** node is always rotated to the root first. So this implementation always -** returns the key of the new root. -*/ -extern -void* tdelete(const void* key, void** rootp, - int(*comparf)(const void*, const void*) ) -{ - reg Dt_t* dt; - reg Tree_t* o; - Tree_t obj; - - if(!rootp || !(dt = *((Dt_t**)rootp)) ) - return NIL(void*); - - Treedisc.comparf = comparf; - - obj.key = (void*)key; - dtdelete(dt,&obj); - - if(!(o = dtfinger(dt)) ) - { dtclose(dt); - *rootp = NIL(void*); - } - - return o ? (void*)(&o->key) : NIL(void*); -} - -/* the below routine assumes a particular layout of Dtlink_t. -** If this ever gets changed, this routine should be redone. -*/ -#define lchild link.lh.__left -#define rchild link.rh.__rght - -static void _twalk(Tree_t* obj, void(*action)(const void*,VISIT,int), int level) -{ if(!obj->lchild && !obj->rchild) - (*action)((void*)obj,leaf,level); - else - { (*action)((void*)obj,preorder,level); - if(obj->lchild) - _twalk((Tree_t*)obj->lchild,action,level+1); - (*action)((void*)obj,postorder,level); - if(obj->rchild) - _twalk((Tree_t*)obj->rchild,action,level+1); - (*action)((void*)obj,endorder,level); - } -} - -/* the original twalk allows specifying arbitrary node to start traversal. -** Since our root is a dictionary structure, the search here will start -** at whichever node happens to be current root. -*/ -extern -void twalk(const void* root, void(*action)(const void*,VISIT,int) ) -{ - reg Tree_t* o; - - if(root && (o = (Tree_t*)dtfinger((Dt_t*)root)) ) - _twalk(o,action,0); -} - -#endif diff --git a/src/lib/libast/features/common b/src/lib/libast/features/common index cbe539476..7a016a8aa 100644 --- a/src/lib/libast/features/common +++ b/src/lib/libast/features/common @@ -60,7 +60,7 @@ cat{ #endif /* Windows variants and veneers */ - #if !defined(_WINIX) && (_UWIN || __CYGWIN__ || __EMX__) + #if !defined(_WINIX) && (__CYGWIN__ || __EMX__) # define _WINIX 1 #endif @@ -75,7 +75,7 @@ cat{ # if _BLD_STATIC && !_BLD_DLL # undef _DLL # else - # if !_UWIN && !defined(_DLL) + # if !defined(_DLL) # define _DLL 1 # endif # endif @@ -85,9 +85,6 @@ cat{ # if !defined(__IMPORT__) && ( _BLD_DLL || defined(_DLL) ) # define __IMPORT__ __declspec(dllimport) # endif - # if _BLD_DLL && _UWIN - # define __DYNAMIC__(v) (_ast_getdll()->_ast_ ## v) - # endif #endif #if !defined(_astimport) # if defined(__IMPORT__) && defined(_DLL) @@ -96,7 +93,7 @@ cat{ # define _astimport extern # endif #endif - #if _dll_import && ( !_BLD_DLL || _WINIX && !_UWIN ) + #if _dll_import && ( !_BLD_DLL || _WINIX ) # define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj # define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj #else @@ -517,12 +514,6 @@ tst - -DTRY=1 - -DTRY=1 -Dvoid=char - -DTRY=2 - -DTRY=3 - -DTRY=4 output{ printf("/* va_arg() va_list type */\n"); #endif /*TRY == 4*/ - #if _UWIN - printf("#ifndef va_copy\n"); - printf("#define va_copy(to,fr) ((to)=(fr))\t"); - printf("/* copy va_list fr -> to */\n"); - printf("#endif\n"); - #else #if !defined(va_copy) #if defined(__va_copy) printf("#ifndef va_copy\n"); @@ -542,7 +533,6 @@ tst - -DTRY=1 - -DTRY=1 -Dvoid=char - -DTRY=2 - -DTRY=3 - -DTRY=4 output{ printf("#endif\n"); #endif #endif - #endif #endif printf("#endif\n"); diff --git a/src/lib/libast/features/lib b/src/lib/libast/features/lib index 8e42646a1..860b62e2a 100644 --- a/src/lib/libast/features/lib +++ b/src/lib/libast/features/lib @@ -630,19 +630,6 @@ tst - output{ int main() { - #if _UWIN - printf("\n"); - printf("/* override some UWIN feature tests */\n"); - printf("#undef _lib_execlp\n"); - printf("#undef _lib_execvp\n"); - printf("#undef _lib_execvpe\n"); - printf("#undef _lib_fork\n"); - printf("#undef _std_string\n"); - printf("#define _std_string 1\n"); - printf("#undef _stream_peek\n"); - printf("\n"); - #endif - #if _lib_posix_spawn || _lib_spawn_mode || _lib_spawn && _hdr_spawn && _mem_pgroup_inheritance || _lib_vfork && _real_vfork printf("#if !_AST_no_spawnveg\n"); printf("#define _use_spawnveg 1\n"); diff --git a/src/lib/libast/features/limits.c b/src/lib/libast/features/limits.c index 0b969b2b9..ac58a5b0b 100644 --- a/src/lib/libast/features/limits.c +++ b/src/lib/libast/features/limits.c @@ -295,23 +295,6 @@ int main() #endif printf("\n"); -#ifdef _UWIN - printf("#ifdef _UWIN\n"); - printf("#ifndef DBL_DIG\n"); - printf("#define DBL_DIG 15\n"); - printf("#endif\n"); - printf("#ifndef DBL_MAX\n"); - printf("#define DBL_MAX 1.7976931348623158e+308\n"); - printf("#endif\n"); - printf("#ifndef FLT_DIG\n"); - printf("#define FLT_DIG 6\n"); - printf("#endif\n"); - printf("#ifndef FLT_MAX\n"); - printf("#define FLT_MAX 3.402823466e+38F\n"); - printf("#endif\n"); - printf("#endif\n"); - printf("\n"); -#endif #include "conflim.h" diff --git a/src/lib/libast/features/map.c b/src/lib/libast/features/map.c index c1efe7885..e16bad0b0 100644 --- a/src/lib/libast/features/map.c +++ b/src/lib/libast/features/map.c @@ -518,9 +518,7 @@ main() printf("#endif\n"); #endif #endif - printf("#if !_UWIN\n"); printf("#undef extern\n"); - printf("#endif\n"); #if _npt_strtold || _map_libc || _std_strtold #if _npt_strtold && !_map_libc && !_std_strtold printf("#ifndef _ISOC99_SOURCE\n"); diff --git a/src/lib/libast/features/sfio b/src/lib/libast/features/sfio index 1f548a3a8..7d95828bb 100644 --- a/src/lib/libast/features/sfio +++ b/src/lib/libast/features/sfio @@ -25,7 +25,6 @@ tst tmp_rmfail note{ open files cannot be removed }end execute{ int main() { - #if !_UWIN int n; char* s; FILE* fr; @@ -71,7 +70,6 @@ tst tmp_rmfail note{ open files cannot be removed }end execute{ fclose(fr); if (strcmp(file, data) != 0) return 0; - #endif return 1; } }end diff --git a/src/lib/libast/features/stdio b/src/lib/libast/features/stdio index 3172d5b6e..11a277455 100644 --- a/src/lib/libast/features/stdio +++ b/src/lib/libast/features/stdio @@ -115,7 +115,6 @@ output{ printf("#ifndef TMP_MAX\n"); printf("#define TMP_MAX %d\n", TMP_MAX); printf("#endif\n"); - #if !_UWIN printf("\n"); printf("#define _doprnt _ast_doprnt\n"); printf("#define _doscan _ast_doscan\n"); @@ -191,12 +190,7 @@ output{ printf("#define putc_unlocked _ast_putc_unlocked\n"); printf("#define putchar_unlocked _ast_putchar_unlocked\n"); - printf("#define flockfile _ast_flockfile\n"); - printf("#define ftrylockfile _ast_ftrylockfile\n"); - printf("#define funlockfile _ast_funlockfile\n"); - printf("\n"); - #endif return 0; } }end @@ -359,14 +353,12 @@ cat{ #else - #if !_UWIN #if _BLD_ast && defined(__EXPORT__) #define extern extern __EXPORT__ #endif #if !_BLD_ast && defined(__IMPORT__) #define extern extern __IMPORT__ #endif - #endif extern FILE _Sfstdin; extern FILE _Sfstdout; diff --git a/src/lib/libast/features/tmlib b/src/lib/libast/features/tmlib index 4db71cda2..1996a6037 100644 --- a/src/lib/libast/features/tmlib +++ b/src/lib/libast/features/tmlib @@ -5,7 +5,7 @@ _cc_export_dynamic = note{ probe CC.EXPORT.DYNAMIC supported }end run{ }end tst tzset_environ note{ tzset() bypasses user getenv() }end execute{ - #if _UWIN || !_cc_export_dynamic + #if !_cc_export_dynamic int main() { return 0; diff --git a/src/lib/libast/features/uwin b/src/lib/libast/features/uwin deleted file mode 100644 index b42cea1d7..000000000 --- a/src/lib/libast/features/uwin +++ /dev/null @@ -1,10 +0,0 @@ -lib a64l,acosh,asinh,atanh,cbrt,ceil,crypt,erf,exp,expm1,floor -lib gamma,getpass,lgamma,log,log1p,random,rcmd,rint,srand48 -lib copysign,logb,finite,drem,sqrt,ilogb,remainder,scalb -lib _copysign,_finite,_scalb,__iob_func,_p__iob,__p__iob - -dat _iob - -cat{ - #define stricmp strcasecmp -}end diff --git a/src/lib/libast/include/ast_std.h b/src/lib/libast/include/ast_std.h index 168416490..b43bff889 100644 --- a/src/lib/libast/include/ast_std.h +++ b/src/lib/libast/include/ast_std.h @@ -40,10 +40,8 @@ #define _BLD_aso 1 #define _BLD_cdt 1 #define _BLD_sfio 1 -#if !_UWIN #define _BLD_vmalloc 1 #endif -#endif #ifdef _SFSTDIO_H #define _SKIP_SFSTDIO_H @@ -134,8 +132,6 @@ struct lconv #define extern __EXPORT__ #endif -#if !_UWIN /* for AST54 compatibility */ - #undef getenv #define getenv _ast_getenv @@ -144,8 +140,6 @@ struct lconv extern char* getenv(const char*); -#endif - #undef localeconv #define localeconv _ast_localeconv diff --git a/src/lib/libast/include/sfio.h b/src/lib/libast/include/sfio.h index a8169e5f8..fd2bf3be3 100644 --- a/src/lib/libast/include/sfio.h +++ b/src/lib/libast/include/sfio.h @@ -207,10 +207,6 @@ extern Sfio_t* sfstdin; extern Sfio_t* sfstdout; extern Sfio_t* sfstderr; -#if _UWIN -#undef extern -#endif - extern Sfio_t _Sfstdin; extern Sfio_t _Sfstdout; extern Sfio_t _Sfstderr; diff --git a/src/lib/libast/man/sfio.3 b/src/lib/libast/man/sfio.3 index 8d780cc24..2dc7764f7 100644 --- a/src/lib/libast/man/sfio.3 +++ b/src/lib/libast/man/sfio.3 @@ -1986,10 +1986,6 @@ FILE* tmpfile(); int fclose(FILE* stream); int pclose(FILE* stream); -void flockfile(FILE* stream) -int ftrylockfile(FILE* stream) -void funlockfile(FILE* stream) - void setbuf(FILE* stream, char* buf); int setvbuf(FILE* stream, char* buf, int mode, size_t size); void setbuffer(FILE* stream, char* buf, size_t size); diff --git a/src/lib/libast/misc/getenv.c b/src/lib/libast/misc/getenv.c index 76e7b2dbf..c145aedd2 100644 --- a/src/lib/libast/misc/getenv.c +++ b/src/lib/libast/misc/getenv.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -21,16 +21,8 @@ * * ***********************************************************************/ -#if _UWIN && __STDPP__ -__STDPP__directive pragma pp:hide getenv -#endif - #include "intercepts.h" -#if _UWIN && __STDPP__ -__STDPP__directive pragma pp:nohide getenv -#endif - /* * NOTE: the "intercepts" definition is here instead of astintercept.c because some * static linkers miss lone references to "intercepts" without "astintercept()" @@ -41,43 +33,6 @@ __STDPP__directive pragma pp:nohide getenv Intercepts_t intercepts = { 0 }; -#if _UWIN && !defined(getenv) - -#include - -extern char** environ; - -static char* -default_getenv(const char* name) -{ - register char** av; - register const char* cp; - register const char* sp; - register char c0; - register char c1; - - av = environ; - if (!av || !name || !(c0 = *name)) - return 0; - if (!(c1 = *++name)) - c1 = '='; - while (cp = *av++) - { - if (cp[0] != c0 || cp[1] != c1) - continue; - sp = name; - cp++; - while (*sp && *sp++ == *cp++); - if (*(sp-1) != *(cp-1)) - continue; - if (*sp == 0 && *cp == '=') - return (char*)(cp+1); - } - return 0; -} - -#endif - /* * get name from the environment */ @@ -89,21 +44,6 @@ default_getenv(const char* name) extern char* getenv(const char* name) { -#if _UWIN && !defined(getenv) /* for AST54 compatibility */ - HANDLE dll; - - static char* (*posix_getenv)(const char*); - - if (!posix_getenv) - { - if (dll = GetModuleHandle("posix.dll")) - posix_getenv = (char*(*)(const char*))GetProcAddress(dll, "getenv"); - if (!posix_getenv) - posix_getenv = default_getenv; - } - return intercepts.intercept_getenv ? (*intercepts.intercept_getenv)(name) : (*posix_getenv)(name); -#else #undef getenv return intercepts.intercept_getenv ? (*intercepts.intercept_getenv)(name) : getenv(name); -#endif } diff --git a/src/lib/libast/misc/magic.c b/src/lib/libast/misc/magic.c index 7ccb6ce5b..eb13650e5 100644 --- a/src/lib/libast/misc/magic.c +++ b/src/lib/libast/misc/magic.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -839,82 +839,9 @@ ckmagic(register Magic_t* mp, const char* file, char* buf, char* end, struct sta break; case 'r': -#if _UWIN - { - char* e; - Sfio_t* rp; - Sfio_t* gp; - - if (!(t = strrchr(file, '.'))) - goto next; - sfprintf(mp->tmp, "/reg/classes_root/%s", t); - if (!(t = sfstruse(mp->tmp)) || !(rp = sfopen(NiL, t, "r"))) - goto next; - *ep->desc = 0; - *ep->mime = 0; - gp = 0; - while (t = sfgetr(rp, '\n', 1)) - { - if (strneq(t, "Content Type=", 13)) - { - ep->mime = vmnewof(mp->vm, ep->mime, char, sfvalue(rp), 0); - strcpy(ep->mime, t + 13); - if (gp) - break; - } - else - { - sfprintf(mp->tmp, "/reg/classes_root/%s", t); - if ((e = sfstruse(mp->tmp)) && (gp = sfopen(NiL, e, "r"))) - { - ep->desc = vmnewof(mp->vm, ep->desc, char, strlen(t), 1); - strcpy(ep->desc, t); - if (*ep->mime) - break; - } - } - } - sfclose(rp); - if (!gp) - goto next; - if (!*ep->mime) - { - t = T(ep->desc); - if (!strncasecmp(t, "microsoft", 9)) - t += 9; - while (isspace(*t)) - t++; - e = "application/x-ms-"; - ep->mime = vmnewof(mp->vm, ep->mime, char, strlen(t), strlen(e)); - e = strcopy(ep->mime, e); - while ((c = *t++) && c != '.' && c != ' ') - *e++ = isupper(c) ? tolower(c) : c; - *e = 0; - } - while (t = sfgetr(gp, '\n', 1)) - if (*t && !streq(t, "\"\"")) - { - ep->desc = vmnewof(mp->vm, ep->desc, char, sfvalue(gp), 0); - strcpy(ep->desc, t); - break; - } - sfclose(gp); - if (!*ep->desc) - goto next; - if (!t) - for (t = T(ep->desc); *t; t++) - if (*t == '.') - *t = ' '; - if (!mp->keep[level]) - mp->keep[level] = 2; - mp->mime = ep->mime; - break; - } -#else if (ep->cont == '#' && !mp->keep[level]) mp->keep[level] = 1; goto next; -#endif case 'v': if (!(p = getdata(mp, num, 4))) diff --git a/src/lib/libast/misc/signal.c b/src/lib/libast/misc/signal.c index 72515f3f3..618e66ef1 100644 --- a/src/lib/libast/misc/signal.c +++ b/src/lib/libast/misc/signal.c @@ -26,7 +26,7 @@ * fun==SIG_DFL also unblocks signal */ -#if !_UWIN && !__HAIKU__ +#if !__HAIKU__ #undef signal #define signal ______signal @@ -36,8 +36,6 @@ #include #include -#if !_UWIN - #undef signal #undef _def_map_ast @@ -47,8 +45,6 @@ #define extern __EXPORT__ #endif -#endif - #if defined(SV_ABORT) #undef SV_INTERRUPT #define SV_INTERRUPT SV_ABORT diff --git a/src/lib/libast/path/pathkey.c b/src/lib/libast/path/pathkey.c index 7e431c88a..fc1d54d87 100644 --- a/src/lib/libast/path/pathkey.c +++ b/src/lib/libast/path/pathkey.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -65,9 +65,6 @@ pathkey_20100601(const char* lang, const char* tool, const char* apath, char* ke char* env[elementsof(usr) + 3]; char* ver[2]; char tmp[PATH_MAX]; -#if _UWIN - struct stat st; -#endif static char let[] = "ABCDEFGHIJKLMNOP"; @@ -127,15 +124,6 @@ pathkey_20100601(const char* lang, const char* tool, const char* apath, char* ke attr = strcopy(attr, k); } #endif -#if _UWIN - if (!stat("/", &st) && st.st_ino == 64) - { - k = "/64"; - n = memsum(k, strlen(k), n); - if (attr) - attr = strcopy(attr, k); - } -#endif /* * universe diff --git a/src/lib/libast/path/pathnative.c b/src/lib/libast/path/pathnative.c index 4e55c1291..f4ec55f62 100644 --- a/src/lib/libast/path/pathnative.c +++ b/src/lib/libast/path/pathnative.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -33,18 +33,6 @@ #include -#if _UWIN - -extern int uwin_path(const char*, char*, int); - -size_t -pathnative(const char* path, char* buf, size_t siz) -{ - return uwin_path(path, buf, siz); -} - -#else - #if __CYGWIN__ extern void cygwin_conv_to_win32_path(const char*, char*); @@ -122,5 +110,3 @@ pathnative(const char* path, char* buf, size_t siz) #endif #endif - -#endif diff --git a/src/lib/libast/path/pathposix.c b/src/lib/libast/path/pathposix.c index 602a2f841..d0ea10ab6 100644 --- a/src/lib/libast/path/pathposix.c +++ b/src/lib/libast/path/pathposix.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -33,18 +33,6 @@ #include -#if _UWIN - -#include - -size_t -pathposix(const char* path, char* buf, size_t siz) -{ - return uwin_unpath(path, buf, siz); -} - -#else - #if __CYGWIN__ extern void cygwin_conv_to_posix_path(const char*, char*); @@ -124,5 +112,3 @@ pathposix(const char* path, char* buf, size_t siz) #endif #endif - -#endif diff --git a/src/lib/libast/port/astconf.c b/src/lib/libast/port/astconf.c index 7d2b128a2..0a9055519 100644 --- a/src/lib/libast/port/astconf.c +++ b/src/lib/libast/port/astconf.c @@ -605,11 +605,7 @@ format(register Feature_t* fp, const char* path, const char* value, unsigned int { register Feature_t* sp; register int n; -#if _UWIN && ( _X86_ || _X64_ ) - struct stat st; -#else static struct utsname uts; -#endif #if DEBUG_astconf error(-6, "astconf format name=%s path=%s value=%s flags=%04x fp=%p%s", fp->name, path, value, flags, fp, state.synthesizing ? " SYNTHESIZING" : ""); @@ -622,31 +618,10 @@ format(register Feature_t* fp, const char* path, const char* value, unsigned int { case OP_architecture: -#if _UWIN && ( _X86_ || _X64_ ) - if (!stat("/", &st)) - { - if (st.st_ino == 64) - { - fp->value = "x64"; - break; - } - if (st.st_ino == 32) - { - fp->value = "x86"; - break; - } - } -#if _X64_ - fp->value = "x64"; -#else - fp->value = "x86"; -#endif -#else if (!uname(&uts)) return fp->value = uts.machine; if (!(fp->value = getenv("HOSTNAME"))) fp->value = "unknown"; -#endif break; case OP_conformance: diff --git a/src/lib/libast/port/astdynamic.c b/src/lib/libast/port/astdynamic.c index aac9ee661..75df7c366 100644 --- a/src/lib/libast/port/astdynamic.c +++ b/src/lib/libast/port/astdynamic.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -25,88 +25,6 @@ * AST dynamic data initialization */ -#ifdef _UWIN - -#define _std_def_cfree 1 - -#include -#include - -#undef strcoll - -#include - -extern Sfio_t _Sfstdin; -extern Sfio_t _Sfstdout; -extern Sfio_t _Sfstderr; - -#include "sfhdr.h" - -#undef sfstdin -#undef sfstdout -#undef sfstderr - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -/* - * for backward compatibility with early UNIX - */ - -extern void -cfree(void* addr) -{ - free(addr); -} - -extern void -_ast_libinit(void* in, void* out, void* err) -{ - Sfio_t* sp; - - sp = (Sfio_t*)in; - *sp = _Sfstdin; - sfstdin = sp; - sp = (Sfio_t*)out; - *sp = _Sfstdout; - sfstdout = sp; - sp = (Sfio_t*)err; - *sp = _Sfstderr; - sfstderr = sp; -} - -extern void -_ast_init(void) -{ - struct _astdll* ap = _ast_getdll(); - - _ast_libinit(ap->_ast_stdin,ap->_ast_stdout,ap->_ast_stderr); -} - -extern void -_ast_exit(void) -{ - if (_Sfcleanup) - (*_Sfcleanup)(); -} - -BOOL WINAPI -DllMain(HINSTANCE hinst, DWORD reason, VOID* reserved) -{ - switch (reason) - { - case DLL_PROCESS_ATTACH: - break; - case DLL_PROCESS_DETACH: - _ast_exit(); - break; - } - return 1; -} - -#else - #include #if _dll_data_intercept && ( _DLL_BLD || _BLD_DLL ) @@ -128,5 +46,3 @@ _ast_getdll(void) NoN(astdynamic) #endif - -#endif diff --git a/src/lib/libast/stdio/_doprnt.c b/src/lib/libast/stdio/_doprnt.c index e5268424c..97b4a2b95 100644 --- a/src/lib/libast/stdio/_doprnt.c +++ b/src/lib/libast/stdio/_doprnt.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int _doprnt(const char* fmt, va_list args, Sfio_t* f) { - STDIO_INT(f, "_doprnt", int, (const char*, va_list, Sfio_t*), (fmt, args, f)) - return sfvprintf(f, fmt, args); } diff --git a/src/lib/libast/stdio/_doscan.c b/src/lib/libast/stdio/_doscan.c index 5e315dde1..e5f143a4c 100644 --- a/src/lib/libast/stdio/_doscan.c +++ b/src/lib/libast/stdio/_doscan.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int _doscan(Sfio_t* f, const char* fmt, va_list args) { - STDIO_INT(f, "_doscan", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) - return sfvscanf(f, fmt, args); } diff --git a/src/lib/libast/stdio/_filbuf.c b/src/lib/libast/stdio/_filbuf.c index 5d7a1e215..5e6906cb2 100644 --- a/src/lib/libast/stdio/_filbuf.c +++ b/src/lib/libast/stdio/_filbuf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -30,7 +30,5 @@ extern int _filbuf(Sfio_t* f) { - STDIO_INT(f, "_filbuf", int, (Sfio_t*), (f)) - return _sffilbuf(f, 0); } diff --git a/src/lib/libast/stdio/_flsbuf.c b/src/lib/libast/stdio/_flsbuf.c index 9ccbf6090..5964f3ecc 100644 --- a/src/lib/libast/stdio/_flsbuf.c +++ b/src/lib/libast/stdio/_flsbuf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -36,8 +36,6 @@ NoN(_flsbuf) extern int _flsbuf(int c, Sfio_t* f) { - STDIO_INT(f, "_flsbuf", int, (int, Sfio_t*), (c, f)) - return _sfflsbuf(f, c); } diff --git a/src/lib/libast/stdio/_stdfun.c b/src/lib/libast/stdio/_stdfun.c deleted file mode 100644 index f8bd2030f..000000000 --- a/src/lib/libast/stdio/_stdfun.c +++ /dev/null @@ -1,80 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include - -#if !_UWIN - -void _STUB_stdfun(){} - -#else - -#include -#include -#include -#include "FEATURE/uwin" - -#if _lib___iob_func -#define IOB ((char*)__iob_func()) -#elif _lib___p__iob -#define IOB ((char*)__p__iob()) -#elif _dat__iob -#define IOB ((char*)_iob) -#else -#define IOB ((char*)_p__iob()) -#endif - -#define IOBMAX (512*32) - -#include "stdhdr.h" - -int -_stdfun(Sfio_t* f, Funvec_t* vp) -{ - static char* iob; - static int init; - static void* bp; - static void* np; - - if (!iob && !(iob = IOB)) - return 0; - if (f && ((char*)f < iob || (char*)f > iob+IOBMAX)) - return 0; - if (!vp->vec[1]) - { - if (!init) - { - init = 1; - bp = dlopen("/usr/bin/stdio.dll", 0); - } - if (bp && (vp->vec[1] = (Fun_f)dlsym(bp, vp->name))) - return 1; - if (!np && !(np = dlopen("/sys/msvcrt.dll", 0))) - return -1; - if (!(vp->vec[1] = (Fun_f)dlsym(np, vp->name))) - return -1; - } - return 1; -} - -#endif diff --git a/src/lib/libast/stdio/clearerr.c b/src/lib/libast/stdio/clearerr.c index fe3947f39..2fea2f517 100644 --- a/src/lib/libast/stdio/clearerr.c +++ b/src/lib/libast/stdio/clearerr.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,8 +26,6 @@ int clearerr(Sfio_t* f) { - STDIO_INT(f, "clearerr", int, (Sfio_t*), (f)) - sfclrerr(f); return sfclrlock(f); } diff --git a/src/lib/libast/stdio/fclose.c b/src/lib/libast/stdio/fclose.c index 28516ce70..1fdaeb652 100644 --- a/src/lib/libast/stdio/fclose.c +++ b/src/lib/libast/stdio/fclose.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int fclose(Sfio_t* f) { - STDIO_INT(f, "fclose", int, (Sfio_t*), (f)) - return sfclose(f); } diff --git a/src/lib/libast/stdio/fcloseall.c b/src/lib/libast/stdio/fcloseall.c index af03234de..479eab98d 100644 --- a/src/lib/libast/stdio/fcloseall.c +++ b/src/lib/libast/stdio/fcloseall.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -35,8 +35,6 @@ fcloseall(void) int count; int loop; - STDIO_INT(0, "fcloseall", int, (void), ()) - for(loop = 0; loop < MAXLOOP; ++loop) { nclose = count = 0; for(p = &_Sfpool; p; p = next) diff --git a/src/lib/libast/stdio/feof.c b/src/lib/libast/stdio/feof.c deleted file mode 100644 index 32d7b931a..000000000 --- a/src/lib/libast/stdio/feof.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(feof) - -#else - -#undef feof - -int -feof(Sfio_t* f) -{ - STDIO_INT(f, "feof", int, (Sfio_t*), (f)) - - return sfeof(f); -} - -#endif diff --git a/src/lib/libast/stdio/ferror.c b/src/lib/libast/stdio/ferror.c deleted file mode 100644 index 573d95bb5..000000000 --- a/src/lib/libast/stdio/ferror.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(ferror) - -#else - -#undef ferror - -int -ferror(Sfio_t* f) -{ - STDIO_INT(f, "ferror", int, (Sfio_t*), (f)) - - return sferror(f); -} - -#endif diff --git a/src/lib/libast/stdio/fflush.c b/src/lib/libast/stdio/fflush.c index 37e0088d1..2639f6fc9 100644 --- a/src/lib/libast/stdio/fflush.c +++ b/src/lib/libast/stdio/fflush.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -33,8 +33,6 @@ fflush(Sfio_t* f) if (!f) return fcloseall(); - STDIO_INT(f, "fflush", int, (Sfio_t*), (f)) - if (f->extent > 0) sfseek(f, (Sfoff_t)0, SEEK_CUR|SF_PUBLIC); return (sfsync(f) < 0 || sfpurge(f) < 0) ? -1 : 0; diff --git a/src/lib/libast/stdio/fgetc.c b/src/lib/libast/stdio/fgetc.c index 78ca64d90..9b1cd1d4a 100644 --- a/src/lib/libast/stdio/fgetc.c +++ b/src/lib/libast/stdio/fgetc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int fgetc(Sfio_t* f) { - STDIO_INT(f, "fgetc", int, (Sfio_t*), (f)) - return sfgetc(f); } diff --git a/src/lib/libast/stdio/fgetpos.c b/src/lib/libast/stdio/fgetpos.c index 0bb6cddc2..875e82aba 100644 --- a/src/lib/libast/stdio/fgetpos.c +++ b/src/lib/libast/stdio/fgetpos.c @@ -26,7 +26,5 @@ int fgetpos(Sfio_t* f, fpos_t* pos) { - STDIO_INT(f, "fgetpos", int, (Sfio_t*, fpos_t*), (f, pos)) - return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1; } diff --git a/src/lib/libast/stdio/fgets.c b/src/lib/libast/stdio/fgets.c index 9b6d44977..34a72da0f 100644 --- a/src/lib/libast/stdio/fgets.c +++ b/src/lib/libast/stdio/fgets.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -98,8 +98,6 @@ _stdgets(Sfio_t* f, char* us, int n, int isgets) char* fgets(char* s, int n, Sfio_t* f) { - STDIO_PTR(f, "fgets", char*, (char*, int, Sfio_t*), (s, n, f)) - return _stdgets(f, s, n, 0); } diff --git a/src/lib/libast/stdio/fgetwc.c b/src/lib/libast/stdio/fgetwc.c index cda641b82..9efd49979 100644 --- a/src/lib/libast/stdio/fgetwc.c +++ b/src/lib/libast/stdio/fgetwc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -28,8 +28,6 @@ fgetwc(Sfio_t* f) { wchar_t c; - STDIO_INT(f, "fgetwc", wint_t, (Sfio_t*), (f)) - FWIDE(f, WEOF); return (sfread(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF; } diff --git a/src/lib/libast/stdio/fgetws.c b/src/lib/libast/stdio/fgetws.c index 7e96f9614..16f4eb481 100644 --- a/src/lib/libast/stdio/fgetws.c +++ b/src/lib/libast/stdio/fgetws.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -30,8 +30,6 @@ fgetws(wchar_t* s, int n, Sfio_t* f) register wchar_t* e = s + n - 1; register wint_t c; - STDIO_PTR(f, "fgets", wchar_t*, (wchar_t*, int, Sfio_t*), (s, n, f)) - FWIDE(f, 0); while (p < e && (c = fgetwc(f)) != WEOF && (*p++ = c) != '\n'); *p = 0; diff --git a/src/lib/libast/stdio/fileno.c b/src/lib/libast/stdio/fileno.c deleted file mode 100644 index 0c48c8544..000000000 --- a/src/lib/libast/stdio/fileno.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(fileno) - -#else - -#undef fileno - -int -fileno(Sfio_t* f) -{ - STDIO_INT(f, "fileno", int, (Sfio_t*), (f)) - - return sffileno(f); -} - -#endif diff --git a/src/lib/libast/stdio/flockfile.c b/src/lib/libast/stdio/flockfile.c deleted file mode 100644 index 377754e33..000000000 --- a/src/lib/libast/stdio/flockfile.c +++ /dev/null @@ -1,30 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2022 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -void -flockfile(Sfio_t* f) -{ - STDIO_VOID(f, "flockfile", void, (Sfio_t*), (f)) -} diff --git a/src/lib/libast/stdio/fmemopen.c b/src/lib/libast/stdio/fmemopen.c index 686f04803..d20a45862 100644 --- a/src/lib/libast/stdio/fmemopen.c +++ b/src/lib/libast/stdio/fmemopen.c @@ -26,7 +26,5 @@ Sfio_t* fmemopen(void* buf, size_t size, const char* mode) { - STDIO_PTR(0, "fmemopen", Sfio_t*, (void*, size_t, const char*), (buf, size, mode)) - return sfnew(NiL, buf, size, -1, SF_STRING|_sftype(mode, NiL, NiL)); } diff --git a/src/lib/libast/stdio/fprintf.c b/src/lib/libast/stdio/fprintf.c index 69d394383..f1c95c870 100644 --- a/src/lib/libast/stdio/fprintf.c +++ b/src/lib/libast/stdio/fprintf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -31,8 +31,6 @@ fprintf(Sfio_t* f, const char* fmt, ...) va_start(args, fmt); - STDIO_INT(f, "vfprintf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) - v = sfvprintf(f, fmt, args); va_end(args); return v; diff --git a/src/lib/libast/stdio/fpurge.c b/src/lib/libast/stdio/fpurge.c index 47546f085..46f3875bc 100644 --- a/src/lib/libast/stdio/fpurge.c +++ b/src/lib/libast/stdio/fpurge.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int fpurge(Sfio_t* f) { - STDIO_INT(f, "fpurge", int, (Sfio_t*), (f)) - return sfpurge(f); } diff --git a/src/lib/libast/stdio/fputc.c b/src/lib/libast/stdio/fputc.c deleted file mode 100644 index 8f8d9f0d3..000000000 --- a/src/lib/libast/stdio/fputc.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(fputc) - -#else - -#undef fputc - -int -fputc(int c, Sfio_t* f) -{ - STDIO_INT(f, "fputc", int, (int, Sfio_t*), (c, f)) - - return sfputc(f, c); -} - -#endif diff --git a/src/lib/libast/stdio/fputs.c b/src/lib/libast/stdio/fputs.c index 849a7123e..405720dc7 100644 --- a/src/lib/libast/stdio/fputs.c +++ b/src/lib/libast/stdio/fputs.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int fputs(const char* s, Sfio_t* f) { - STDIO_INT(f, "fputs", int, (const char*, Sfio_t*), (s, f)) - return sfputr(f, s, -1); } diff --git a/src/lib/libast/stdio/fputwc.c b/src/lib/libast/stdio/fputwc.c index a2b736293..084374ec3 100644 --- a/src/lib/libast/stdio/fputwc.c +++ b/src/lib/libast/stdio/fputwc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,8 +26,6 @@ wint_t fputwc(wchar_t c, Sfio_t* f) { - STDIO_INT(f, "fputc", wint_t, (wchar_t, Sfio_t*), (c, f)) - FWIDE(f, WEOF); return (sfwrite(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF; } diff --git a/src/lib/libast/stdio/fputws.c b/src/lib/libast/stdio/fputws.c index 1f32701f0..9ac00b3ad 100644 --- a/src/lib/libast/stdio/fputws.c +++ b/src/lib/libast/stdio/fputws.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -28,8 +28,6 @@ fputws(const wchar_t* s, Sfio_t* f) { size_t n; - STDIO_INT(f, "fputws", int, (const wchar_t*, Sfio_t*), (s, f)) - FWIDE(f, WEOF); n = wcslen(s) * sizeof(wchar_t); return (sfwrite(f, s, n) == n) ? 0 : -1; diff --git a/src/lib/libast/stdio/fread.c b/src/lib/libast/stdio/fread.c index 867def402..57bccc509 100644 --- a/src/lib/libast/stdio/fread.c +++ b/src/lib/libast/stdio/fread.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -28,7 +28,5 @@ fread(void* p, size_t s, size_t n, Sfio_t* f) { ssize_t v; - STDIO_INT(f, "fread", ssize_t, (void*, size_t, size_t, Sfio_t*), (p, s, n, f)) - return ((v = sfread(f, p, s * n)) <= 0) ? 0 : (v / s); } diff --git a/src/lib/libast/stdio/freopen.c b/src/lib/libast/stdio/freopen.c index 8f0fc5047..d1343457d 100644 --- a/src/lib/libast/stdio/freopen.c +++ b/src/lib/libast/stdio/freopen.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ Sfio_t* freopen(const char* path, const char* mode, Sfio_t* f) { - STDIO_PTR(f, "freopen", Sfio_t*, (const char*, const char*, Sfio_t*), (path, mode, f)) - return sfopen(f, path, mode); } diff --git a/src/lib/libast/stdio/fscanf.c b/src/lib/libast/stdio/fscanf.c index 5cba1febc..243792276 100644 --- a/src/lib/libast/stdio/fscanf.c +++ b/src/lib/libast/stdio/fscanf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -31,8 +31,6 @@ fscanf(Sfio_t* f, const char* fmt, ...) va_start(args, fmt); - STDIO_INT(f, "vfscanf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) - v = sfvscanf(f, fmt, args); va_end(args); return v; diff --git a/src/lib/libast/stdio/fseek.c b/src/lib/libast/stdio/fseek.c index 1009a3da9..63d9e9bd8 100644 --- a/src/lib/libast/stdio/fseek.c +++ b/src/lib/libast/stdio/fseek.c @@ -26,7 +26,5 @@ int fseek(Sfio_t* f, long off, int op) { - STDIO_INT(f, "fseek", int, (Sfio_t*, long, int), (f, off, op)) - return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1; } diff --git a/src/lib/libast/stdio/fseeko.c b/src/lib/libast/stdio/fseeko.c index 57dcd6c97..c0636f6a2 100644 --- a/src/lib/libast/stdio/fseeko.c +++ b/src/lib/libast/stdio/fseeko.c @@ -26,7 +26,5 @@ int fseeko(Sfio_t* f, off_t off, int op) { - STDIO_INT(f, "fseeko", int, (Sfio_t*, off_t, int), (f, off, op)) - return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1; } diff --git a/src/lib/libast/stdio/fsetpos.c b/src/lib/libast/stdio/fsetpos.c index 07d8f3048..3e550b9c7 100644 --- a/src/lib/libast/stdio/fsetpos.c +++ b/src/lib/libast/stdio/fsetpos.c @@ -26,7 +26,5 @@ int fsetpos(Sfio_t* f, const fpos_t* pos) { - STDIO_INT(f, "fsetpos", int, (Sfio_t*, const fpos_t*), (f, pos)) - return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1; } diff --git a/src/lib/libast/stdio/ftell.c b/src/lib/libast/stdio/ftell.c index e2c4c801d..47a673228 100644 --- a/src/lib/libast/stdio/ftell.c +++ b/src/lib/libast/stdio/ftell.c @@ -26,7 +26,5 @@ long ftell(Sfio_t* f) { - STDIO_INT(f, "ftell", long, (Sfio_t*), (f)) - return (long)sfseek(f, (Sfoff_t)0, SEEK_CUR); } diff --git a/src/lib/libast/stdio/ftello.c b/src/lib/libast/stdio/ftello.c index 6fbdff09a..075a45ae5 100644 --- a/src/lib/libast/stdio/ftello.c +++ b/src/lib/libast/stdio/ftello.c @@ -26,7 +26,5 @@ off_t ftello(Sfio_t* f) { - STDIO_INT(f, "ftello", off_t, (Sfio_t*), (f)) - return sfseek(f, (Sfoff_t)0, SEEK_CUR); } diff --git a/src/lib/libast/stdio/ftrylockfile.c b/src/lib/libast/stdio/ftrylockfile.c deleted file mode 100644 index 4bd20be4c..000000000 --- a/src/lib/libast/stdio/ftrylockfile.c +++ /dev/null @@ -1,32 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2022 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -int -ftrylockfile(Sfio_t* f) -{ - STDIO_INT(f, "ftrylockfile", int, (Sfio_t*), (f)) - - return 0; -} diff --git a/src/lib/libast/stdio/funlockfile.c b/src/lib/libast/stdio/funlockfile.c deleted file mode 100644 index 39675dc9b..000000000 --- a/src/lib/libast/stdio/funlockfile.c +++ /dev/null @@ -1,30 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2022 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -void -funlockfile(Sfio_t* f) -{ - STDIO_VOID(f, "funlockfile", void, (Sfio_t*), (f)) -} diff --git a/src/lib/libast/stdio/fwide.c b/src/lib/libast/stdio/fwide.c index 60cdc4bba..02d272809 100644 --- a/src/lib/libast/stdio/fwide.c +++ b/src/lib/libast/stdio/fwide.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,8 +26,6 @@ int fwide(Sfio_t* f, int mode) { - STDIO_INT(f, "fwide", int, (Sfio_t*, int), (f, mode)) - if (mode > 0) { f->bits &= ~SF_MB; diff --git a/src/lib/libast/stdio/fwrite.c b/src/lib/libast/stdio/fwrite.c index 7b6cbd425..a66f1b4de 100644 --- a/src/lib/libast/stdio/fwrite.c +++ b/src/lib/libast/stdio/fwrite.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -28,7 +28,5 @@ fwrite(const void* p, size_t s, size_t n, Sfio_t* f) { ssize_t v; - STDIO_INT(f, "fwrite", ssize_t, (const void*, size_t, size_t, Sfio_t*), (p, s, n, f)) - return ((v = sfwrite(f, p, s * n)) <= 0) ? 0 : (v / s); } diff --git a/src/lib/libast/stdio/fwscanf.c b/src/lib/libast/stdio/fwscanf.c index a91d62214..195b3e3df 100644 --- a/src/lib/libast/stdio/fwscanf.c +++ b/src/lib/libast/stdio/fwscanf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -31,8 +31,6 @@ fwscanf(Sfio_t* f, const wchar_t* fmt, ...) va_start(args, fmt); - STDIO_INT(f, "vfwscanf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args)) - v = vfwscanf(f, fmt, args); va_end(args); return v; diff --git a/src/lib/libast/stdio/getc.c b/src/lib/libast/stdio/getc.c deleted file mode 100644 index 30d8294c1..000000000 --- a/src/lib/libast/stdio/getc.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(getc) - -#else - -#undef getc - -int -getc(Sfio_t* f) -{ - STDIO_INT(f, "getc", int, (Sfio_t*), (f)) - - return sfgetc(f); -} - -#endif diff --git a/src/lib/libast/stdio/getchar.c b/src/lib/libast/stdio/getchar.c deleted file mode 100644 index 91b35cc02..000000000 --- a/src/lib/libast/stdio/getchar.c +++ /dev/null @@ -1,40 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(getchar) - -#else - -#undef getchar - -int -getchar(void) -{ - return sfgetc(sfstdin); -} - -#endif diff --git a/src/lib/libast/stdio/getdelim.c b/src/lib/libast/stdio/getdelim.c index d40ccd0e1..bd39e42ba 100644 --- a/src/lib/libast/stdio/getdelim.c +++ b/src/lib/libast/stdio/getdelim.c @@ -33,8 +33,6 @@ getdelim(char** sp, size_t* np, int delim, Sfio_t* f) uchar* s; uchar* ps; - STDIO_INT(f, "getdelim", ssize_t, (char**, size_t*, int, Sfio_t*), (sp, np, delim, f)) - if(delim < 0 || delim > 255 || !sp || !np) /* bad parameters */ return -1; diff --git a/src/lib/libast/stdio/getline.c b/src/lib/libast/stdio/getline.c index 7e0f5bdb2..e402f4382 100644 --- a/src/lib/libast/stdio/getline.c +++ b/src/lib/libast/stdio/getline.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -30,7 +30,5 @@ ssize_t getline(char** sp, size_t* np, Sfio_t* f) { - STDIO_INT(f, "getline", ssize_t, (char**, size_t*, Sfio_t*), (sp, np, f)) - return getdelim(sp, np, '\n', f); } diff --git a/src/lib/libast/stdio/getw.c b/src/lib/libast/stdio/getw.c index 1807d424a..0001f2128 100644 --- a/src/lib/libast/stdio/getw.c +++ b/src/lib/libast/stdio/getw.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -28,7 +28,5 @@ getw(Sfio_t* f) { int v; - STDIO_INT(f, "getw", int, (Sfio_t*), (f)) - return sfread(f, &v, sizeof(v)) == sizeof(v) ? v : -1; } diff --git a/src/lib/libast/stdio/pclose.c b/src/lib/libast/stdio/pclose.c index 34fb4d791..a0b2ab427 100644 --- a/src/lib/libast/stdio/pclose.c +++ b/src/lib/libast/stdio/pclose.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int pclose(Sfio_t* f) { - STDIO_INT(f, "pclose", int, (Sfio_t*), (f)) - return sfclose(f); } diff --git a/src/lib/libast/stdio/putc.c b/src/lib/libast/stdio/putc.c deleted file mode 100644 index 27b6b8295..000000000 --- a/src/lib/libast/stdio/putc.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ - -#include "stdhdr.h" - -#if !_UWIN - -NoN(putc) - -#else - -#undef putc - -int -putc(int c, Sfio_t* f) -{ - STDIO_INT(f, "putc", int, (int, Sfio_t*), (c, f)) - - return sfputc(f, c); -} - -#endif diff --git a/src/lib/libast/stdio/putchar.c b/src/lib/libast/stdio/putchar.c index 9f8b50992..f91a43464 100644 --- a/src/lib/libast/stdio/putchar.c +++ b/src/lib/libast/stdio/putchar.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -23,18 +23,4 @@ #include "stdhdr.h" -#if !_UWIN - NoN(putchar) - -#else - -#undef putchar - -int -putchar(int c) -{ - return sfputc(sfstdout, c); -} - -#endif diff --git a/src/lib/libast/stdio/putw.c b/src/lib/libast/stdio/putw.c index d7bf268cd..62e281e81 100644 --- a/src/lib/libast/stdio/putw.c +++ b/src/lib/libast/stdio/putw.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int putw(int v, Sfio_t* f) { - STDIO_INT(f, "putw", int, (int, Sfio_t*), (v, f)) - return sfwrite(f, &v, sizeof(v)) == sizeof(v) ? 0 : -1; } diff --git a/src/lib/libast/stdio/rewind.c b/src/lib/libast/stdio/rewind.c index bf6667689..e2390d280 100644 --- a/src/lib/libast/stdio/rewind.c +++ b/src/lib/libast/stdio/rewind.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,8 +26,6 @@ void rewind(Sfio_t* f) { - STDIO_VOID(f, "rewind", void, (Sfio_t*), (f)) - sfseek(f, (Sfoff_t)0, SEEK_SET|SF_PUBLIC); sfclrlock(f); } diff --git a/src/lib/libast/stdio/setbuf.c b/src/lib/libast/stdio/setbuf.c index 8ae606ba7..b4aa3f756 100644 --- a/src/lib/libast/stdio/setbuf.c +++ b/src/lib/libast/stdio/setbuf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ void setbuf(Sfio_t* f, char* b) { - STDIO_VOID(f, "setbuf", void, (Sfio_t*, char*), (f, b)) - sfsetbuf(f, b, b ? BUFSIZ : 0); } diff --git a/src/lib/libast/stdio/setbuffer.c b/src/lib/libast/stdio/setbuffer.c index d8c2dc5ab..90d8c6490 100644 --- a/src/lib/libast/stdio/setbuffer.c +++ b/src/lib/libast/stdio/setbuffer.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int setbuffer(Sfio_t* f, char* b, int n) { - STDIO_INT(f, "setbuffer", int, (Sfio_t*, char*, int), (f, b, n)) - return sfsetbuf(f, b, n) ? 0 : -1; } diff --git a/src/lib/libast/stdio/setlinebuf.c b/src/lib/libast/stdio/setlinebuf.c index 7c5d764da..b110c49b0 100644 --- a/src/lib/libast/stdio/setlinebuf.c +++ b/src/lib/libast/stdio/setlinebuf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,8 +26,6 @@ int setlinebuf(Sfio_t* f) { - STDIO_INT(f, "setlinebuf", int, (Sfio_t*), (f)) - sfset(f, SF_LINE, 1); return 0; } diff --git a/src/lib/libast/stdio/setvbuf.c b/src/lib/libast/stdio/setvbuf.c index bfbe4495f..2d7870e65 100644 --- a/src/lib/libast/stdio/setvbuf.c +++ b/src/lib/libast/stdio/setvbuf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,8 +26,6 @@ int setvbuf(Sfio_t* f, char* buf, int type, size_t size) { - STDIO_INT(f, "setvbuf", int, (Sfio_t*, char*, int, size_t), (f, buf, type, size)) - if (type == _IOLBF) sfset(f, SF_LINE, 1); else if (f->flags & SF_STRING) diff --git a/src/lib/libast/stdio/stdhdr.h b/src/lib/libast/stdio/stdhdr.h index b4b773d87..bf43c0ec3 100644 --- a/src/lib/libast/stdio/stdhdr.h +++ b/src/lib/libast/stdio/stdhdr.h @@ -37,64 +37,6 @@ #define SF_MB 010000 #define SF_WC 020000 -#if _UWIN - -#define STDIO_TRANSFER 1 - -typedef int (*Fun_f)(); - -typedef struct Funvec_s -{ - const char* name; - Fun_f vec[2]; -} Funvec_t; - -extern int _stdfun(Sfio_t*, Funvec_t*); - -#define STDIO_INT(p,n,t,f,a) \ - { \ - typedef t (*_s_f)f; \ - int _i; \ - static Funvec_t _v = { n }; \ - if ((_i = _stdfun(p, &_v)) < 0) \ - return -1; \ - else if (_i > 0) \ - return ((_s_f)_v.vec[_i])a; \ - } - -#define STDIO_PTR(p,n,t,f,a) \ - { \ - typedef t (*_s_f)f; \ - int _i; \ - static Funvec_t _v = { n }; \ - if ((_i = _stdfun(p, &_v)) < 0) \ - return 0; \ - else if (_i > 0) \ - return ((_s_f)_v.vec[_i])a; \ - } - -#define STDIO_VOID(p,n,t,f,a) \ - { \ - typedef t (*_s_f)f; \ - int _i; \ - static Funvec_t _v = { n }; \ - if ((_i = _stdfun(p, &_v)) < 0) \ - return; \ - else if (_i > 0) \ - { \ - ((_s_f)_v.vec[_i])a; \ - return; \ - } \ - } - -#else - -#define STDIO_INT(p,n,t,f,a) -#define STDIO_PTR(p,n,t,f,a) -#define STDIO_VOID(p,n,t,f,a) - -#endif - #define FWIDE(f,r) \ do \ { \ diff --git a/src/lib/libast/stdio/ungetc.c b/src/lib/libast/stdio/ungetc.c index e1b6f32de..2d1e8fbeb 100644 --- a/src/lib/libast/stdio/ungetc.c +++ b/src/lib/libast/stdio/ungetc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int ungetc(int c, Sfio_t* f) { - STDIO_INT(f, "ungetc", int, (int, Sfio_t*), (c, f)) - return sfungetc(f, c); } diff --git a/src/lib/libast/stdio/ungetwc.c b/src/lib/libast/stdio/ungetwc.c index 60c0a76be..1cb945df0 100644 --- a/src/lib/libast/stdio/ungetwc.c +++ b/src/lib/libast/stdio/ungetwc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -29,8 +29,6 @@ ungetwc(wint_t c, Sfio_t* f) register unsigned char* s = (unsigned char*)&c; register unsigned char* e = s + sizeof(c); - STDIO_INT(f, "ungetwc", wint_t, (wint_t, Sfio_t*), (c, f)) - FWIDE(f, WEOF); while (s < e) if (sfungetc(f, *s++) == EOF) diff --git a/src/lib/libast/stdio/vfprintf.c b/src/lib/libast/stdio/vfprintf.c index 88e393489..ec3fe8b1d 100644 --- a/src/lib/libast/stdio/vfprintf.c +++ b/src/lib/libast/stdio/vfprintf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int vfprintf(Sfio_t* f, const char* fmt, va_list args) { - STDIO_INT(f, "vfprintf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) - return sfvprintf(f, fmt, args); } diff --git a/src/lib/libast/stdio/vfscanf.c b/src/lib/libast/stdio/vfscanf.c index 15b50e6f0..01b6eee10 100644 --- a/src/lib/libast/stdio/vfscanf.c +++ b/src/lib/libast/stdio/vfscanf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -26,7 +26,5 @@ int vfscanf(Sfio_t* f, const char* fmt, va_list args) { - STDIO_INT(f, "vfscanf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) - return sfvscanf(f, fmt, args); } diff --git a/src/lib/libast/stdio/vfwprintf.c b/src/lib/libast/stdio/vfwprintf.c index caa415996..c2da158c8 100644 --- a/src/lib/libast/stdio/vfwprintf.c +++ b/src/lib/libast/stdio/vfwprintf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -33,8 +33,6 @@ vfwprintf(Sfio_t* f, const wchar_t* fmt, va_list args) int v; Sfio_t* t; - STDIO_INT(f, "vfwprintf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args)) - FWIDE(f, WEOF); n = wcstombs(NiL, fmt, 0); if (m = malloc(n + 1)) diff --git a/src/lib/libast/stdio/vfwscanf.c b/src/lib/libast/stdio/vfwscanf.c index 1f60ae9c5..cfb0f39cd 100644 --- a/src/lib/libast/stdio/vfwscanf.c +++ b/src/lib/libast/stdio/vfwscanf.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -85,8 +85,6 @@ vfwscanf(Sfio_t* f, const wchar_t* fmt, va_list args) Wide_t* w; char buf[1024]; - STDIO_INT(f, "vfwscanf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args)) - FWIDE(f, WEOF); n = wcstombs(NiL, fmt, 0); if (w = newof(0, Wide_t, 1, n)) diff --git a/src/lib/libast/uwin/a64l.c b/src/lib/libast/uwin/a64l.c deleted file mode 100644 index 0fb12d778..000000000 --- a/src/lib/libast/uwin/a64l.c +++ /dev/null @@ -1,77 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_a64l - -void _STUB_a64l(){} - -#else - -#define a64l ______a64l -#define l64a ______l64a - -#include -#include - -#undef a64l -#undef l64a - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -static char letter[65] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -extern long a64l(const char *str) -{ - register unsigned long ul = 0; - register int n = 6; - register int c; - register char *cp; - for(n=0; n <6; n++) - { - if((c= *str++)==0) - break; - if(!(cp=strchr(letter,c))) - break; - ul |= (cp-letter)<< (6*n); - } - return((long)ul); -} - -extern char *l64a(long l) -{ - static char buff[7]; - unsigned ul = ((unsigned long)l & 0xffffffff); - register char *cp = buff; - while(ul>0) - { - *cp++ = letter[ul&077]; - ul >>= 6; - } - *cp = 0; - return(buff); -} - -#endif diff --git a/src/lib/libast/uwin/acosh.c b/src/lib/libast/uwin/acosh.c deleted file mode 100644 index 9248e915d..000000000 --- a/src/lib/libast/uwin/acosh.c +++ /dev/null @@ -1,108 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_acosh - -void _STUB_acosh(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)acosh.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* ACOSH(X) - * RETURN THE INVERSE HYPERBOLIC COSINE OF X - * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 2/16/85; - * REVISED BY K.C. NG on 3/6/85, 3/24/85, 4/16/85, 8/17/85. - * - * Required system supported functions : - * sqrt(x) - * - * Required kernel function: - * log1p(x) ...return log(1+x) - * - * Method : - * Based on - * acosh(x) = log [ x + sqrt(x*x-1) ] - * we have - * acosh(x) := log1p(x)+ln2, if (x > 1.0E20); else - * acosh(x) := log1p( sqrt(x-1) * (sqrt(x-1) + sqrt(x+1)) ) . - * These formulae avoid the over/underflow complication. - * - * Special cases: - * acosh(x) is NaN with signal if x<1. - * acosh(NaN) is NaN without signal. - * - * Accuracy: - * acosh(x) returns the exact inverse hyperbolic cosine of x nearly - * rounded. In a test run with 512,000 random arguments on a VAX, the - * maximum observed error was 3.30 ulps (units of the last place) at - * x=1.0070493753568216 . - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#endif - -extern double acosh(x) -double x; -{ - double t,big=1.E20; /* big+1==big */ - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - /* return log1p(x) + log(2) if x is large */ - if(x>big) {t=log1p(x)+ln2lo; return(t+ln2hi);} - - t=sqrt(x-1.0); - return(log1p(t*(t+sqrt(x+1.0)))); -} - -#endif diff --git a/src/lib/libast/uwin/asinh.c b/src/lib/libast/uwin/asinh.c deleted file mode 100644 index 6c8f54cab..000000000 --- a/src/lib/libast/uwin/asinh.c +++ /dev/null @@ -1,107 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_asinh - -void _STUB_asinh(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)asinh.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* ASINH(X) - * RETURN THE INVERSE HYPERBOLIC SINE OF X - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 2/16/85; - * REVISED BY K.C. NG on 3/7/85, 3/24/85, 4/16/85. - * - * Required system supported functions : - * copysign(x,y) - * sqrt(x) - * - * Required kernel function: - * log1p(x) ...return log(1+x) - * - * Method : - * Based on - * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] - * we have - * asinh(x) := x if 1+x*x=1, - * := sign(x)*(log1p(x)+ln2)) if sqrt(1+x*x)=x, else - * := sign(x)*log1p(|x| + |x|/(1/|x| + sqrt(1+(1/|x|)^2)) ) - * - * Accuracy: - * asinh(x) returns the exact inverse hyperbolic sine of x nearly rounded. - * In a test run with 52,000 random arguments on a VAX, the maximum - * observed error was 1.58 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#endif - -extern double asinh(x) -double x; -{ - double t,s; - const static double small=1.0E-10, /* fl(1+small*small) == 1 */ - big =1.0E20, /* fl(1+big) == big */ - one =1.0 ; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if((t=copysign(x,one))>small) - if(t big */ - {s=log1p(t)+ln2lo; return(copysign(s+ln2hi,x));} - else /* if |x| < small */ - return(x); -} - -#endif diff --git a/src/lib/libast/uwin/atanh.c b/src/lib/libast/uwin/atanh.c deleted file mode 100644 index b5e9a78b9..000000000 --- a/src/lib/libast/uwin/atanh.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_atanh - -void _STUB_atanh(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)atanh.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* ATANH(X) - * RETURN THE HYPERBOLIC ARC TANGENT OF X - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/8/85; - * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85. - * - * Required kernel function: - * log1p(x) ...return log(1+x) - * - * Method : - * Return - * 1 2x x - * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) - * 2 1 - x 1 - x - * - * Special cases: - * atanh(x) is NaN if |x| > 1 with signal; - * atanh(NaN) is that NaN with no signal; - * atanh(+-1) is +-INF with signal. - * - * Accuracy: - * atanh(x) returns the exact hyperbolic arc tangent of x nearly rounded. - * In a test run with 512,000 random arguments on a VAX, the maximum - * observed error was 1.87 ulps (units in the last place) at - * x= -3.8962076028810414000e-03. - */ -#include "mathimpl.h" - -#if defined(vax)||defined(tahoe) -#include -#endif /* defined(vax)||defined(tahoe) */ - -extern double atanh(x) -double x; -{ - double z; - z = copysign(0.5,x); - x = copysign(x,1.0); -#if defined(vax)||defined(tahoe) - if (x == 1.0) { - return(copysign(1.0,z)*infnan(ERANGE)); /* sign(x)*INF */ - } -#endif /* defined(vax)||defined(tahoe) */ - x = x/(1.0-x); - return( z*log1p(x+x) ); -} - -#endif diff --git a/src/lib/libast/uwin/cbrt.c b/src/lib/libast/uwin/cbrt.c deleted file mode 100644 index fd34e3b3b..000000000 --- a/src/lib/libast/uwin/cbrt.c +++ /dev/null @@ -1,39 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_cbrt - -void _STUB_cbrt(){} - -#else - -#include "mathimpl.h" - -extern double cbrt(double x) -{ - return(exp(log(x)/3.0)); -} - - -#endif diff --git a/src/lib/libast/uwin/crypt.c b/src/lib/libast/uwin/crypt.c deleted file mode 100644 index 60607411c..000000000 --- a/src/lib/libast/uwin/crypt.c +++ /dev/null @@ -1,956 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_crypt - -void _STUB_crypt(){} - -#else - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Tom Truscott. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#define crypt ______crypt -#define encrypt ______encrypt -#define setkey ______setkey - -/* #include */ -#include -#include -#include - -#undef crypt -#undef encrypt -#undef setkey - -#ifndef _PASSWORD_EFMT1 -#define _PASSWORD_EFMT1 '-' -#endif - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -/* - * UNIX password, and DES, encryption. - * By Tom Truscott, trt@rti.rti.org, - * from algorithms by Robert W. Baldwin and James Gillogly. - * - * References: - * "Mathematical Cryptology for Computer Scientists and Mathematicians," - * by Wayne Patterson, 1987, ISBN 0-8476-7438-X. - * - * "Password Security: A Case History," R. Morris and Ken Thompson, - * Communications of the ACM, vol. 22, pp. 594-597, Nov. 1979. - * - * "DES will be Totally Insecure within Ten Years," M.E. Hellman, - * IEEE Spectrum, vol. 16, pp. 32-39, July 1979. - */ - -/* ===== Configuration ==================== */ - -/* - * define "MUST_ALIGN" if your compiler cannot load/store - * long integers at arbitrary (e.g. odd) memory locations. - * (Either that or never pass unaligned addresses to des_cipher!) - */ -#if !defined(vax) -#define MUST_ALIGN -#endif - -#ifdef CHAR_BITS -#if CHAR_BITS != 8 - #error C_block structure assumes 8 bit characters -#endif -#endif - -/* - * define "LONG_IS_32_BITS" only if sizeof(long)==4. - * This avoids use of bit fields (your compiler may be sloppy with them). - */ -#if !defined(cray) -#define LONG_IS_32_BITS -#endif - -/* - * define "B64" to be the declaration for a 64 bit integer. - * XXX this feature is currently unused, see "endian" comment below. - */ -#if defined(cray) -#define B64 long -#endif -#if defined(convex) -#define B64 long long -#endif - -/* - * define "LARGEDATA" to get faster permutations, by using about 72 kilobytes - * of lookup tables. This speeds up des_setkey() and des_cipher(), but has - * little effect on crypt(). - */ -#if defined(notdef) -#define LARGEDATA -#endif - -/* ==================================== */ - -/* - * Cipher-block representation (Bob Baldwin): - * - * DES operates on groups of 64 bits, numbered 1..64 (sigh). One - * representation is to store one bit per byte in an array of bytes. Bit N of - * the NBS spec is stored as the LSB of the Nth byte (index N-1) in the array. - * Another representation stores the 64 bits in 8 bytes, with bits 1..8 in the - * first byte, 9..16 in the second, and so on. The DES spec apparently has - * bit 1 in the MSB of the first byte, but that is particularly noxious so we - * bit-reverse each byte so that bit 1 is the LSB of the first byte, bit 8 is - * the MSB of the first byte. Specifically, the 64-bit input data and key are - * converted to LSB format, and the output 64-bit block is converted back into - * MSB format. - * - * DES operates internally on groups of 32 bits which are expanded to 48 bits - * by permutation E and shrunk back to 32 bits by the S boxes. To speed up - * the computation, the expansion is applied only once, the expanded - * representation is maintained during the encryption, and a compression - * permutation is applied only at the end. To speed up the S-box lookups, - * the 48 bits are maintained as eight 6 bit groups, one per byte, which - * directly feed the eight S-boxes. Within each byte, the 6 bits are the - * most significant ones. The low two bits of each byte are zero. (Thus, - * bit 1 of the 48 bit E expansion is stored as the "4"-valued bit of the - * first byte in the eight byte representation, bit 2 of the 48 bit value is - * the "8"-valued bit, and so on.) In fact, a combined "SPE"-box lookup is - * used, in which the output is the 64 bit result of an S-box lookup which - * has been permuted by P and expanded by E, and is ready for use in the next - * iteration. Two 32-bit wide tables, SPE[0] and SPE[1], are used for this - * lookup. Since each byte in the 48 bit path is a multiple of four, indexed - * lookup of SPE[0] and SPE[1] is simple and fast. The key schedule and - * "salt" are also converted to this 8*(6+2) format. The SPE table size is - * 8*64*8 = 4K bytes. - * - * To speed up bit-parallel operations (such as XOR), the 8 byte - * representation is "union"ed with 32 bit values "i0" and "i1", and, on - * machines which support it, a 64 bit value "b64". This data structure, - * "C_block", has two problems. First, alignment restrictions must be - * honored. Second, the byte-order (e.g. little-endian or big-endian) of - * the architecture becomes visible. - * - * The byte-order problem is unfortunate, since on the one hand it is good - * to have a machine-independent C_block representation (bits 1..8 in the - * first byte, etc.), and on the other hand it is good for the LSB of the - * first byte to be the LSB of i0. We cannot have both these things, so we - * currently use the "little-endian" representation and avoid any multi-byte - * operations that depend on byte order. This largely precludes use of the - * 64-bit datatype since the relative order of i0 and i1 are unknown. It - * also inhibits grouping the SPE table to look up 12 bits at a time. (The - * 12 bits can be stored in a 16-bit field with 3 low-order zeroes and 1 - * high-order zero, providing fast indexing into a 64-bit wide SPE.) On the - * other hand, 64-bit datatypes are currently rare, and a 12-bit SPE lookup - * requires a 128 kilobyte table, so perhaps this is not a big loss. - * - * Permutation representation (Jim Gillogly): - * - * A transformation is defined by its effect on each of the 8 bytes of the - * 64-bit input. For each byte we give a 64-bit output that has the bits in - * the input distributed appropriately. The transformation is then the OR - * of the 8 sets of 64-bits. This uses 8*256*8 = 16K bytes of storage for - * each transformation. Unless LARGEDATA is defined, however, a more compact - * table is used which looks up 16 4-bit "chunks" rather than 8 8-bit chunks. - * The smaller table uses 16*16*8 = 2K bytes for each transformation. This - * is slower but tolerable, particularly for password encryption in which - * the SPE transformation is iterated many times. The small tables total 9K - * bytes, the large tables total 72K bytes. - * - * The transformations used are: - * IE3264: MSB->LSB conversion, initial permutation, and expansion. - * This is done by collecting the 32 even-numbered bits and applying - * a 32->64 bit transformation, and then collecting the 32 odd-numbered - * bits and applying the same transformation. Since there are only - * 32 input bits, the IE3264 transformation table is half the size of - * the usual table. - * CF6464: Compression, final permutation, and LSB->MSB conversion. - * This is done by two trivial 48->32 bit compressions to obtain - * a 64-bit block (the bit numbering is given in the "CIFP" table) - * followed by a 64->64 bit "cleanup" transformation. (It would - * be possible to group the bits in the 64-bit block so that 2 - * identical 32->32 bit transformations could be used instead, - * saving a factor of 4 in space and possibly 2 in time, but - * byte-ordering and other complications rear their ugly head. - * Similar opportunities/problems arise in the key schedule - * transforms.) - * PC1ROT: MSB->LSB, PC1 permutation, rotate, and PC2 permutation. - * This admittedly baroque 64->64 bit transformation is used to - * produce the first code (in 8*(6+2) format) of the key schedule. - * PC2ROT[0]: Inverse PC2 permutation, rotate, and PC2 permutation. - * It would be possible to define 15 more transformations, each - * with a different rotation, to generate the entire key schedule. - * To save space, however, we instead permute each code into the - * next by using a transformation that "undoes" the PC2 permutation, - * rotates the code, and then applies PC2. Unfortunately, PC2 - * transforms 56 bits into 48 bits, dropping 8 bits, so PC2 is not - * invertible. We get around that problem by using a modified PC2 - * which retains the 8 otherwise-lost bits in the unused low-order - * bits of each byte. The low-order bits are cleared when the - * codes are stored into the key schedule. - * PC2ROT[1]: Same as PC2ROT[0], but with two rotations. - * This is faster than applying PC2ROT[0] twice, - * - * The Bell Labs "salt" (Bob Baldwin): - * - * The salting is a simple permutation applied to the 48-bit result of E. - * Specifically, if bit i (1 <= i <= 24) of the salt is set then bits i and - * i+24 of the result are swapped. The salt is thus a 24 bit number, with - * 16777216 possible values. (The original salt was 12 bits and could not - * swap bits 13..24 with 36..48.) - * - * It is possible, but ugly, to warp the SPE table to account for the salt - * permutation. Fortunately, the conditional bit swapping requires only - * about four machine instructions and can be done on-the-fly with about an - * 8% performance penalty. - */ - -typedef union { - unsigned char b[8]; - struct { -#if defined(LONG_IS_32_BITS) - /* long is often faster than a 32-bit bit field */ - long i0; - long i1; -#else - long i0: 32; - long i1: 32; -#endif - } b32; -#if defined(B64) - B64 b64; -#endif -} C_block; - -/* - * Convert twenty-four-bit long in host-order - * to six bits (and 2 low-order zeroes) per char little-endian format. - */ -#define TO_SIX_BIT(rslt, src) { \ - C_block cvt; \ - cvt.b[0] = (unsigned char) src; src >>= 6; \ - cvt.b[1] = (unsigned char) src; src >>= 6; \ - cvt.b[2] = (unsigned char) src; src >>= 6; \ - cvt.b[3] = (unsigned char) src; \ - rslt = (cvt.b32.i0 & 0x3f3f3f3fL) << 2; \ - } - -/* - * These macros may someday permit efficient use of 64-bit integers. - */ -#define ZERO(d,d0,d1) d0 = 0, d1 = 0 -#define LOAD(d,d0,d1,bl) d0 = (bl).b32.i0, d1 = (bl).b32.i1 -#define LOADREG(d,d0,d1,s,s0,s1) d0 = s0, d1 = s1 -#define OR(d,d0,d1,bl) d0 |= (bl).b32.i0, d1 |= (bl).b32.i1 -#define STORE(s,s0,s1,bl) (bl).b32.i0 = s0, (bl).b32.i1 = s1 -#define DCL_BLOCK(d,d0,d1) long d0, d1 - -#if defined(LARGEDATA) - /* Waste memory like crazy. Also, do permutations in line */ -#define LGCHUNKBITS 3 -#define CHUNKBITS (1<>4]; OR(D,D0,D1,*tp); p += (1< 0); - STORE(D,D0,D1,*out); -} -#endif /* LARGEDATA */ - - -/* ===== (mostly) Standard DES Tables ==================== */ - -static unsigned char IP[] = { /* initial permutation */ - 58, 50, 42, 34, 26, 18, 10, 2, - 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, - 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, - 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, - 63, 55, 47, 39, 31, 23, 15, 7, -}; - -/* The final permutation is the inverse of IP - no table is necessary */ - -static unsigned char ExpandTr[] = { /* expansion operation */ - 32, 1, 2, 3, 4, 5, - 4, 5, 6, 7, 8, 9, - 8, 9, 10, 11, 12, 13, - 12, 13, 14, 15, 16, 17, - 16, 17, 18, 19, 20, 21, - 20, 21, 22, 23, 24, 25, - 24, 25, 26, 27, 28, 29, - 28, 29, 30, 31, 32, 1, -}; - -static unsigned char PC1[] = { /* permuted choice table 1 */ - 57, 49, 41, 33, 25, 17, 9, - 1, 58, 50, 42, 34, 26, 18, - 10, 2, 59, 51, 43, 35, 27, - 19, 11, 3, 60, 52, 44, 36, - - 63, 55, 47, 39, 31, 23, 15, - 7, 62, 54, 46, 38, 30, 22, - 14, 6, 61, 53, 45, 37, 29, - 21, 13, 5, 28, 20, 12, 4, -}; - -static unsigned char Rotates[] = { /* PC1 rotation schedule */ - 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, -}; - -/* note: each "row" of PC2 is left-padded with bits that make it invertible */ -static unsigned char PC2[] = { /* permuted choice table 2 */ - 9, 18, 14, 17, 11, 24, 1, 5, - 22, 25, 3, 28, 15, 6, 21, 10, - 35, 38, 23, 19, 12, 4, 26, 8, - 43, 54, 16, 7, 27, 20, 13, 2, - - 0, 0, 41, 52, 31, 37, 47, 55, - 0, 0, 30, 40, 51, 45, 33, 48, - 0, 0, 44, 49, 39, 56, 34, 53, - 0, 0, 46, 42, 50, 36, 29, 32, -}; - -static unsigned char S[8][64] = { /* 48->32 bit substitution tables */ - /* S[1] */ - 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, - 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, - 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, - 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, - /* S[2] */ - 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, - 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, - 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, - 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, - /* S[3] */ - 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, - 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, - 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, - 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, - /* S[4] */ - 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, - 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, - 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, - 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, - /* S[5] */ - 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, - 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, - 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, - 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, - /* S[6] */ - 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, - 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, - 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, - 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, - /* S[7] */ - 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, - 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, - 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, - 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, - /* S[8] */ - 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, - 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, - 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, - 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11, -}; - -static unsigned char P32Tr[] = { /* 32-bit permutation function */ - 16, 7, 20, 21, - 29, 12, 28, 17, - 1, 15, 23, 26, - 5, 18, 31, 10, - 2, 8, 24, 14, - 32, 27, 3, 9, - 19, 13, 30, 6, - 22, 11, 4, 25, -}; - -static unsigned char CIFP[] = { /* compressed/interleaved permutation */ - 1, 2, 3, 4, 17, 18, 19, 20, - 5, 6, 7, 8, 21, 22, 23, 24, - 9, 10, 11, 12, 25, 26, 27, 28, - 13, 14, 15, 16, 29, 30, 31, 32, - - 33, 34, 35, 36, 49, 50, 51, 52, - 37, 38, 39, 40, 53, 54, 55, 56, - 41, 42, 43, 44, 57, 58, 59, 60, - 45, 46, 47, 48, 61, 62, 63, 64, -}; - -static unsigned char itoa64[] = /* 0..63 => ASCII-64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - - -/* ===== Tables that are initialized at run time ==================== */ - - -static unsigned char a64toi[128]; /* ASCII-64 => 0..63 */ - -/* Initial key schedule permutation */ -static C_block PC1ROT[64/CHUNKBITS][1< final permutation table */ -static C_block CF6464[64/CHUNKBITS][1<>LGCHUNKBITS; /* which chunk this bit comes from */ - l = 1<<(l&(CHUNKBITS-1)); /* mask for this bit */ - for (j = 0; j < (1<>3] |= 1<<(k&07); - } - } -} - -/* - * Initialize various tables. This need only be done once. It could even be - * done at compile time, if the compiler were capable of that sort of thing. - */ -static void init_des(void) { - register int i, j; - register long k; - register int tableno; - static unsigned char perm[64], tmp32[32]; /* "static" for speed */ - - /* - * table that converts chars "./0-9A-Za-z"to integers 0-63. - */ - for (i = 0; i < 64; i++) - a64toi[itoa64[i]] = i; - - /* - * PC1ROT - bit reverse, then PC1, then Rotate, then PC2. - */ - for (i = 0; i < 64; i++) - perm[i] = 0; - for (i = 0; i < 64; i++) { - if ((k = PC2[i]) == 0) - continue; - k += Rotates[0]-1; - if ((k%28) < Rotates[0]) k -= 28; - k = PC1[k]; - if (k > 0) { - k--; - k = (k|07) - (k&07); - k++; - } - perm[i] = (unsigned char) k; - } -#ifdef DEBUG - prtab("pc1tab", perm, 8); -#endif - init_perm(PC1ROT, perm, 8, 8); - - /* - * PC2ROT - PC2 inverse, then Rotate (once or twice), then PC2. - */ - for (j = 0; j < 2; j++) { - unsigned char pc2inv[64]; - for (i = 0; i < 64; i++) - perm[i] = pc2inv[i] = 0; - for (i = 0; i < 64; i++) { - if ((k = PC2[i]) == 0) - continue; - pc2inv[k-1] = i+1; - } - for (i = 0; i < 64; i++) { - if ((k = PC2[i]) == 0) - continue; - k += j; - if ((k%28) <= j) k -= 28; - perm[i] = pc2inv[k]; - } -#ifdef DEBUG - prtab("pc2tab", perm, 8); -#endif - init_perm(PC2ROT[j], perm, 8, 8); - } - - /* - * Bit reverse, then initial permutation, then expansion. - */ - for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { - k = (j < 2)? 0: IP[ExpandTr[i*6+j-2]-1]; - if (k > 32) - k -= 32; - else if (k > 0) - k--; - if (k > 0) { - k--; - k = (k|07) - (k&07); - k++; - } - perm[i*8+j] = (unsigned char) k; - } - } -#ifdef DEBUG - prtab("ietab", perm, 8); -#endif - init_perm(IE3264, perm, 4, 8); - - /* - * Compression, then final permutation, then bit reverse. - */ - for (i = 0; i < 64; i++) { - k = IP[CIFP[i]-1]; - if (k > 0) { - k--; - k = (k|07) - (k&07); - k++; - } - perm[k-1] = i+1; - } -#ifdef DEBUG - prtab("cftab", perm, 8); -#endif - init_perm(CF6464, perm, 8, 8); - - /* - * SPE table - */ - for (i = 0; i < 48; i++) - perm[i] = P32Tr[ExpandTr[i]-1]; - for (tableno = 0; tableno < 8; tableno++) { - for (j = 0; j < 64; j++) { - k = (((j >> 0) &01) << 5)| - (((j >> 1) &01) << 3)| - (((j >> 2) &01) << 2)| - (((j >> 3) &01) << 1)| - (((j >> 4) &01) << 0)| - (((j >> 5) &01) << 4); - k = S[tableno][k]; - k = (((k >> 3)&01) << 0)| - (((k >> 2)&01) << 1)| - (((k >> 1)&01) << 2)| - (((k >> 0)&01) << 3); - for (i = 0; i < 32; i++) - tmp32[i] = 0; - for (i = 0; i < 4; i++) - tmp32[4 * tableno + i] = (k >> i) & 01; - k = 0; - for (i = 24; --i >= 0; ) - k = (k<<1) | tmp32[perm[i]-1]; - TO_SIX_BIT(SPE[0][tableno][j], k); - k = 0; - for (i = 24; --i >= 0; ) - k = (k<<1) | tmp32[perm[i+24]-1]; - TO_SIX_BIT(SPE[1][tableno][j], k); - } - } -} - -/* - * The Key Schedule, filled in by des_setkey() or setkey(). - */ -#define KS_SIZE 16 -static C_block KS[KS_SIZE]; - -/* - * Set up the key schedule from the key. - */ -static int des_setkey(register const char *key) { - register DCL_BLOCK(K,K0,K1); - register C_block *ptabp; - register int i; - static int des_ready = 0; - - if (!des_ready) { - init_des(); - des_ready = 1; - } - - PERM6464(K,K0,K1,(unsigned char *)key,(C_block *)PC1ROT); - key = (char *)&KS[0]; - STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key); - for (i = 1; i < 16; i++) { - key += sizeof(C_block); - STORE(K,K0,K1,*(C_block *)key); - ptabp = (C_block *)PC2ROT[Rotates[i]-1]; - PERM6464(K,K0,K1,(unsigned char *)key,ptabp); - STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key); - } - return (0); -} - -/* - * Encrypt (or decrypt if num_iter < 0) the 8 chars at "in" with abs(num_iter) - * iterations of DES, using the given 24-bit salt and the pre-computed key - * schedule, and store the resulting 8 chars at "out" (in == out is permitted). - * - * NOTE: the performance of this routine is critically dependent on your - * compiler and machine architecture. - */ -static int des_cipher(const char *in, char *out, long salt, int num_iter) { - /* variables that we want in registers, most important first */ -#if defined(pdp11) - register int j; -#endif - register long L0, L1, R0, R1, k; - register C_block *kp; - register int ks_inc, loop_count; - C_block B; - - L0 = salt; - TO_SIX_BIT(salt, L0); /* convert to 4*(6+2) format */ - -#if defined(vax) || defined(pdp11) - salt = ~salt; /* "x &~ y" is faster than "x & y". */ -#define SALT (~salt) -#else -#define SALT salt -#endif - -#if defined(MUST_ALIGN) - B.b[0] = in[0]; B.b[1] = in[1]; B.b[2] = in[2]; B.b[3] = in[3]; - B.b[4] = in[4]; B.b[5] = in[5]; B.b[6] = in[6]; B.b[7] = in[7]; - LOAD(L,L0,L1,B); -#else - LOAD(L,L0,L1,*(C_block *)in); -#endif - LOADREG(R,R0,R1,L,L0,L1); - L0 &= 0x55555555L; - L1 &= 0x55555555L; - L0 = (L0 << 1) | L1; /* L0 is the even-numbered input bits */ - R0 &= 0xaaaaaaaaL; - R1 = (R1 >> 1) & 0x55555555L; - L1 = R0 | R1; /* L1 is the odd-numbered input bits */ - STORE(L,L0,L1,B); - PERM3264(L,L0,L1,B.b, (C_block *)IE3264); /* even bits */ - PERM3264(R,R0,R1,B.b+4,(C_block *)IE3264); /* odd bits */ - - if (num_iter >= 0) - { /* encryption */ - kp = &KS[0]; - ks_inc = sizeof(*kp); - } - else - { /* decryption */ - num_iter = -num_iter; - kp = &KS[KS_SIZE-1]; - ks_inc = -((int) sizeof(*kp)); - } - - while (--num_iter >= 0) { - loop_count = 8; - do { - -#define SPTAB(t, i) (*(long *)((unsigned char *)t + i*(sizeof(long)/4))) -#if defined(gould) - /* use this if B.b[i] is evaluated just once ... */ -#define DOXOR(x,y,i) x^=SPTAB(SPE[0][i],B.b[i]); y^=SPTAB(SPE[1][i],B.b[i]); -#else -#if defined(pdp11) - /* use this if your "long" int indexing is slow */ -#define DOXOR(x,y,i) j=B.b[i]; x^=SPTAB(SPE[0][i],j); y^=SPTAB(SPE[1][i],j); -#else - /* use this if "k" is allocated to a register ... */ -#define DOXOR(x,y,i) k=B.b[i]; x^=SPTAB(SPE[0][i],k); y^=SPTAB(SPE[1][i],k); -#endif -#endif - -#define CRUNCH(p0, p1, q0, q1) \ - k = (q0 ^ q1) & SALT; \ - B.b32.i0 = k ^ q0 ^ kp->b32.i0; \ - B.b32.i1 = k ^ q1 ^ kp->b32.i1; \ - kp = (C_block *)((char *)kp+ks_inc); \ - \ - DOXOR(p0, p1, 0); \ - DOXOR(p0, p1, 1); \ - DOXOR(p0, p1, 2); \ - DOXOR(p0, p1, 3); \ - DOXOR(p0, p1, 4); \ - DOXOR(p0, p1, 5); \ - DOXOR(p0, p1, 6); \ - DOXOR(p0, p1, 7); - - CRUNCH(L0, L1, R0, R1); - CRUNCH(R0, R1, L0, L1); - } while (--loop_count != 0); - kp = (C_block *)((char *)kp-(ks_inc*KS_SIZE)); - - - /* swap L and R */ - L0 ^= R0; L1 ^= R1; - R0 ^= L0; R1 ^= L1; - L0 ^= R0; L1 ^= R1; - } - - /* store the encrypted (or decrypted) result */ - L0 = ((L0 >> 3) & 0x0f0f0f0fL) | ((L1 << 1) & 0xf0f0f0f0L); - L1 = ((R0 >> 3) & 0x0f0f0f0fL) | ((R1 << 1) & 0xf0f0f0f0L); - STORE(L,L0,L1,B); - PERM6464(L,L0,L1,B.b, (C_block *)CF6464); -#if defined(MUST_ALIGN) - STORE(L,L0,L1,B); - out[0] = B.b[0]; out[1] = B.b[1]; out[2] = B.b[2]; out[3] = B.b[3]; - out[4] = B.b[4]; out[5] = B.b[5]; out[6] = B.b[6]; out[7] = B.b[7]; -#else - STORE(L,L0,L1,*(C_block *)out); -#endif - return (0); -} - -/* - * "setkey" routine (for backwards compatibility) - */ -extern int setkey(register const char *key) { - register int i, j, k; - C_block keyblock; - - for (i = 0; i < 8; i++) { - k = 0; - for (j = 0; j < 8; j++) { - k <<= 1; - k |= (unsigned char)*key++; - } - keyblock.b[i] = k; - } - return (des_setkey((char *)keyblock.b)); -} - -/* - * "encrypt" routine (for backwards compatibility) - */ -extern int encrypt(register char *block, int flag) { - register int i, j, k; - C_block cblock; - - for (i = 0; i < 8; i++) { - k = 0; - for (j = 0; j < 8; j++) { - k <<= 1; - k |= (unsigned char)*block++; - } - cblock.b[i] = k; - } - if (des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1))) - return (1); - for (i = 7; i >= 0; i--) { - k = cblock.b[i]; - for (j = 7; j >= 0; j--) { - *--block = k&01; - k >>= 1; - } - } - return (0); -} - -/* - * Return a pointer to static data consisting of the "setting" - * followed by an encryption produced by the "key" and "setting". - */ -extern char * crypt(register const char *key, register const char *setting) { - register char *encp; - register long i; - register int t; - long salt; - int num_iter, salt_size; - C_block keyblock, rsltblock; - -#ifdef HL_NOENCRYPTION - char buff[1024]; - strncpy(buff, key, 1024); - buff[1023] = 0; - return buff; -#endif - - for (i = 0; i < 8; i++) { - if ((t = 2*(unsigned char)(*key)) != 0) - key++; - keyblock.b[i] = t; - } - if (des_setkey((char *)keyblock.b)) /* also initializes "a64toi" */ - return (NULL); - - encp = &cryptresult[0]; - switch (*setting) { - case _PASSWORD_EFMT1: - /* - * Involve the rest of the password 8 characters at a time. - */ - while (*key) { - if (des_cipher((char *)&keyblock, - (char *)&keyblock, 0L, 1)) - return (NULL); - for (i = 0; i < 8; i++) { - if ((t = 2*(unsigned char)(*key)) != 0) - key++; - keyblock.b[i] ^= t; - } - if (des_setkey((char *)keyblock.b)) - return (NULL); - } - - *encp++ = *setting++; - - /* get iteration count */ - num_iter = 0; - for (i = 4; --i >= 0; ) { - if ((t = (unsigned char)setting[i]) == '\0') - t = '.'; - encp[i] = t; - num_iter = (num_iter<<6) | a64toi[t]; - } - setting += 4; - encp += 4; - salt_size = 4; - break; - default: - num_iter = 25; - salt_size = 2; - } - - salt = 0; - for (i = salt_size; --i >= 0; ) { - if ((t = (unsigned char)setting[i]) == '\0') - t = '.'; - encp[i] = t; - salt = (salt<<6) | a64toi[t]; - } - encp += salt_size; - if (des_cipher((char *)&constdatablock, (char *)&rsltblock, - salt, num_iter)) - return (NULL); - - /* - * Encode the 64 cipher bits as 11 ASCII characters. - */ - i = ((long)((rsltblock.b[0]<<8) | rsltblock.b[1])<<8) | rsltblock.b[2]; - encp[3] = itoa64[i&0x3f]; i >>= 6; - encp[2] = itoa64[i&0x3f]; i >>= 6; - encp[1] = itoa64[i&0x3f]; i >>= 6; - encp[0] = itoa64[i]; encp += 4; - i = ((long)((rsltblock.b[3]<<8) | rsltblock.b[4])<<8) | rsltblock.b[5]; - encp[3] = itoa64[i&0x3f]; i >>= 6; - encp[2] = itoa64[i&0x3f]; i >>= 6; - encp[1] = itoa64[i&0x3f]; i >>= 6; - encp[0] = itoa64[i]; encp += 4; - i = ((long)((rsltblock.b[6])<<8) | rsltblock.b[7])<<2; - encp[2] = itoa64[i&0x3f]; i >>= 6; - encp[1] = itoa64[i&0x3f]; i >>= 6; - encp[0] = itoa64[i]; - - encp[3] = 0; - - return (cryptresult); -} - -#ifdef DEBUG -STATIC -prtab(s, t, num_rows) - char *s; - unsigned char *t; - int num_rows; -{ - register int i, j; - - (void)printf("%s:\n", s); - for (i = 0; i < num_rows; i++) { - for (j = 0; j < 8; j++) { - (void)printf("%3d", t[i*8+j]); - } - (void)printf("\n"); - } - (void)printf("\n"); -} -#endif - -#endif diff --git a/src/lib/libast/uwin/erf.c b/src/lib/libast/uwin/erf.c deleted file mode 100644 index 4cac68eae..000000000 --- a/src/lib/libast/uwin/erf.c +++ /dev/null @@ -1,403 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_erf - -void _STUB_erf(){} - -#else - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)erf.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* Modified Nov 30, 1992 P. McILROY: - * Replaced expansions for x >= 1.25 (error 1.7ulp vs ~6ulp) - * Replaced even+odd with direct calculation for x < .84375, - * to avoid destructive cancellation. - * - * Performance of erfc(x): - * In 300000 trials in the range [.83, .84375] the - * maximum observed error was 3.6ulp. - * - * In [.84735,1.25] the maximum observed error was <2.5ulp in - * 100000 runs in the range [1.2, 1.25]. - * - * In [1.25,26] (Not including subnormal results) - * the error is < 1.7ulp. - */ - -/* double erf(double x) - * double erfc(double x) - * x - * 2 |\ - * erf(x) = --------- | exp(-t*t)dt - * sqrt(pi) \| - * 0 - * - * erfc(x) = 1-erf(x) - * - * Method: - * 1. Reduce x to |x| by erf(-x) = -erf(x) - * 2. For x in [0, 0.84375] - * erf(x) = x + x*P(x^2) - * erfc(x) = 1 - erf(x) if x<=0.25 - * = 0.5 + ((0.5-x)-x*P) if x in [0.25,0.84375] - * where - * 2 2 4 20 - * P = P(x ) = (p0 + p1 * x + p2 * x + ... + p10 * x ) - * is an approximation to (erf(x)-x)/x with precision - * - * -56.45 - * | P - (erf(x)-x)/x | <= 2 - * - * - * Remark. The formula is derived by noting - * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) - * and that - * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 - * is close to one. The interval is chosen because the fixed - * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is - * near 0.6174), and by some experiment, 0.84375 is chosen to - * guarantee the error is less than one ulp for erf. - * - * 3. For x in [0.84375,1.25], let s = x - 1, and - * c = 0.84506291151 rounded to single (24 bits) - * erf(x) = c + P1(s)/Q1(s) - * erfc(x) = (1-c) - P1(s)/Q1(s) - * |P1/Q1 - (erf(x)-c)| <= 2**-59.06 - * Remark: here we use the taylor series expansion at x=1. - * erf(1+s) = erf(1) + s*Poly(s) - * = 0.845.. + P1(s)/Q1(s) - * That is, we use rational approximation to approximate - * erf(1+s) - (c = (single)0.84506291151) - * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] - * where - * P1(s) = degree 6 poly in s - * Q1(s) = degree 6 poly in s - * - * 4. For x in [1.25, 2]; [2, 4] - * erf(x) = 1.0 - tiny - * erfc(x) = (1/x)exp(-x*x-(.5*log(pi) -.5z + R(z)/S(z)) - * - * Where z = 1/(x*x), R is degree 9, and S is degree 3; - * - * 5. For x in [4,28] - * erf(x) = 1.0 - tiny - * erfc(x) = (1/x)exp(-x*x-(.5*log(pi)+eps + zP(z)) - * - * Where P is degree 14 polynomial in 1/(x*x). - * - * Notes: - * Here 4 and 5 make use of the asymptotic series - * exp(-x*x) - * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) ); - * x*sqrt(pi) - * - * where for z = 1/(x*x) - * P(z) ~ z/2*(-1 + z*3/2*(1 + z*5/2*(-1 + z*7/2*(1 +...)))) - * - * Thus we use rational approximation to approximate - * erfc*x*exp(x*x) ~ 1/sqrt(pi); - * - * The error bound for the target function, G(z) for - * the interval - * [4, 28]: - * |eps + 1/(z)P(z) - G(z)| < 2**(-56.61) - * for [2, 4]: - * |R(z)/S(z) - G(z)| < 2**(-58.24) - * for [1.25, 2]: - * |R(z)/S(z) - G(z)| < 2**(-58.12) - * - * 6. For inf > x >= 28 - * erf(x) = 1 - tiny (raise inexact) - * erfc(x) = tiny*tiny (raise underflow) - * - * 7. Special cases: - * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, - * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, - * erfc/erf(NaN) is NaN - */ - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + 1) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -#ifdef _IEEE_LIBM -/* - * redefining "___function" to "function" in _IEEE_LIBM mode - */ -#include "ieee_libm.h" -#endif -#include "mathimpl.h" - -static double -tiny = 1e-300, -half = 0.5, -one = 1.0, -two = 2.0, -c = 8.45062911510467529297e-01, /* (float)0.84506291151 */ -/* - * Coefficients for approximation to erf in [0,0.84375] - */ -p0t8 = 1.02703333676410051049867154944018394163280, -p0 = 1.283791670955125638123339436800229927041e-0001, -p1 = -3.761263890318340796574473028946097022260e-0001, -p2 = 1.128379167093567004871858633779992337238e-0001, -p3 = -2.686617064084433642889526516177508374437e-0002, -p4 = 5.223977576966219409445780927846432273191e-0003, -p5 = -8.548323822001639515038738961618255438422e-0004, -p6 = 1.205520092530505090384383082516403772317e-0004, -p7 = -1.492214100762529635365672665955239554276e-0005, -p8 = 1.640186161764254363152286358441771740838e-0006, -p9 = -1.571599331700515057841960987689515895479e-0007, -p10= 1.073087585213621540635426191486561494058e-0008; -/* - * Coefficients for approximation to erf in [0.84375,1.25] - */ -static double -pa0 = -2.362118560752659485957248365514511540287e-0003, -pa1 = 4.148561186837483359654781492060070469522e-0001, -pa2 = -3.722078760357013107593507594535478633044e-0001, -pa3 = 3.183466199011617316853636418691420262160e-0001, -pa4 = -1.108946942823966771253985510891237782544e-0001, -pa5 = 3.547830432561823343969797140537411825179e-0002, -pa6 = -2.166375594868790886906539848893221184820e-0003, -qa1 = 1.064208804008442270765369280952419863524e-0001, -qa2 = 5.403979177021710663441167681878575087235e-0001, -qa3 = 7.182865441419627066207655332170665812023e-0002, -qa4 = 1.261712198087616469108438860983447773726e-0001, -qa5 = 1.363708391202905087876983523620537833157e-0002, -qa6 = 1.198449984679910764099772682882189711364e-0002; -/* - * log(sqrt(pi)) for large x expansions. - * The tail (lsqrtPI_lo) is included in the rational - * approximations. -*/ -static double - lsqrtPI_hi = .5723649429247000819387380943226; -/* - * lsqrtPI_lo = .000000000000000005132975581353913; - * - * Coefficients for approximation to erfc in [2, 4] -*/ -static double -rb0 = -1.5306508387410807582e-010, /* includes lsqrtPI_lo */ -rb1 = 2.15592846101742183841910806188e-008, -rb2 = 6.24998557732436510470108714799e-001, -rb3 = 8.24849222231141787631258921465e+000, -rb4 = 2.63974967372233173534823436057e+001, -rb5 = 9.86383092541570505318304640241e+000, -rb6 = -7.28024154841991322228977878694e+000, -rb7 = 5.96303287280680116566600190708e+000, -rb8 = -4.40070358507372993983608466806e+000, -rb9 = 2.39923700182518073731330332521e+000, -rb10 = -6.89257464785841156285073338950e-001, -sb1 = 1.56641558965626774835300238919e+001, -sb2 = 7.20522741000949622502957936376e+001, -sb3 = 9.60121069770492994166488642804e+001; -/* - * Coefficients for approximation to erfc in [1.25, 2] -*/ -static double -rc0 = -2.47925334685189288817e-007, /* includes lsqrtPI_lo */ -rc1 = 1.28735722546372485255126993930e-005, -rc2 = 6.24664954087883916855616917019e-001, -rc3 = 4.69798884785807402408863708843e+000, -rc4 = 7.61618295853929705430118701770e+000, -rc5 = 9.15640208659364240872946538730e-001, -rc6 = -3.59753040425048631334448145935e-001, -rc7 = 1.42862267989304403403849619281e-001, -rc8 = -4.74392758811439801958087514322e-002, -rc9 = 1.09964787987580810135757047874e-002, -rc10 = -1.28856240494889325194638463046e-003, -sc1 = 9.97395106984001955652274773456e+000, -sc2 = 2.80952153365721279953959310660e+001, -sc3 = 2.19826478142545234106819407316e+001; -/* - * Coefficients for approximation to erfc in [4,28] - */ -static double -rd0 = -2.1491361969012978677e-016, /* includes lsqrtPI_lo */ -rd1 = -4.99999999999640086151350330820e-001, -rd2 = 6.24999999772906433825880867516e-001, -rd3 = -1.54166659428052432723177389562e+000, -rd4 = 5.51561147405411844601985649206e+000, -rd5 = -2.55046307982949826964613748714e+001, -rd6 = 1.43631424382843846387913799845e+002, -rd7 = -9.45789244999420134263345971704e+002, -rd8 = 6.94834146607051206956384703517e+003, -rd9 = -5.27176414235983393155038356781e+004, -rd10 = 3.68530281128672766499221324921e+005, -rd11 = -2.06466642800404317677021026611e+006, -rd12 = 7.78293889471135381609201431274e+006, -rd13 = -1.42821001129434127360582351685e+007; - -extern double erf(x) - double x; -{ - double R,S,P,Q,ax,s,y,z,r,fabs(),exp(); - if(!finite(x)) { /* erf(nan)=nan */ - if (isnan(x)) - return(x); - return (x > 0 ? one : -one); /* erf(+/-inf)= +/-1 */ - } - if ((ax = x) < 0) - ax = - ax; - if (ax < .84375) { - if (ax < 3.7e-09) { - if (ax < 1.0e-308) - return 0.125*(8.0*x+p0t8*x); /* avoid underflow */ - return x + p0*x; - } - y = x*x; - r = y*(p1+y*(p2+y*(p3+y*(p4+y*(p5+ - y*(p6+y*(p7+y*(p8+y*(p9+y*p10))))))))); - return x + x*(p0+r); - } - if (ax < 1.25) { /* 0.84375 <= |x| < 1.25 */ - s = fabs(x)-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if (x>=0) - return (c + P/Q); - else - return (-c - P/Q); - } - if (ax >= 6.0) { /* inf>|x|>=6 */ - if (x >= 0.0) - return (one-tiny); - else - return (tiny-one); - } - /* 1.25 <= |x| < 6 */ - z = -ax*ax; - s = -one/z; - if (ax < 2.0) { - R = rc0+s*(rc1+s*(rc2+s*(rc3+s*(rc4+s*(rc5+ - s*(rc6+s*(rc7+s*(rc8+s*(rc9+s*rc10))))))))); - S = one+s*(sc1+s*(sc2+s*sc3)); - } else { - R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+ - s*(rb6+s*(rb7+s*(rb8+s*(rb9+s*rb10))))))))); - S = one+s*(sb1+s*(sb2+s*sb3)); - } - y = (R/S -.5*s) - lsqrtPI_hi; - z += y; - z = exp(z)/ax; - if (x >= 0) - return (one-z); - else - return (z-one); -} - -extern double erfc(x) - double x; -{ - double R,S,P,Q,s,ax,y,z,r,fabs(),__exp__D(); - if (!finite(x)) { - if (isnan(x)) /* erfc(NaN) = NaN */ - return(x); - else if (x > 0) /* erfc(+-inf)=0,2 */ - return 0.0; - else - return 2.0; - } - if ((ax = x) < 0) - ax = -ax; - if (ax < .84375) { /* |x|<0.84375 */ - if (ax < 1.38777878078144568e-17) /* |x|<2**-56 */ - return one-x; - y = x*x; - r = y*(p1+y*(p2+y*(p3+y*(p4+y*(p5+ - y*(p6+y*(p7+y*(p8+y*(p9+y*p10))))))))); - if (ax < .0625) { /* |x|<2**-4 */ - return (one-(x+x*(p0+r))); - } else { - r = x*(p0+r); - r += (x-half); - return (half - r); - } - } - if (ax < 1.25) { /* 0.84375 <= |x| < 1.25 */ - s = ax-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if (x>=0) { - z = one-c; return z - P/Q; - } else { - z = c+P/Q; return one+z; - } - } - if (ax >= 28) /* Out of range */ - if (x>0) - return (tiny*tiny); - else - return (two-tiny); - z = ax; - TRUNC(z); - y = z - ax; y *= (ax+z); - z *= -z; /* Here z + y = -x^2 */ - s = one/(-z-y); /* 1/(x*x) */ - if (ax >= 4) { /* 6 <= ax */ - R = s*(rd1+s*(rd2+s*(rd3+s*(rd4+s*(rd5+ - s*(rd6+s*(rd7+s*(rd8+s*(rd9+s*(rd10 - +s*(rd11+s*(rd12+s*rd13)))))))))))); - y += rd0; - } else if (ax >= 2) { - R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+ - s*(rb6+s*(rb7+s*(rb8+s*(rb9+s*rb10))))))))); - S = one+s*(sb1+s*(sb2+s*sb3)); - y += R/S; - R = -.5*s; - } else { - R = rc0+s*(rc1+s*(rc2+s*(rc3+s*(rc4+s*(rc5+ - s*(rc6+s*(rc7+s*(rc8+s*(rc9+s*rc10))))))))); - S = one+s*(sc1+s*(sc2+s*sc3)); - y += R/S; - R = -.5*s; - } - /* return exp(-x^2 - lsqrtPI_hi + R + y)/x; */ - s = ((R + y) - lsqrtPI_hi) + z; - y = (((z-s) - lsqrtPI_hi) + R) + y; - r = __exp__D(s, y)/x; - if (x>0) - return r; - else - return two-r; -} - -#endif diff --git a/src/lib/libast/uwin/err.c b/src/lib/libast/uwin/err.c deleted file mode 100644 index deebf86f1..000000000 --- a/src/lib/libast/uwin/err.c +++ /dev/null @@ -1,124 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include "FEATURE/uwin" - -#if !_UWIN - -void _STUB_err(){} - -#else - - -/* - * BSD 4.4 compatibility - * - * NOTE: errorv(ERROR_NOID) => the first arg is the printf format - */ - -#include -#include - -#include - -#ifdef __EXPORT__ -#define extern __EXPORT__ -#endif - -static void -errmsg(int level, int code, const char* fmt, va_list ap) -{ - if (!error_info.id) - { - struct _astdll* dp = _ast_getdll(); - char* s; - char* t; - - if (s = dp->_ast__argv[0]) - { - if (t = strrchr(s, '/')) - s = t + 1; - error_info.id = s; - } - } - errorv(fmt, level|ERROR_NOID, ap); - if ((level & ERROR_LEVEL) >= ERROR_ERROR) - exit(code); -} - -extern void verr(int code, const char* fmt, va_list ap) -{ - errmsg(ERROR_ERROR|ERROR_SYSTEM, code, fmt, ap); -} - -extern void err(int code, const char* fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - errmsg(ERROR_ERROR|ERROR_SYSTEM, code, fmt, ap); - va_end(ap); -} - -extern void verrx(int code, const char* fmt, va_list ap) -{ - errmsg(ERROR_ERROR, code, fmt, ap); -} - -extern void errx(int code, const char* fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - errmsg(ERROR_ERROR, code, fmt, ap); - va_end(ap); -} - -extern void vwarn(const char* fmt, va_list ap) -{ - errmsg(ERROR_WARNING|ERROR_SYSTEM, 0, fmt, ap); -} - -extern void warn(const char* fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - errmsg(ERROR_WARNING|ERROR_SYSTEM, 0, fmt, ap); - va_end(ap); -} - -extern void vwarnx(const char* fmt, va_list ap) -{ - errmsg(ERROR_WARNING, 0, fmt, ap); -} - -extern void warnx(const char* fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - errmsg(ERROR_WARNING, 0, fmt, ap); - va_end(ap); -} - -#endif diff --git a/src/lib/libast/uwin/exp.c b/src/lib/libast/uwin/exp.c deleted file mode 100644 index 51db3f76c..000000000 --- a/src/lib/libast/uwin/exp.c +++ /dev/null @@ -1,213 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN - -void _STUB_exp(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* EXP(X) - * RETURN THE EXPONENTIAL OF X - * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * finite(x) - * - * Method: - * 1. Argument Reduction: given the input x, find r and integer k such - * that - * x = k*ln2 + r, |r| <= 0.5*ln2 . - * r will be represented as r := z+c for better accuracy. - * - * 2. Compute exp(r) by - * - * exp(r) = 1 + r + r*R1/(2-R1), - * where - * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))). - * - * 3. exp(x) = 2^k * exp(r) . - * - * Special cases: - * exp(INF) is INF, exp(NaN) is NaN; - * exp(-INF)= 0; - * for finite argument, only exp(0)=1 is exact. - * - * Accuracy: - * exp(x) returns the exponential of x nearly rounded. In a test run - * with 1,156,000 random arguments on a VAX, the maximum observed - * error was 0.869 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) -vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) -vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1) -vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94) -vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F) -vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84) -vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define lnhuge vccast(lnhuge) -#define lntiny vccast(lntiny) -#define invln2 vccast(invln2) -#define p1 vccast(p1) -#define p2 vccast(p2) -#define p3 vccast(p3) -#define p4 vccast(p4) -#define p5 vccast(p5) -#endif - -ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E) -ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93) -ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C) -ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1) -ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0) -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76) -ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) -ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) - -#if !_lib_exp - -extern double exp(x) -double x; -{ - double z,hi,lo,c; - int k; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if( x <= lnhuge ) { - if( x >= lntiny ) { - - /* argument reduction : x --> x - k*ln2 */ - - k=invln2*x+copysign(0.5,x); /* k=NINT(x/ln2) */ - - /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */ - - hi=x-k*ln2hi; - x=hi-(lo=k*ln2lo); - - /* return 2^k*[1+x+x*c/(2+c)] */ - z=x*x; - c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); - return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k); - - } - /* end of x > lntiny */ - - else - /* exp(-big#) underflows to zero */ - if(finite(x)) return(scalb(1.0,-5000)); - - /* exp(-INF) is zero */ - else return(0.0); - } - /* end of x < lnhuge */ - - else - /* exp(INF) is INF, exp(+big#) overflows to INF */ - return( finite(x) ? scalb(1.0,5000) : x); -} - -#endif - -/* returns exp(r = x + c) for |c| < |x| with no overlap. */ - -double __exp__D(x, c) -double x, c; -{ - double z,hi,lo; - int k; - -#if !defined(vax)&&!defined(tahoe) - if (x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if ( x <= lnhuge ) { - if ( x >= lntiny ) { - - /* argument reduction : x --> x - k*ln2 */ - z = invln2*x; - k = (int)z + copysign(.5, x); - - /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */ - - hi=(x-k*ln2hi); /* Exact. */ - x= hi - (lo = k*ln2lo-c); - /* return 2^k*[1+x+x*c/(2+c)] */ - z=x*x; - c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); - c = (x*c)/(2.0-c); - - return scalb(1.+(hi-(lo - c)), k); - } - /* end of x > lntiny */ - - else - /* exp(-big#) underflows to zero */ - if(finite(x)) return(scalb(1.0,-5000)); - - /* exp(-INF) is zero */ - else return(0.0); - } - /* end of x < lnhuge */ - - else - /* exp(INF) is INF, exp(+big#) overflows to INF */ - return( finite(x) ? scalb(1.0,5000) : x); -} - -#endif diff --git a/src/lib/libast/uwin/exp__E.c b/src/lib/libast/uwin/exp__E.c deleted file mode 100644 index 5c131a8e4..000000000 --- a/src/lib/libast/uwin/exp__E.c +++ /dev/null @@ -1,142 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN - -void _STUB_exp__E(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)exp__E.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* exp__E(x,c) - * ASSUMPTION: c << x SO THAT fl(x+c)=x. - * (c is the correction term for x) - * exp__E RETURNS - * - * / exp(x+c) - 1 - x , 1E-19 < |x| < .3465736 - * exp__E(x,c) = | - * \ 0 , |x| < 1E-19. - * - * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS) - * KERNEL FUNCTION OF EXP, EXPM1, POW FUNCTIONS - * CODED IN C BY K.C. NG, 1/31/85; - * REVISED BY K.C. NG on 3/16/85, 4/16/85. - * - * Required system supported function: - * copysign(x,y) - * - * Method: - * 1. Rational approximation. Let r=x+c. - * Based on - * 2 * sinh(r/2) - * exp(r) - 1 = ---------------------- , - * cosh(r/2) - sinh(r/2) - * exp__E(r) is computed using - * x*x (x/2)*W - ( Q - ( 2*P + x*P ) ) - * --- + (c + x*[---------------------------------- + c ]) - * 2 1 - W - * where P := p1*x^2 + p2*x^4, - * Q := q1*x^2 + q2*x^4 (for 56 bits precision, add q3*x^6) - * W := x/2-(Q-x*P), - * - * (See the listing below for the values of p1,p2,q1,q2,q3. The poly- - * nomials P and Q may be regarded as the approximations to sinh - * and cosh : - * sinh(r/2) = r/2 + r * P , cosh(r/2) = 1 + Q . ) - * - * The coefficients were obtained by a special Remez algorithm. - * - * Approximation error: - * - * | exp(x) - 1 | 2**(-57), (IEEE double) - * | ------------ - (exp__E(x,0)+x)/x | <= - * | x | 2**(-69). (VAX D) - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(p1, 1.5150724356786683059E-2 ,3abe,3d78,066a,67e1, -6, .F83ABE67E1066A) -vc(p2, 6.3112487873718332688E-5 ,5b42,3984,0173,48cd, -13, .845B4248CD0173) -vc(q1, 1.1363478204690669916E-1 ,b95a,3ee8,ec45,44a2, -3, .E8B95A44A2EC45) -vc(q2, 1.2624568129896839182E-3 ,7905,3ba5,f5e7,72e4, -9, .A5790572E4F5E7) -vc(q3, 1.5021856115869022674E-6 ,9eb4,36c9,c395,604a, -19, .C99EB4604AC395) - -ic(p1, 1.3887401997267371720E-2, -7, 1.C70FF8B3CC2CF) -ic(p2, 3.3044019718331897649E-5, -15, 1.15317DF4526C4) -ic(q1, 1.1110813732786649355E-1, -4, 1.C719538248597) -ic(q2, 9.9176615021572857300E-4, -10, 1.03FC4CB8C98E8) - -#ifdef vccast -#define p1 vccast(p1) -#define p2 vccast(p2) -#define q1 vccast(q1) -#define q2 vccast(q2) -#define q3 vccast(q3) -#endif - -double __exp__E(x,c) -double x,c; -{ - const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19; - double z,p,q,xp,xh,w; - if(copysign(x,one)>small) { - z = x*x ; - p = z*( p1 +z* p2 ); -#if defined(vax)||defined(tahoe) - q = z*( q1 +z*( q2 +z* q3 )); -#else /* defined(vax)||defined(tahoe) */ - q = z*( q1 +z* q2 ); -#endif /* defined(vax)||defined(tahoe) */ - xp= x*p ; - xh= x*half ; - w = xh-(q-xp) ; - p = p+p; - c += x*((xh*w-(q-(p+xp)))/(one-w)+c); - return(z*half+c); - } - /* end of |x| > small */ - - else { - if(x!=zero) one+small; /* raise the inexact flag */ - return(copysign(zero,x)); - } -} - -#endif diff --git a/src/lib/libast/uwin/expm1.c b/src/lib/libast/uwin/expm1.c deleted file mode 100644 index 609619a85..000000000 --- a/src/lib/libast/uwin/expm1.c +++ /dev/null @@ -1,173 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_expm1 - -void _STUB_expm1(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)expm1.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* EXPM1(X) - * RETURN THE EXPONENTIAL OF X MINUS ONE - * DOUBLE PRECISION (IEEE 53 BITS, VAX D FORMAT 56 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/21/85, 4/16/85. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * finite(x) - * - * Kernel function: - * exp__E(x,c) - * - * Method: - * 1. Argument Reduction: given the input x, find r and integer k such - * that - * x = k*ln2 + r, |r| <= 0.5*ln2 . - * r will be represented as r := z+c for better accuracy. - * - * 2. Compute EXPM1(r)=exp(r)-1 by - * - * EXPM1(r=z+c) := z + exp__E(z,c) - * - * 3. EXPM1(x) = 2^k * ( EXPM1(r) + 1-2^-k ). - * - * Remarks: - * 1. When k=1 and z < -0.25, we use the following formula for - * better accuracy: - * EXPM1(x) = 2 * ( (z+0.5) + exp__E(z,c) ) - * 2. To avoid rounding error in 1-2^-k where k is large, we use - * EXPM1(x) = 2^k * { [z+(exp__E(z,c)-2^-k )] + 1 } - * when k>56. - * - * Special cases: - * EXPM1(INF) is INF, EXPM1(NaN) is NaN; - * EXPM1(-INF)= -1; - * for finite argument, only EXPM1(0)=0 is exact. - * - * Accuracy: - * EXPM1(x) returns the exact (exp(x)-1) nearly rounded. In a test run with - * 1,166,000 random arguments on a VAX, the maximum observed error was - * .872 ulps (units of the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define lnhuge vccast(lnhuge) -#define invln2 vccast(invln2) -#endif - -extern double expm1(x) -double x; -{ - const static double one=1.0, half=1.0/2.0; - double z,hi,lo,c; - int k; -#if defined(vax)||defined(tahoe) - static prec=56; -#else /* defined(vax)||defined(tahoe) */ - static prec=53; -#endif /* defined(vax)||defined(tahoe) */ - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - if( x <= lnhuge ) { - if( x >= -40.0 ) { - - /* argument reduction : x - k*ln2 */ - k= (int)(invln2*x)+copysign(0.5,x); /* k=NINT(x/ln2) */ - hi=x-k*ln2hi ; - z=hi-(lo=k*ln2lo); - c=(hi-z)-lo; - - if(k==0) return(z+__exp__E(z,c)); - if(k==1) - if(z< -0.25) - {x=z+half;x +=__exp__E(z,c); return(x+x);} - else - {z+=__exp__E(z,c); x=half+z; return(x+x);} - /* end of k=1 */ - - else { - if(k<=prec) - { x=one-scalb(one,-k); z += __exp__E(z,c);} - else if(k<100) - { x = __exp__E(z,c)-scalb(one,-k); x+=z; z=one;} - else - { x = __exp__E(z,c)+z; z=one;} - - return (scalb(x+z,k)); - } - } - /* end of x > lnunfl */ - - else - /* expm1(-big#) rounded to -1 (inexact) */ - if(finite(x)) - { ln2hi+ln2lo; return(-one);} - - /* expm1(-INF) is -1 */ - else return(-one); - } - /* end of x < lnhuge */ - - else - /* expm1(INF) is INF, expm1(+big#) overflows to INF */ - return( finite(x) ? scalb(one,5000) : x); -} - -#endif diff --git a/src/lib/libast/uwin/gamma.c b/src/lib/libast/uwin/gamma.c deleted file mode 100644 index 50662305e..000000000 --- a/src/lib/libast/uwin/gamma.c +++ /dev/null @@ -1,343 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_gamma - -void _STUB_gamma(){} - -#else - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * This code by P. McIlroy, Oct 1992; - * - * The financial support of UUNET Communications Services is gratefully - * acknowledged. - */ - -#define gamma ______gamma - -#include -#include -#include "mathimpl.h" - -#undef gamma - -/* METHOD: - * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x)) - * At negative integers, return +Inf, and set errno. - * - * x < 6.5: - * Use argument reduction G(x+1) = xG(x) to reach the - * range [1.066124,2.066124]. Use a rational - * approximation centered at the minimum (x0+1) to - * ensure monotonicity. - * - * x >= 6.5: Use the asymptotic approximation (Stirling's formula) - * adjusted for equal-ripples: - * - * log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x)) - * - * Keep extra precision in multiplying (x-.5)(log(x)-1), to - * avoid premature round-off. - * - * Special values: - * non-positive integer: Set overflow trap; return +Inf; - * x > 171.63: Set overflow trap; return +Inf; - * NaN: Set invalid trap; return NaN - * - * Accuracy: Gamma(x) is accurate to within - * x > 0: error provably < 0.9ulp. - * Maximum observed in 1,000,000 trials was .87ulp. - * x < 0: - * Maximum observed error < 4ulp in 1,000,000 trials. - */ - -static double neg_gam __P((double)); -static double small_gam __P((double)); -static double smaller_gam __P((double)); -static struct Double large_gam __P((double)); -static struct Double ratfun_gam __P((double, double)); - -/* - * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval - * [1.066.., 2.066..] accurate to 4.25e-19. - */ -#define LEFT -.3955078125 /* left boundary for rat. approx */ -#define x0 .461632144968362356785 /* xmin - 1 */ - -#define a0_hi 0.88560319441088874992 -#define a0_lo -.00000000000000004996427036469019695 -#define P0 6.21389571821820863029017800727e-01 -#define P1 2.65757198651533466104979197553e-01 -#define P2 5.53859446429917461063308081748e-03 -#define P3 1.38456698304096573887145282811e-03 -#define P4 2.40659950032711365819348969808e-03 -#define Q0 1.45019531250000000000000000000e+00 -#define Q1 1.06258521948016171343454061571e+00 -#define Q2 -2.07474561943859936441469926649e-01 -#define Q3 -1.46734131782005422506287573015e-01 -#define Q4 3.07878176156175520361557573779e-02 -#define Q5 5.12449347980666221336054633184e-03 -#define Q6 -1.76012741431666995019222898833e-03 -#define Q7 9.35021023573788935372153030556e-05 -#define Q8 6.13275507472443958924745652239e-06 -/* - * Constants for large x approximation (x in [6, Inf]) - * (Accurate to 2.8*10^-19 absolute) - */ -#define lns2pi_hi 0.418945312500000 -#define lns2pi_lo -.000006779295327258219670263595 -#define Pa0 8.33333333333333148296162562474e-02 -#define Pa1 -2.77777777774548123579378966497e-03 -#define Pa2 7.93650778754435631476282786423e-04 -#define Pa3 -5.95235082566672847950717262222e-04 -#define Pa4 8.41428560346653702135821806252e-04 -#define Pa5 -1.89773526463879200348872089421e-03 -#define Pa6 5.69394463439411649408050664078e-03 -#define Pa7 -1.44705562421428915453880392761e-02 - -static const double zero = 0., one = 1.0, tiny = 1e-300; -static int endian; -/* - * TRUNC sets trailing bits in a floating-point number to zero. - * is a temporary variable. - */ -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -extern double gamma(x) - double x; -{ - struct Double u; - endian = (*(int *) &one) ? 1 : 0; - - if (x >= 6) { - if(x > 171.63) - return(one/zero); - u = large_gam(x); - return(__exp__D(u.a, u.b)); - } else if (x >= 1.0 + LEFT + x0) - return (small_gam(x)); - else if (x > 1.e-17) - return (smaller_gam(x)); - else if (x > -1.e-17) { - if (x == 0.0) - if (!_IEEE) return (infnan(ERANGE)); - else return (one/x); - one+1e-20; /* Raise inexact flag. */ - return (one/x); - } else if (!finite(x)) { - if (_IEEE) /* x = NaN, -Inf */ - return (x*x); - else - return (infnan(EDOM)); - } else - return (neg_gam(x)); -} -/* - * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error. - */ -static struct Double -large_gam(x) - double x; -{ - double z, p; - struct Double t, u, v; - - z = one/(x*x); - p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7)))))); - p = p/x; - - u = __log__D(x); - u.a -= one; - v.a = (x -= .5); - TRUNC(v.a); - v.b = x - v.a; - t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */ - t.b = v.b*u.a + x*u.b; - /* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */ - t.b += lns2pi_lo; t.b += p; - u.a = lns2pi_hi + t.b; u.a += t.a; - u.b = t.a - u.a; - u.b += lns2pi_hi; u.b += t.b; - return (u); -} -/* - * Good to < 1 ulp. (Provably .90 ulp; .87 ulp on 1,000,000 runs.) - * It also has correct monotonicity. - */ -static double -small_gam(x) - double x; -{ - double y, ym1, t; - struct Double yy, r; - y = x - one; - ym1 = y - one; - if (y <= 1.0 + (LEFT + x0)) { - yy = ratfun_gam(y - x0, 0); - return (yy.a + yy.b); - } - r.a = y; - TRUNC(r.a); - yy.a = r.a - one; - y = ym1; - yy.b = r.b = y - yy.a; - /* Argument reduction: G(x+1) = x*G(x) */ - for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) { - t = r.a*yy.a; - r.b = r.a*yy.b + y*r.b; - r.a = t; - TRUNC(r.a); - r.b += (t - r.a); - } - /* Return r*gamma(y). */ - yy = ratfun_gam(y - x0, 0); - y = r.b*(yy.a + yy.b) + r.a*yy.b; - y += yy.a*r.a; - return (y); -} -/* - * Good on (0, 1+x0+LEFT]. Accurate to 1ulp. - */ -static double -smaller_gam(x) - double x; -{ - double t, d; - struct Double r, xx; - if (x < x0 + LEFT) { - t = x, TRUNC(t); - d = (t+x)*(x-t); - t *= t; - xx.a = (t + x), TRUNC(xx.a); - xx.b = x - xx.a; xx.b += t; xx.b += d; - t = (one-x0); t += x; - d = (one-x0); d -= t; d += x; - x = xx.a + xx.b; - } else { - xx.a = x, TRUNC(xx.a); - xx.b = x - xx.a; - t = x - x0; - d = (-x0 -t); d += x; - } - r = ratfun_gam(t, d); - d = r.a/x, TRUNC(d); - r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b; - return (d + r.a/x); -} -/* - * returns (z+c)^2 * P(z)/Q(z) + a0 - */ -static struct Double -ratfun_gam(z, c) - double z, c; -{ - double p, q; - struct Double r, t; - - q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8))))))); - p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4))); - - /* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */ - p = p/q; - t.a = z, TRUNC(t.a); /* t ~= z + c */ - t.b = (z - t.a) + c; - t.b *= (t.a + z); - q = (t.a *= t.a); /* t = (z+c)^2 */ - TRUNC(t.a); - t.b += (q - t.a); - r.a = p, TRUNC(r.a); /* r = P/Q */ - r.b = p - r.a; - t.b = t.b*p + t.a*r.b + a0_lo; - t.a *= r.a; /* t = (z+c)^2*(P/Q) */ - r.a = t.a + a0_hi, TRUNC(r.a); - r.b = ((a0_hi-r.a) + t.a) + t.b; - return (r); /* r = a0 + t */ -} - -static double -neg_gam(x) - double x; -{ - int sgn = 1; - struct Double lg, lsine; - double y, z; - - y = floor(x + .5); - if (y == x) /* Negative integer. */ - if(!_IEEE) - return (infnan(ERANGE)); - else - return (one/zero); - z = fabs(x - y); - y = .5*ceil(x); - if (y == ceil(y)) - sgn = -1; - if (z < .25) - z = sin(M_PI*z); - else - z = cos(M_PI*(0.5-z)); - /* Special case: G(1-x) = Inf; G(x) may be nonzero. */ - if (x < -170) { - if (x < -190) - return ((double)sgn*tiny*tiny); - y = one - x; /* exact: 128 < |x| < 255 */ - lg = large_gam(y); - lsine = __log__D(M_PI/z); /* = TRUNC(log(u)) + small */ - lg.a -= lsine.a; /* exact (opposite signs) */ - lg.b -= lsine.b; - y = -(lg.a + lg.b); - z = (y + lg.a) + lg.b; - y = __exp__D(y, z); - if (sgn < 0) y = -y; - return (y); - } - y = one-x; - if (one-y == x) - y = gamma(y); - else /* 1-x is inexact */ - y = -x*gamma(-x); - if (sgn < 0) y = -y; - return (M_PI / (y*z)); -} - -#endif diff --git a/src/lib/libast/uwin/getpass.c b/src/lib/libast/uwin/getpass.c deleted file mode 100644 index 67c8927b8..000000000 --- a/src/lib/libast/uwin/getpass.c +++ /dev/null @@ -1,78 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_getpass - -void _STUB_getpass(){} - -#else - - -#define getpass ______getpass - -#include -#include -#include - -#undef getpass - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -static int interrupt; -static void handler(int sig) -{ - interrupt++; -} - -extern char* getpass(const char *prompt) -{ - struct termios told,tnew; - Sfio_t *iop; - static char *cp, passwd[32]; - void (*savesig)(int); - if(!(iop = sfopen((Sfio_t*)0, "/dev/tty", "r"))) - return(0); - if(tcgetattr(sffileno(iop),&told) < 0) - return(0); - interrupt = 0; - tnew = told; - tnew.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL); - if(tcsetattr(sffileno(iop),TCSANOW,&tnew) < 0) - return(0); - savesig = signal(SIGINT, handler); - sfputr(sfstderr,prompt,-1); - if(cp = sfgetr(iop,'\n',1)) - strncpy(passwd,cp,sizeof(passwd)-1); - tcsetattr(sffileno(iop),TCSANOW,&told); - sfputc(sfstderr,'\n'); - sfclose(iop); - signal(SIGINT, savesig); - if(interrupt) - kill(getpid(),SIGINT); - return(cp?passwd:0); -} - -#endif diff --git a/src/lib/libast/uwin/lgamma.c b/src/lib/libast/uwin/lgamma.c deleted file mode 100644 index 038ad0c61..000000000 --- a/src/lib/libast/uwin/lgamma.c +++ /dev/null @@ -1,316 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_lgamma - -void _STUB_lgamma(){} - -#else - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)lgamma.c 8.2 (Berkeley) 11/30/93"; -#endif /* not lint */ - -/* - * Coded by Peter McIlroy, Nov 1992; - * - * The financial support of UUNET Communications Services is gratefully - * acknowledged. - */ - -#define gamma ______gamma -#define lgamma ______lgamma - -#include -#include -#include "mathimpl.h" - -#undef gamma -#undef lgamma - -/* Log gamma function. - * Error: x > 0 error < 1.3ulp. - * x > 4, error < 1ulp. - * x > 9, error < .6ulp. - * x < 0, all bets are off. (When G(x) ~ 1, log(G(x)) ~ 0) - * Method: - * x > 6: - * Use the asymptotic expansion (Stirling's Formula) - * 0 < x < 6: - * Use gamma(x+1) = x*gamma(x) for argument reduction. - * Use rational approximation in - * the range 1.2, 2.5 - * Two approximations are used, one centered at the - * minimum to ensure monotonicity; one centered at 2 - * to maintain small relative error. - * x < 0: - * Use the reflection formula, - * G(1-x)G(x) = PI/sin(PI*x) - * Special values: - * non-positive integer returns +Inf. - * NaN returns NaN -*/ -static int endian; -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -/* double and float have same size exponent field */ -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -static double small_lgam(double); -static double large_lgam(double); -static double neg_lgam(double); -static double zero = 0.0, one = 1.0; -int signgam; - -#define UNDERFL (1e-1020 * 1e-1020) - -#define LEFT (1.0 - (x0 + .25)) -#define RIGHT (x0 - .218) -/* - * Constants for approximation in [1.244,1.712] -*/ -#define x0 0.461632144968362356785 -#define x0_lo -.000000000000000015522348162858676890521 -#define a0_hi -0.12148629128932952880859 -#define a0_lo .0000000007534799204229502 -#define r0 -2.771227512955130520e-002 -#define r1 -2.980729795228150847e-001 -#define r2 -3.257411333183093394e-001 -#define r3 -1.126814387531706041e-001 -#define r4 -1.129130057170225562e-002 -#define r5 -2.259650588213369095e-005 -#define s0 1.714457160001714442e+000 -#define s1 2.786469504618194648e+000 -#define s2 1.564546365519179805e+000 -#define s3 3.485846389981109850e-001 -#define s4 2.467759345363656348e-002 -/* - * Constants for approximation in [1.71, 2.5] -*/ -#define a1_hi 4.227843350984671344505727574870e-01 -#define a1_lo 4.670126436531227189e-18 -#define p0 3.224670334241133695662995251041e-01 -#define p1 3.569659696950364669021382724168e-01 -#define p2 1.342918716072560025853732668111e-01 -#define p3 1.950702176409779831089963408886e-02 -#define p4 8.546740251667538090796227834289e-04 -#define q0 1.000000000000000444089209850062e+00 -#define q1 1.315850076960161985084596381057e+00 -#define q2 6.274644311862156431658377186977e-01 -#define q3 1.304706631926259297049597307705e-01 -#define q4 1.102815279606722369265536798366e-02 -#define q5 2.512690594856678929537585620579e-04 -#define q6 -1.003597548112371003358107325598e-06 -/* - * Stirling's Formula, adjusted for equal-ripple. x in [6,Inf]. -*/ -#define lns2pi .418938533204672741780329736405 -#define pb0 8.33333333333333148296162562474e-02 -#define pb1 -2.77777777774548123579378966497e-03 -#define pb2 7.93650778754435631476282786423e-04 -#define pb3 -5.95235082566672847950717262222e-04 -#define pb4 8.41428560346653702135821806252e-04 -#define pb5 -1.89773526463879200348872089421e-03 -#define pb6 5.69394463439411649408050664078e-03 -#define pb7 -1.44705562421428915453880392761e-02 - -extern __pure double lgamma(double x) -{ - double r; - - signgam = 1; - endian = ((*(int *) &one)) ? 1 : 0; - - if (!finite(x)) - if (_IEEE) - return (x+x); - else return (infnan(EDOM)); - - if (x > 6 + RIGHT) { - r = large_lgam(x); - return (r); - } else if (x > 1e-16) - return (small_lgam(x)); - else if (x > -1e-16) { - if (x < 0) - signgam = -1, x = -x; - return (-log(x)); - } else - return (neg_lgam(x)); -} - -static double -large_lgam(double x) -{ - double z, p, x1; - struct Double t, u, v; - u = __log__D(x); - u.a -= 1.0; - if (x > 1e15) { - v.a = x - 0.5; - TRUNC(v.a); - v.b = (x - v.a) - 0.5; - t.a = u.a*v.a; - t.b = x*u.b + v.b*u.a; - if (_IEEE == 0 && !finite(t.a)) - return(infnan(ERANGE)); - return(t.a + t.b); - } - x1 = 1./x; - z = x1*x1; - p = pb0+z*(pb1+z*(pb2+z*(pb3+z*(pb4+z*(pb5+z*(pb6+z*pb7)))))); - /* error in approximation = 2.8e-19 */ - - p = p*x1; /* error < 2.3e-18 absolute */ - /* 0 < p < 1/64 (at x = 5.5) */ - v.a = x = x - 0.5; - TRUNC(v.a); /* truncate v.a to 26 bits. */ - v.b = x - v.a; - t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */ - t.b = v.b*u.a + x*u.b; - t.b += p; t.b += lns2pi; /* return t + lns2pi + p */ - return (t.a + t.b); -} - -static double -small_lgam(double x) -{ - int x_int; - double y, z, t, r = 0, p, q, hi, lo; - struct Double rr; - x_int = (int)(x + .5); - y = x - x_int; - if (x_int <= 2 && y > RIGHT) { - t = y - x0; - y--; x_int++; - goto CONTINUE; - } else if (y < -LEFT) { - t = y +(1.0-x0); -CONTINUE: - z = t - x0_lo; - p = r0+z*(r1+z*(r2+z*(r3+z*(r4+z*r5)))); - q = s0+z*(s1+z*(s2+z*(s3+z*s4))); - r = t*(z*(p/q) - x0_lo); - t = .5*t*t; - z = 1.0; - switch (x_int) { - case 6: z = (y + 5); - case 5: z *= (y + 4); - case 4: z *= (y + 3); - case 3: z *= (y + 2); - rr = __log__D(z); - rr.b += a0_lo; rr.a += a0_hi; - return(((r+rr.b)+t+rr.a)); - case 2: return(((r+a0_lo)+t)+a0_hi); - case 0: r -= log1p(x); - default: rr = __log__D(x); - rr.a -= a0_hi; rr.b -= a0_lo; - return(((r - rr.b) + t) - rr.a); - } - } else { - p = p0+y*(p1+y*(p2+y*(p3+y*p4))); - q = q0+y*(q1+y*(q2+y*(q3+y*(q4+y*(q5+y*q6))))); - p = p*(y/q); - t = (double)(float) y; - z = y-t; - hi = (double)(float) (p+a1_hi); - lo = a1_hi - hi; lo += p; lo += a1_lo; - r = lo*y + z*hi; /* q + r = y*(a0+p/q) */ - q = hi*t; - z = 1.0; - switch (x_int) { - case 6: z = (y + 5); - case 5: z *= (y + 4); - case 4: z *= (y + 3); - case 3: z *= (y + 2); - rr = __log__D(z); - r += rr.b; r += q; - return(rr.a + r); - case 2: return (q+ r); - case 0: rr = __log__D(x); - r -= rr.b; r -= log1p(x); - r += q; r-= rr.a; - return(r); - default: rr = __log__D(x); - r -= rr.b; - q -= rr.a; - return (r+q); - } - } -} - -static double -neg_lgam(double x) -{ - int xi; - double y, z, one = 1.0, zero = 0.0; - extern double gamma(); - - /* avoid destructive cancellation as much as possible */ - if (x > -170) { - xi = (int)x; - if (xi == x) - if (_IEEE) - return(one/zero); - else - return(infnan(ERANGE)); - y = gamma(x); - if (y < 0) - y = -y, signgam = -1; - return (log(y)); - } - z = floor(x + .5); - if (z == x) { /* convention: G(-(integer)) -> +Inf */ - if (_IEEE) - return (one/zero); - else - return (infnan(ERANGE)); - } - y = .5*ceil(x); - if (y == ceil(y)) - signgam = -1; - x = -x; - z = fabs(x + z); /* 0 < z <= .5 */ - if (z < .25) - z = sin(M_PI*z); - else - z = cos(M_PI*(0.5-z)); - z = log(M_PI/(z*x)); - y = large_lgam(x); - return (z - y); -} - -#endif diff --git a/src/lib/libast/uwin/log.c b/src/lib/libast/uwin/log.c deleted file mode 100644 index e9365a336..000000000 --- a/src/lib/libast/uwin/log.c +++ /dev/null @@ -1,496 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN - -void _STUB_log(){} - -#else - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93"; -#endif /* not lint */ - -#include -#include - -#include "mathimpl.h" - -/* Table-driven natural logarithm. - * - * This code was derived, with minor modifications, from: - * Peter Tang, "Table-Driven Implementation of the - * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. - * Math Software, vol 16. no 4, pp 378-400, Dec 1990). - * - * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, - * where F = j/128 for j an integer in [0, 128]. - * - * log(2^m) = log2_hi*m + log2_tail*m - * since m is an integer, the dominant term is exact. - * m has at most 10 digits (for subnormal numbers), - * and log2_hi has 11 trailing zero bits. - * - * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h - * logF_hi[] + 512 is exact. - * - * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... - * the leading term is calculated to extra precision in two - * parts, the larger of which adds exactly to the dominant - * m and F terms. - * There are two cases: - * 1. when m, j are non-zero (m | j), use absolute - * precision for the leading term. - * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). - * In this case, use a relative precision of 24 bits. - * (This is done differently in the original paper) - * - * Special cases: - * 0 return signalling -Inf - * neg return signalling NaN - * +Inf return +Inf -*/ - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define endian (((*(int *) &one)) ? 1 : 0) -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -#define N 128 - -/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128. - * Used for generation of extend precision logarithms. - * The constant 35184372088832 is 2^45, so the divide is exact. - * It ensures correct reading of logF_head, even for inaccurate - * decimal-to-binary conversion routines. (Everybody gets the - * right answer for integers less than 2^53.) - * Values for log(F) were generated using error < 10^-57 absolute - * with the bc -l package. -*/ -static double A1 = .08333333333333178827; -static double A2 = .01250000000377174923; -static double A3 = .002232139987919447809; -static double A4 = .0004348877777076145742; - -static double logF_head[N+1] = { - 0., - .007782140442060381246, - .015504186535963526694, - .023167059281547608406, - .030771658666765233647, - .038318864302141264488, - .045809536031242714670, - .053244514518837604555, - .060624621816486978786, - .067950661908525944454, - .075223421237524235039, - .082443669210988446138, - .089612158689760690322, - .096729626458454731618, - .103796793681567578460, - .110814366340264314203, - .117783035656430001836, - .124703478501032805070, - .131576357788617315236, - .138402322859292326029, - .145182009844575077295, - .151916042025732167530, - .158605030176659056451, - .165249572895390883786, - .171850256926518341060, - .178407657472689606947, - .184922338493834104156, - .191394852999565046047, - .197825743329758552135, - .204215541428766300668, - .210564769107350002741, - .216873938300523150246, - .223143551314024080056, - .229374101064877322642, - .235566071312860003672, - .241719936886966024758, - .247836163904594286577, - .253915209980732470285, - .259957524436686071567, - .265963548496984003577, - .271933715484010463114, - .277868451003087102435, - .283768173130738432519, - .289633292582948342896, - .295464212893421063199, - .301261330578199704177, - .307025035294827830512, - .312755710004239517729, - .318453731118097493890, - .324119468654316733591, - .329753286372579168528, - .335355541920762334484, - .340926586970454081892, - .346466767346100823488, - .351976423156884266063, - .357455888922231679316, - .362905493689140712376, - .368325561158599157352, - .373716409793814818840, - .379078352934811846353, - .384411698910298582632, - .389716751140440464951, - .394993808240542421117, - .400243164127459749579, - .405465108107819105498, - .410659924985338875558, - .415827895143593195825, - .420969294644237379543, - .426084395310681429691, - .431173464818130014464, - .436236766774527495726, - .441274560805140936281, - .446287102628048160113, - .451274644139630254358, - .456237433481874177232, - .461175715122408291790, - .466089729924533457960, - .470979715219073113985, - .475845904869856894947, - .480688529345570714212, - .485507815781602403149, - .490303988045525329653, - .495077266798034543171, - .499827869556611403822, - .504556010751912253908, - .509261901790523552335, - .513945751101346104405, - .518607764208354637958, - .523248143765158602036, - .527867089620485785417, - .532464798869114019908, - .537041465897345915436, - .541597282432121573947, - .546132437597407260909, - .550647117952394182793, - .555141507540611200965, - .559615787935399566777, - .564070138285387656651, - .568504735352689749561, - .572919753562018740922, - .577315365035246941260, - .581691739635061821900, - .586049045003164792433, - .590387446602107957005, - .594707107746216934174, - .599008189645246602594, - .603290851438941899687, - .607555250224322662688, - .611801541106615331955, - .616029877215623855590, - .620240409751204424537, - .624433288012369303032, - .628608659422752680256, - .632766669570628437213, - .636907462236194987781, - .641031179420679109171, - .645137961373620782978, - .649227946625615004450, - .653301272011958644725, - .657358072709030238911, - .661398482245203922502, - .665422632544505177065, - .669430653942981734871, - .673422675212350441142, - .677398823590920073911, - .681359224807238206267, - .685304003098281100392, - .689233281238557538017, - .693147180560117703862 -}; - -static double logF_tail[N+1] = { - 0., - -.00000000000000543229938420049, - .00000000000000172745674997061, - -.00000000000001323017818229233, - -.00000000000001154527628289872, - -.00000000000000466529469958300, - .00000000000005148849572685810, - -.00000000000002532168943117445, - -.00000000000005213620639136504, - -.00000000000001819506003016881, - .00000000000006329065958724544, - .00000000000008614512936087814, - -.00000000000007355770219435028, - .00000000000009638067658552277, - .00000000000007598636597194141, - .00000000000002579999128306990, - -.00000000000004654729747598444, - -.00000000000007556920687451336, - .00000000000010195735223708472, - -.00000000000017319034406422306, - -.00000000000007718001336828098, - .00000000000010980754099855238, - -.00000000000002047235780046195, - -.00000000000008372091099235912, - .00000000000014088127937111135, - .00000000000012869017157588257, - .00000000000017788850778198106, - .00000000000006440856150696891, - .00000000000016132822667240822, - -.00000000000007540916511956188, - -.00000000000000036507188831790, - .00000000000009120937249914984, - .00000000000018567570959796010, - -.00000000000003149265065191483, - -.00000000000009309459495196889, - .00000000000017914338601329117, - -.00000000000001302979717330866, - .00000000000023097385217586939, - .00000000000023999540484211737, - .00000000000015393776174455408, - -.00000000000036870428315837678, - .00000000000036920375082080089, - -.00000000000009383417223663699, - .00000000000009433398189512690, - .00000000000041481318704258568, - -.00000000000003792316480209314, - .00000000000008403156304792424, - -.00000000000034262934348285429, - .00000000000043712191957429145, - -.00000000000010475750058776541, - -.00000000000011118671389559323, - .00000000000037549577257259853, - .00000000000013912841212197565, - .00000000000010775743037572640, - .00000000000029391859187648000, - -.00000000000042790509060060774, - .00000000000022774076114039555, - .00000000000010849569622967912, - -.00000000000023073801945705758, - .00000000000015761203773969435, - .00000000000003345710269544082, - -.00000000000041525158063436123, - .00000000000032655698896907146, - -.00000000000044704265010452446, - .00000000000034527647952039772, - -.00000000000007048962392109746, - .00000000000011776978751369214, - -.00000000000010774341461609578, - .00000000000021863343293215910, - .00000000000024132639491333131, - .00000000000039057462209830700, - -.00000000000026570679203560751, - .00000000000037135141919592021, - -.00000000000017166921336082431, - -.00000000000028658285157914353, - -.00000000000023812542263446809, - .00000000000006576659768580062, - -.00000000000028210143846181267, - .00000000000010701931762114254, - .00000000000018119346366441110, - .00000000000009840465278232627, - -.00000000000033149150282752542, - -.00000000000018302857356041668, - -.00000000000016207400156744949, - .00000000000048303314949553201, - -.00000000000071560553172382115, - .00000000000088821239518571855, - -.00000000000030900580513238244, - -.00000000000061076551972851496, - .00000000000035659969663347830, - .00000000000035782396591276383, - -.00000000000046226087001544578, - .00000000000062279762917225156, - .00000000000072838947272065741, - .00000000000026809646615211673, - -.00000000000010960825046059278, - .00000000000002311949383800537, - -.00000000000058469058005299247, - -.00000000000002103748251144494, - -.00000000000023323182945587408, - -.00000000000042333694288141916, - -.00000000000043933937969737844, - .00000000000041341647073835565, - .00000000000006841763641591466, - .00000000000047585534004430641, - .00000000000083679678674757695, - -.00000000000085763734646658640, - .00000000000021913281229340092, - -.00000000000062242842536431148, - -.00000000000010983594325438430, - .00000000000065310431377633651, - -.00000000000047580199021710769, - -.00000000000037854251265457040, - .00000000000040939233218678664, - .00000000000087424383914858291, - .00000000000025218188456842882, - -.00000000000003608131360422557, - -.00000000000050518555924280902, - .00000000000078699403323355317, - -.00000000000067020876961949060, - .00000000000016108575753932458, - .00000000000058527188436251509, - -.00000000000035246757297904791, - -.00000000000018372084495629058, - .00000000000088606689813494916, - .00000000000066486268071468700, - .00000000000063831615170646519, - .00000000000025144230728376072, - -.00000000000017239444525614834 -}; - -#if !_lib_log - -extern double -#ifdef _ANSI_SOURCE -log(double x) -#else -log(x) double x; -#endif -{ - int m, j; - double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0; - volatile double u1; - - /* Catch special cases */ - if (x <= 0) - if (_IEEE && x == zero) /* log(0) = -Inf */ - return (-one/zero); - else if (_IEEE) /* log(neg) = NaN */ - return (zero/zero); - else if (x == zero) /* NOT REACHED IF _IEEE */ - return (infnan(-ERANGE)); - else - return (infnan(EDOM)); - else if (!finite(x)) - if (_IEEE) /* x = NaN, Inf */ - return (x+x); - else - return (infnan(ERANGE)); - - /* Argument reduction: 1 <= g < 2; x/2^m = g; */ - /* y = F*(1 + f/F) for |f| <= 2^-8 */ - - m = logb(x); - g = ldexp(x, -m); - if (_IEEE && m == -1022) { - j = logb(g), m += j; - g = ldexp(g, -j); - } - j = N*(g-1) + .5; - F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */ - f = g - F; - - /* Approximate expansion for log(1+f/F) ~= u + q */ - g = 1/(2*F+f); - u = 2*f*g; - v = u*u; - q = u*v*(A1 + v*(A2 + v*(A3 + v*A4))); - - /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8, - * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits. - * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750 - */ - if (m | j) - u1 = u + 513, u1 -= 513; - - /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero; - * u1 = u to 24 bits. - */ - else - u1 = u, TRUNC(u1); - u2 = (2.0*(f - F*u1) - u1*f) * g; - /* u1 + u2 = 2f/(2F+f) to extra precision. */ - - /* log(x) = log(2^m*F*(1+f/F)) = */ - /* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q); */ - /* (exact) + (tiny) */ - - u1 += m*logF_head[N] + logF_head[j]; /* exact */ - u2 = (u2 + logF_tail[j]) + q; /* tiny */ - u2 += logF_tail[N]*m; - return (u1 + u2); -} - -#endif - -/* - * Extra precision variant, returning struct {double a, b;}; - * log(x) = a+b to 63 bits, with a is rounded to 26 bits. - */ -struct Double -#ifdef _ANSI_SOURCE -__log__D(double x) -#else -__log__D(x) double x; -#endif -{ - int m, j; - double F, f, g, q, u, v, u2, one = 1.0; - volatile double u1; - struct Double r; - - /* Argument reduction: 1 <= g < 2; x/2^m = g; */ - /* y = F*(1 + f/F) for |f| <= 2^-8 */ - - m = (int)logb(x); - g = ldexp(x, -m); - if (_IEEE && m == -1022) { - j = (int)logb(g), m += j; - g = ldexp(g, -j); - } - j = (int)(N*(g-1) + .5); - F = (1.0/N) * j + 1; - f = g - F; - - g = 1/(2*F+f); - u = 2*f*g; - v = u*u; - q = u*v*(A1 + v*(A2 + v*(A3 + v*A4))); - if (m | j) - u1 = u + 513, u1 -= 513; - else - u1 = u, TRUNC(u1); - u2 = (2.0*(f - F*u1) - u1*f) * g; - - u1 += m*logF_head[N] + logF_head[j]; - - u2 += logF_tail[j]; u2 += q; - u2 += logF_tail[N]*m; - r.a = u1 + u2; /* Only difference is here */ - TRUNC(r.a); - r.b = (u1 - r.a) + u2; - return (r); -} - -#endif diff --git a/src/lib/libast/uwin/log1p.c b/src/lib/libast/uwin/log1p.c deleted file mode 100644 index f599a4d3c..000000000 --- a/src/lib/libast/uwin/log1p.c +++ /dev/null @@ -1,176 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_log1p - -void _STUB_log1p(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)log1p.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* LOG1P(x) - * RETURN THE LOGARITHM OF 1+x - * DOUBLE PRECISION (VAX D FORMAT 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/24/85, 4/16/85. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * logb(x) - * finite(x) - * - * Required kernel function: - * log__L(z) - * - * Method : - * 1. Argument Reduction: find k and f such that - * 1+x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * 2. Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * log(1+f) is computed by - * - * log(1+f) = 2s + s*log__L(s*s) - * where - * log__L(z) = z*(L1 + z*(L2 + z*(... (L6 + z*L7)...))) - * - * See log__L() for the values of the coefficients. - * - * 3. Finally, log(1+x) = k*ln2 + log(1+f). - * - * Remarks 1. In step 3 n*ln2 will be stored in two floating point numbers - * n*ln2hi + n*ln2lo, where ln2hi is chosen such that the last - * 20 bits (for VAX D format), or the last 21 bits ( for IEEE - * double) is 0. This ensures n*ln2hi is exactly representable. - * 2. In step 1, f may not be representable. A correction term c - * for f is computed. It follows that the correction term for - * f - t (the leading term of log(1+f) in step 2) is c-c*x. We - * add this correction term to n*ln2lo to attenuate the error. - * - * - * Special cases: - * log1p(x) is NaN with signal if x < -1; log1p(NaN) is NaN with no signal; - * log1p(INF) is +INF; log1p(-1) is -INF with signal; - * only log1p(0)=0 is exact for finite argument. - * - * Accuracy: - * log1p(x) returns the exact log(1+x) nearly rounded. In a test run - * with 1,536,000 random arguments on a VAX, the maximum observed - * error was .846 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define sqrt2 vccast(sqrt2) -#endif - -extern double log1p(x) -double x; -{ - const static double zero=0.0, negone= -1.0, one=1.0, - half=1.0/2.0, small=1.0E-20; /* 1+small == 1 */ - double z,s,t,c; - int k; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - if(finite(x)) { - if( x > negone ) { - - /* argument reduction */ - if(copysign(x,one)= sqrt2 ) - { k += 1 ; z *= half; t *= half; } - t += negone; x = z + t; - c = (t-x)+z ; /* correction term for x */ - - /* compute log(1+x) */ - s = x/(2+x); t = x*x*half; - c += (k*ln2lo-c*x); - z = c+s*(t+__log__L(s*s)); - x += (z - t) ; - - return(k*ln2hi+x); - } - /* end of if (x > negone) */ - - else { -#if defined(vax)||defined(tahoe) - if ( x == negone ) - return (infnan(-ERANGE)); /* -INF */ - else - return (infnan(EDOM)); /* NaN */ -#else /* defined(vax)||defined(tahoe) */ - /* x = -1, return -INF with signal */ - if ( x == negone ) return( negone/zero ); - - /* negative argument for log, return NaN with signal */ - else return ( zero / zero ); -#endif /* defined(vax)||defined(tahoe) */ - } - } - /* end of if (finite(x)) */ - - /* log(-INF) is NaN */ - else if(x<0) - return(zero/zero); - - /* log(+INF) is INF */ - else return(x); -} - -#endif diff --git a/src/lib/libast/uwin/log__L.c b/src/lib/libast/uwin/log__L.c deleted file mode 100644 index 3276e694b..000000000 --- a/src/lib/libast/uwin/log__L.c +++ /dev/null @@ -1,116 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN - -void _STUB_log__L(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)log__L.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* log__L(Z) - * LOG(1+X) - 2S X - * RETURN --------------- WHERE Z = S*S, S = ------- , 0 <= Z <= .0294... - * S 2 + X - * - * DOUBLE PRECISION (VAX D FORMAT 56 bits or IEEE DOUBLE 53 BITS) - * KERNEL FUNCTION FOR LOG; TO BE USED IN LOG1P, LOG, AND POW FUNCTIONS - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. Ng, 2/3/85, 4/16/85. - * - * Method : - * 1. Polynomial approximation: let s = x/(2+x). - * Based on log(1+x) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * - * (log(1+x) - 2s)/s is computed by - * - * z*(L1 + z*(L2 + z*(... (L7 + z*L8)...))) - * - * where z=s*s. (See the listing below for Lk's values.) The - * coefficients are obtained by a special Remez algorithm. - * - * Accuracy: - * Assuming no rounding error, the maximum magnitude of the approximation - * error (absolute) is 2**(-58.49) for IEEE double, and 2**(-63.63) - * for VAX D format. - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(L1, 6.6666666666666703212E-1 ,aaaa,402a,aac5,aaaa, 0, .AAAAAAAAAAAAC5) -vc(L2, 3.9999999999970461961E-1 ,cccc,3fcc,2684,cccc, -1, .CCCCCCCCCC2684) -vc(L3, 2.8571428579395698188E-1 ,4924,3f92,5782,92f8, -1, .92492492F85782) -vc(L4, 2.2222221233634724402E-1 ,8e38,3f63,af2c,39b7, -2, .E38E3839B7AF2C) -vc(L5, 1.8181879517064680057E-1 ,2eb4,3f3a,655e,cc39, -2, .BA2EB4CC39655E) -vc(L6, 1.5382888777946145467E-1 ,8551,3f1d,781d,e8c5, -2, .9D8551E8C5781D) -vc(L7, 1.3338356561139403517E-1 ,95b3,3f08,cd92,907f, -2, .8895B3907FCD92) -vc(L8, 1.2500000000000000000E-1 ,0000,3f00,0000,0000, -2, .80000000000000) - -ic(L1, 6.6666666666667340202E-1, -1, 1.5555555555592) -ic(L2, 3.9999999999416702146E-1, -2, 1.999999997FF24) -ic(L3, 2.8571428742008753154E-1, -2, 1.24924941E07B4) -ic(L4, 2.2222198607186277597E-1, -3, 1.C71C52150BEA6) -ic(L5, 1.8183562745289935658E-1, -3, 1.74663CC94342F) -ic(L6, 1.5314087275331442206E-1, -3, 1.39A1EC014045B) -ic(L7, 1.4795612545334174692E-1, -3, 1.2F039F0085122) - -#ifdef vccast -#define L1 vccast(L1) -#define L2 vccast(L2) -#define L3 vccast(L3) -#define L4 vccast(L4) -#define L5 vccast(L5) -#define L6 vccast(L6) -#define L7 vccast(L7) -#define L8 vccast(L8) -#endif - -double __log__L(z) -double z; -{ -#if defined(vax)||defined(tahoe) - return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*(L7+z*L8)))))))); -#else /* defined(vax)||defined(tahoe) */ - return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*L7))))))); -#endif /* defined(vax)||defined(tahoe) */ -} - -#endif diff --git a/src/lib/libast/uwin/mathimpl.h b/src/lib/libast/uwin/mathimpl.h deleted file mode 100644 index 12857f0b2..000000000 --- a/src/lib/libast/uwin/mathimpl.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93 - */ - -#include -#include - -#if defined(vax)||defined(tahoe) - -/* Deal with different ways to concatenate in cpp */ -# ifdef __STDC__ -# define cat3(a,b,c) a ## b ## c -# else -# define cat3(a,b,c) a/**/b/**/c -# endif - -/* Deal with vax/tahoe byte order issues */ -# ifdef vax -# define cat3t(a,b,c) cat3(a,b,c) -# else -# define cat3t(a,b,c) cat3(a,c,b) -# endif - -# define vccast(name) (*(const double *)(cat3(name,,x))) - - /* - * Define a constant to high precision on a Vax or Tahoe. - * - * Args are the name to define, the decimal floating point value, - * four 16-bit chunks of the float value in hex - * (because the vax and tahoe differ in float format!), the power - * of 2 of the hex-float exponent, and the hex-float mantissa. - * Most of these arguments are not used at compile time; they are - * used in a post-check to make sure the constants were compiled - * correctly. - * - * People who want to use the constant will have to do their own - * #define foo vccast(foo) - * since CPP cannot do this for them from inside another macro (sigh). - * We define "vccast" if this needs doing. - */ -# define vc(name, value, x1,x2,x3,x4, bexp, xval) \ - const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; - -# define ic(name, value, bexp, xval) ; - -#else /* vax or tahoe */ - - /* Hooray, we have an IEEE machine */ -# undef vccast -# define vc(name, value, x1,x2,x3,x4, bexp, xval) ; - -# define ic(name, value, bexp, xval) \ - const static double name = value; - -#endif /* defined(vax)||defined(tahoe) */ - - -/* - * Functions internal to the math package, yet not static. - */ -extern double __exp__E(); -extern double __log__L(); - -struct Double {double a, b;}; -double __exp__D __P((double, double)); -struct Double __log__D __P((double)); - -/* - * All externs exported after this point - */ -#if defined(_BLD_ast) && defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -extern double copysign(double, double); diff --git a/src/lib/libast/uwin/mini.sym b/src/lib/libast/uwin/mini.sym deleted file mode 100644 index 3a75e548c..000000000 --- a/src/lib/libast/uwin/mini.sym +++ /dev/null @@ -1,84 +0,0 @@ -_ast_init -_sfdlen -_sffilbuf -_sfflsbuf -_sfgetl -_sfgetl2 -_sfgetu -_sfgetu2 -_sfllen -_sfputd -_sfputl -_sfputu -_stdgets -_stdscanf -_stdsprintf -_stkseek -printf -remove -sfclose -sfclrerr -sfclrlock -sfdisc -sfdlen -sfdostext -sfeof -sferror -sffcvt -sffileno -sfgetc -sfgetd -sfgetl -sfgetr -sfgetu -sfkeyprintf -sfllen -sfmove -sfnew -sfnotify -sfnputc -sfopen -sfpkrd -sfpoll -sfpool -sfpopen -sfprintf -sfprints -sfpurge -sfputc -sfputd -sfputl -sfputr -sfputu -sfrd -sfread -sfreserve -sfscanf -sfseek -sfset -sfsetbuf -sfsetfd -sfsize -sfsk -sfslen -sfslowio -sfsprintf -sfsscanf -sfstack -sfstacked -sfswap -sfsync -sftell -sftmp -sfulen -sfungetc -sfvalue -sfvprintf -sfvscanf -sfwr -sfwrite -sigflag -sprintf -system -mktemp -strdup diff --git a/src/lib/libast/uwin/rand48.c b/src/lib/libast/uwin/rand48.c deleted file mode 100644 index 8521075dd..000000000 --- a/src/lib/libast/uwin/rand48.c +++ /dev/null @@ -1,178 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_srand48 - -void _STUB_srand48(){} - -#else - -#define drand48 ______drand48 -#define erand48 ______erand48 -#define jrand48 ______jrand48 -#define lcong48 ______lcong48 -#define lrand48 ______lrand48 -#define mrand48 ______mrand48 -#define nrand48 ______nrand48 -#define seed48 ______seed48 -#define srand48 ______srand48 - -#include - -#undef drand48 -#undef erand48 -#undef jrand48 -#undef lcong48 -#undef lrand48 -#undef mrand48 -#undef nrand48 -#undef seed48 -#undef srand48 - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -#define A 0x5DEECE66D -#define A0 0X5 -#define A1 0xDEEC -#define A2 0xE66D -#define C 0xB -#define XINIT 0x330E -#define SCALE 3.55271e-15 - -static unsigned short oldval[3]; -static unsigned short X[3] = { 0, 0, XINIT}; -static unsigned short a[3] = { A0, A1, A2}; -static unsigned short c = C; - -static void multadd(unsigned short x[3], unsigned short a[3], unsigned short c) -{ - register unsigned long r = c; - unsigned short x2 = x[2]; - unsigned short x1 = x[1]; - r += a[2]*x2; - x[2] = (unsigned short)r; - r >>= 16; - r += a[1]*x2; - r += a[2]*x1; - x[1] = (unsigned short)r; - r >>= 16; - r += a[2]*x[0]; - r += a[1]*x1; - r += a[0]*x2; - x[0] = (unsigned short)r; -} - -extern double drand48(void) -{ - double d; - unsigned long u; - multadd(X,a,c); - u = (X[0]<<16) + X[1]; - d = (u*65536.) + X[2]; - return(d*SCALE); -} - -extern double erand48(unsigned short xsubi[3]) -{ - double d; - unsigned long u; - multadd(xsubi,a,c); - u = (xsubi[0]<<16) + xsubi[1]; - d = (u*65536.) + xsubi[2]; - return(d*SCALE); -} - -extern long jrand48(unsigned short xsubi[3]) -{ - long u; - multadd(xsubi,a,c); - u = (xsubi[0]<<16) | xsubi[1]; - return((long)u); -} - -extern void lcong48(unsigned short param[7]) -{ - X[0] = param[0]; - X[1] = param[1]; - X[2] = param[2]; - a[0] = param[3]; - a[1] = param[4]; - a[2] = param[5]; - c = param[6]; -} - -extern long lrand48(void) -{ - long l; - multadd(X,a,c); - l = (X[0]<<15)|(X[1]>>1); - return(l); -} - -extern long mrand48(void) -{ - unsigned long u; - multadd(X,a,c); - u = (X[0]<<16) | X[1]; - return((long)u); -} - -extern long nrand48(unsigned short xsubi[3]) -{ - long l; - multadd(xsubi,a,c); - l = (xsubi[0]<<15)|(xsubi[1]>>1); - return(l); -} - -extern unsigned short *seed48(unsigned short seed[3]) -{ - unsigned short *sp = (unsigned short*)&X; - a[0] = A0; - a[1] = A1; - a[2] = A2; - c = C; - oldval[0] = X[2]; - oldval[1] = X[1]; - oldval[2] = X[0]; - X[0] = seed[2]; - X[1] = seed[1]; - X[2] = seed[0]; - return(oldval); -} - -extern void srand48(long seedval) -{ - a[0] = A0; - a[1] = A1; - a[2] = A2; - c = C; - X[0] = (unsigned short)(((unsigned long)seedval) >> 16); - X[1] = (unsigned short)seedval; - X[2] = XINIT; -} - -#endif diff --git a/src/lib/libast/uwin/random.c b/src/lib/libast/uwin/random.c deleted file mode 100644 index 3dc2af18c..000000000 --- a/src/lib/libast/uwin/random.c +++ /dev/null @@ -1,381 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_random - -void _STUB_random(){} - -#else - -/* - * Copyright (c) 1983 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * This is derived from the Berkeley source: - * @(#)random.c 5.5 (Berkeley) 7/6/88 - * It was reworked for the GNU C Library by Roland McGrath. - */ - -#define initstate ______initstate -#define random ______random -#define setstate ______setstate -#define srandom ______srandom - -#include -#include -#include -#include - -#undef initstate -#undef random -#undef setstate -#undef srandom - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -extern long int random(); - -#define PTR char* - -/* An improved random number generation package. In addition to the standard - rand()/srand() like interface, this package also has a special state info - interface. The initstate() routine is called with a seed, an array of - bytes, and a count of how many bytes are being passed in; this array is - then initialized to contain information for random number generation with - that much state information. Good sizes for the amount of state - information are 32, 64, 128, and 256 bytes. The state can be switched by - calling the setstate() function with the same array as was initialized - with initstate(). By default, the package runs with 128 bytes of state - information and generates far better random numbers than a linear - congruential generator. If the amount of state information is less than - 32 bytes, a simple linear congruential R.N.G. is used. Internally, the - state information is treated as an array of longs; the zeroeth element of - the array is the type of R.N.G. being used (small integer); the remainder - of the array is the state information for the R.N.G. Thus, 32 bytes of - state information will give 7 longs worth of state information, which will - allow a degree seven polynomial. (Note: The zeroeth word of state - information also has some other information stored in it; see setstate - for details.) The random number generation technique is a linear feedback - shift register approach, employing trinomials (since there are fewer terms - to sum up that way). In this approach, the least significant bit of all - the numbers in the state table will act as a linear feedback shift register, - and will have period 2^deg - 1 (where deg is the degree of the polynomial - being used, assuming that the polynomial is irreducible and primitive). - The higher order bits will have longer periods, since their values are - also influenced by pseudo-random carries out of the lower bits. The - total period of the generator is approximately deg*(2**deg - 1); thus - doubling the amount of state information has a vast influence on the - period of the generator. Note: The deg*(2**deg - 1) is an approximation - only good for large deg, when the period of the shift register is the - dominant factor. With deg equal to seven, the period is actually much - longer than the 7*(2**7 - 1) predicted by this formula. */ - - - -/* For each of the currently supported random number generators, we have a - break value on the amount of state information (you need at least the - bytes of state info to support this random number generator), a degree for - the polynomial (actually a trinomial) that the R.N.G. is based on, and - separation between the two lower order coefficients of the trinomial. */ - -/* Linear congruential. */ -#define TYPE_0 0 -#define BREAK_0 8 -#define DEG_0 0 -#define SEP_0 0 - -/* x**7 + x**3 + 1. */ -#define TYPE_1 1 -#define BREAK_1 32 -#define DEG_1 7 -#define SEP_1 3 - -/* x**15 + x + 1. */ -#define TYPE_2 2 -#define BREAK_2 64 -#define DEG_2 15 -#define SEP_2 1 - -/* x**31 + x**3 + 1. */ -#define TYPE_3 3 -#define BREAK_3 128 -#define DEG_3 31 -#define SEP_3 3 - -/* x**63 + x + 1. */ -#define TYPE_4 4 -#define BREAK_4 256 -#define DEG_4 63 -#define SEP_4 1 - - -/* Array versions of the above information to make code run faster. - Relies on fact that TYPE_i == i. */ - -#define MAX_TYPES 5 /* Max number of types above. */ - -static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; -static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; - - - -/* Initially, everything is set up as if from: - initstate(1, randtbl, 128); - Note that this initialization takes advantage of the fact that srandom - advances the front and rear pointers 10*rand_deg times, and hence the - rear pointer which starts at 0 will also end up at zero; thus the zeroeth - element of the state information, which contains info about the current - position of the rear pointer is just - (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ - -static long int randtbl[DEG_3 + 1] = - { - TYPE_3, - -851904987, -43806228, -2029755270, 1390239686, -1912102820, - -485608943, 1969813258, -1590463333, -1944053249, 455935928, 508023712, - -1714531963, 1800685987, -2015299881, 654595283, -1149023258, - -1470005550, -1143256056, -1325577603, -1568001885, 1275120390, - -607508183, -205999574, -1696891592, 1492211999, -1528267240, - -952028296, -189082757, 362343714, 1424981831, 2039449641, - }; - -/* FPTR and RPTR are two pointers into the state info, a front and a rear - pointer. These two pointers are always rand_sep places aparts, as they - cycle through the state information. (Yes, this does mean we could get - away with just one pointer, but the code for random is more efficient - this way.) The pointers are left positioned as they would be from the call: - initstate(1, randtbl, 128); - (The position of the rear pointer, rptr, is really 0 (as explained above - in the initialization of randtbl) because the state table pointer is set - to point to randtbl[1] (as explained below).) */ - -static long int *fptr = &randtbl[SEP_3 + 1]; -static long int *rptr = &randtbl[1]; - - - -/* The following things are the pointer to the state information table, - the type of the current generator, the degree of the current polynomial - being used, and the separation between the two pointers. - Note that for efficiency of random, we remember the first location of - the state information, not the zeroeth. Hence it is valid to access - state[-1], which is used to store the type of the R.N.G. - Also, we remember the last location, since this is more efficient than - indexing every time to find the address of the last element to see if - the front and rear pointers have wrapped. */ - -static long int *state = &randtbl[1]; - -static int rand_type = TYPE_3; -static int rand_deg = DEG_3; -static int rand_sep = SEP_3; - -static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])]; - -/* Initialize the random number generator based on the given seed. If the - type is the trivial no-state-information type, just remember the seed. - Otherwise, initializes state[] based on the given "seed" via a linear - congruential generator. Then, the pointers are set to known locations - that are exactly rand_sep places apart. Lastly, it cycles the state - information a given number of times to get rid of any initial dependencies - introduced by the L.C.R.N.G. Note that the initialization of randtbl[] - for default usage relies on values produced by this routine. */ -extern void srandom(unsigned int x) -{ - state[0] = x; - if (rand_type != TYPE_0) - { - register long int i; - for (i = 1; i < rand_deg; ++i) - state[i] = (1103515145 * state[i - 1]) + 12345; - fptr = &state[rand_sep]; - rptr = &state[0]; - for (i = 0; i < 10 * rand_deg; ++i) - (void) random(); - } -} - -/* Initialize the state information in the given array of N bytes for - future random number generation. Based on the number of bytes we - are given, and the break values for the different R.N.G.'s, we choose - the best (largest) one we can and set things up for it. srandom is - then called to initialize the state information. Note that on return - from srandom, we set state[-1] to be the type multiplexed with the current - value of the rear pointer; this is so successive calls to initstate won't - lose this information and will be able to restart with setstate. - Note: The first thing we do is save the current state, if any, just like - setstate so that it doesn't matter when initstate is called. - Returns a pointer to the old state. */ -extern char* initstate(unsigned int seed, char* arg_state, size_t n) -{ - PTR ostate = (PTR) &state[-1]; - - if (rand_type == TYPE_0) - state[-1] = rand_type; - else - state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; - if (n < BREAK_1) - { - if (n < BREAK_0) - { - errno = EINVAL; - return NULL; - } - rand_type = TYPE_0; - rand_deg = DEG_0; - rand_sep = SEP_0; - } - else if (n < BREAK_2) - { - rand_type = TYPE_1; - rand_deg = DEG_1; - rand_sep = SEP_1; - } - else if (n < BREAK_3) - { - rand_type = TYPE_2; - rand_deg = DEG_2; - rand_sep = SEP_2; - } - else if (n < BREAK_4) - { - rand_type = TYPE_3; - rand_deg = DEG_3; - rand_sep = SEP_3; - } - else - { - rand_type = TYPE_4; - rand_deg = DEG_4; - rand_sep = SEP_4; - } - - state = &((long int *) arg_state)[1]; /* First location. */ - /* Must set END_PTR before srandom. */ - end_ptr = &state[rand_deg]; - srandom(seed); - if (rand_type == TYPE_0) - state[-1] = rand_type; - else - state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; - - return ostate; -} - -/* Restore the state from the given state array. - Note: It is important that we also remember the locations of the pointers - in the current state information, and restore the locations of the pointers - from the old state information. This is done by multiplexing the pointer - location into the zeroeth word of the state information. Note that due - to the order in which things are done, it is OK to call setstate with the - same state as the current state - Returns a pointer to the old state information. */ -extern char *setstate(const char *arg_state) -{ - register long int *new_state = (long int *) arg_state; - register int type = new_state[0] % MAX_TYPES; - register int rear = new_state[0] / MAX_TYPES; - PTR ostate = (PTR) &state[-1]; - - if (rand_type == TYPE_0) - state[-1] = rand_type; - else - state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; - - switch (type) - { - case TYPE_0: - case TYPE_1: - case TYPE_2: - case TYPE_3: - case TYPE_4: - rand_type = type; - rand_deg = degrees[type]; - rand_sep = seps[type]; - break; - default: - /* State info munged. */ - errno = EINVAL; - return NULL; - } - - state = &new_state[1]; - if (rand_type != TYPE_0) - { - rptr = &state[rear]; - fptr = &state[(rear + rand_sep) % rand_deg]; - } - /* Set end_ptr too. */ - end_ptr = &state[rand_deg]; - - return ostate; -} - -/* If we are using the trivial TYPE_0 R.N.G., just do the old linear - congruential bit. Otherwise, we do our fancy trinomial stuff, which is the - same in all the other cases due to all the global variables that have been - set up. The basic operation is to add the number at the rear pointer into - the one at the front pointer. Then both pointers are advanced to the next - location cyclically in the table. The value returned is the sum generated, - reduced to 31 bits by throwing away the "least random" low bit. - Note: The code takes advantage of the fact that both the front and - rear pointers can't wrap on the same call by not testing the rear - pointer if the front one has wrapped. Returns a 31-bit random number. */ - -extern long int random() -{ - if (rand_type == TYPE_0) - { - state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX; - return state[0]; - } - else - { - long int i; - *fptr += *rptr; - /* Chucking least random bit. */ - i = (*fptr >> 1) & LONG_MAX; - ++fptr; - if (fptr >= end_ptr) - { - fptr = state; - ++rptr; - } - else - { - ++rptr; - if (rptr >= end_ptr) - rptr = state; - } - return i; - } -} - -#endif diff --git a/src/lib/libast/uwin/rcmd.c b/src/lib/libast/uwin/rcmd.c deleted file mode 100644 index af296840f..000000000 --- a/src/lib/libast/uwin/rcmd.c +++ /dev/null @@ -1,571 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_rcmd - -void _STUB_rcmd(){} - -#else - -/* - * Copyright (c) 1983 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rcmd.c 5.17 (Berkeley) 6/27/88"; -#endif /* LIBC_SCCS and not lint */ - -#include "rlib.h" -#include -#include -#include -#if 1 -#define _PATH_HEQUIV "/etc/hosts.equiv" -#endif -#include - -#if NLS -#include "nl_types.h" -#endif - -#ifdef YP -#include -extern void setnetgrent(const char *); -extern void endnetgrent(void); -extern int getnetgrent(char **, char **, char **); -static char *nisdomain = NULL; -static int _checknetgrouphost(const char *, const char *, int); -static int _checknetgroupuser(const char *, const char *); -#endif - -#if defined(__EXPORT__) -#define extern __EXPORT__ -#endif - -extern int rresvport(int *alport) -{ - struct sockaddr_in sin; - int s; - - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = INADDR_ANY; - s = socket(AF_INET, SOCK_STREAM, 0); - if (s < 0) - return (-1); - for (;;) { - sin.sin_port = htons((u_short)*alport); - if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0) - return (s); - if (errno != EADDRINUSE) { - (void) close(s); - return (-1); - } - (*alport)--; - if (*alport == IPPORT_RESERVED/2) { - (void) close(s); - errno = EAGAIN; /* close */ - return (-1); - } - } -} - -extern int rcmd(char **ahost, unsigned short rport, const char *locuser, const char *remuser, const char *cmd, int *fd2p) -{ - int s, timo = 1; -#ifdef F_SETOWN - pid_t pid; -#endif -#ifdef _POSIX_SOURCE - sigset_t set, oset; -#else - long oldmask; -#endif - struct sockaddr_in sin, from; - char c; - int lport = IPPORT_RESERVED - 1; - struct hostent *hp; - -#if NLS - libc_nls_init(); -#endif - -#ifdef F_SETOWN - pid = getpid(); -#endif - hp = gethostbyname(*ahost); - if (hp == 0) { -#if NLS - fprintf(stderr, "%s: %s\n", *ahost, - catgets(_libc_cat, HerrorListSet, - 2, "unknown host")); -#else - fprintf(stderr, "%s: unknown host\n", *ahost); -#endif - return (-1); - } - *ahost = hp->h_name; -#ifdef SIGURG -#ifdef _POSIX_SOURCE - sigemptyset (&set); - sigaddset (&set, SIGURG); - sigprocmask (SIG_BLOCK, &set, &oset); -#else - oldmask = sigblock(sigmask(SIGURG)); -#endif -#endif - for (;;) { - s = rresvport(&lport); - if (s < 0) { - if (errno == EAGAIN) -#if NLS - fprintf(stderr, "socket: %s\n", - catgets(_libc_cat, NetMiscSet, - NetMiscAllPortsInUse, - "All ports in use")); -#else - fprintf(stderr, "socket: All ports in use\n"); -#endif - else -#if NLS - perror(catgets(_libc_cat, NetMiscSet, - NetMiscRcmdSocket, - "rcmd: socket")); -#else -perror("rcmd: socket"); -#endif -#ifdef SIGURG -#ifdef _POSIX_SOURCE -sigprocmask (SIG_SETMASK, &oset, -(sigset_t *)NULL); -#else -sigsetmask(oldmask); -#endif -#endif -return (-1); - } -#ifdef F_SETOWN - fcntl(s, F_SETOWN, pid); -#endif - sin.sin_family = hp->h_addrtype; - bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length); - sin.sin_port = rport; - if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0) - break; - (void) close(s); - if (errno == EADDRINUSE) { - lport--; - continue; - } - if (errno == ECONNREFUSED && timo <= 16) { - sleep(timo); - timo *= 2; - continue; - } - if (hp->h_addr_list[1] != NULL) { - int oerrno = errno; - - fprintf(stderr, -#if NLS - "%s %s: ", catgets(_libc_cat, NetMiscSet, - NetMiscAllPortsInUse, - "connect to address"), - inet_ntoa(sin.sin_addr)); - -#else - - "connect to address %s: ", inet_ntoa(sin.sin_addr)); -#endif - errno = oerrno; - perror(0); - hp->h_addr_list++; - bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, - hp->h_length); - -#if NLS - fprintf(stderr, catgets(_libc_cat, NetMiscSet, - NetMiscTrying, - "Trying %s...\n"), -#else - fprintf(stderr, "Trying %s...\n", -#endif - inet_ntoa(sin.sin_addr)); - continue; - } - perror(hp->h_name); -#ifdef SIGURG -#ifdef _POSIX_SOURCE - sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); -#else - sigsetmask(oldmask); -#endif -#endif - return (-1); - } - lport--; - if (fd2p == 0) { - write(s, "", 1); - lport = 0; - } else { - char num[8]; - int s2 = rresvport(&lport), s3; - int len = sizeof (from); - - if (s2 < 0) - goto bad; - listen(s2, 1); - (void) snprintf(num, sizeof(num), "%d", lport); - if (write(s, num, strlen(num)+1) != strlen(num)+1) { -#if NLS - perror(catgets(_libc_cat, NetMiscSet, - NetMiscSettingUpStderr, - "write: setting up stderr")); -#else - perror("write: setting up stderr"); -#endif - (void) close(s2); - goto bad; - } - s3 = accept(s2, (struct sockaddr *)&from, &len); - (void) close(s2); - if (s3 < 0) { -#if NLS - perror(catgets(_libc_cat, NetMiscSet, - NetMiscAccept, - "accept")); -#else - perror("accept"); -#endif - lport = 0; - goto bad; - } - *fd2p = s3; - from.sin_port = ntohs((u_short)from.sin_port); - if (from.sin_family != AF_INET || - from.sin_port >= IPPORT_RESERVED) { - fprintf(stderr, -#if NLS - "%s\n", - catgets(_libc_cat, NetMiscSet, - NetMiscProtocolFailure, - "socket: protocol failure in circuit setup.")); -#else - "socket: protocol failure in circuit setup.\n"); -#endif - goto bad2; - } - } - (void) write(s, locuser, strlen(locuser)+1); - (void) write(s, remuser, strlen(remuser)+1); - (void) write(s, cmd, strlen(cmd)+1); - if (read(s, &c, 1) != 1) { - perror(*ahost); - goto bad2; - } - if (c != 0) { - while (read(s, &c, 1) == 1) { - (void) write(2, &c, 1); - if (c == '\n') - break; - } - goto bad2; - } -#ifdef SIGURG -#ifdef _POSIX_SOURCE - sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); -#else - sigsetmask(oldmask); -#endif -#endif - return (s); -bad2: - if (lport) - (void) close(*fd2p); -bad: - (void) close(s); -#ifdef SIGURG -#ifdef _POSIX_SOURCE - sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); -#else - sigsetmask(oldmask); -#endif -#endif - return (-1); -} - -extern int ruserok(const char *rhost, int superuser, const char *ruser, const char *luser) -{ - FILE *hostf; - char fhost[MAXHOSTNAMELEN]; - int first = 1; - register const char *sp; - register char *p; - int baselen = -1; - uid_t saveuid; - - saveuid = geteuid(); - sp = rhost; - p = fhost; - while (*sp) { - if (*sp == '.') { - if (baselen == -1) - baselen = sp - rhost; - *p++ = *sp++; - } else { - *p++ = isupper(*sp) ? tolower(*sp++) : *sp++; - } - } - *p = '\0'; - hostf = superuser ? (FILE *)0 : fopen(_PATH_HEQUIV, "r"); -again: - if (hostf) { - if (!_validuser(hostf, fhost, luser, ruser, baselen)) { - (void) fclose(hostf); - seteuid(saveuid); - return(0); - } - (void) fclose(hostf); - } - if (first == 1) { - struct stat sbuf; - struct passwd *pwd; - char pbuf[MAXPATHLEN]; - - first = 0; - if ((pwd = getpwnam(luser)) == NULL) - return(-1); - (void)strcpy(pbuf, pwd->pw_dir); - (void)strcat(pbuf, "/.rhosts"); - (void)seteuid(pwd->pw_uid); - if ((hostf = fopen(pbuf, "r")) == NULL) { - seteuid(saveuid); - return(-1); - } - (void)fstat(fileno(hostf), &sbuf); - if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) { - fclose(hostf); - seteuid(saveuid); - return(-1); - } - goto again; - } - seteuid(saveuid); - return (-1); -} - -int -_validuser(FILE *hostf, const char *rhost, const char *luser, -const char *ruser, int baselen) -{ - char *user; - char ahost[MAXHOSTNAMELEN]; - register char *p; - int hostvalid = 0; - int uservalid = 0; - - while (fgets(ahost, sizeof (ahost), hostf)) { - /* We need to get rid of all comments. */ - p = strchr (ahost, '#'); - if (p) *p = '\0'; - p = ahost; - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { - *p = isupper(*p) ? tolower(*p) : *p; - p++; - } - if (*p == ' ' || *p == '\t') { - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - user = p; - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') - p++; - } else - user = p; - *p = '\0'; - /* Adding new authentication -Nilendu */ - - /* enable all host for + entry */ - if ('+' == ahost[0] && '\0' == ahost[1] ) - hostvalid = 1; - - /* enable all user for + entry */ - if ('+' == user[0] && '\0' == user[1] ) - uservalid = 1; - - /* disable all host for - entry */ - if ('-' == ahost[0] && '\0' == ahost[1] ) - hostvalid = 0; - - /* disable all user for - entry */ - if ('-' == user[0] && '\0' == user[1] ) - uservalid = 0; - - -#ifdef YP - /* disable host from -hostname entry */ - if ('-' == ahost[0] && '@' != ahost[1] - && _checkhost(rhost, &ahost[1], baselen)) - return -1; - /* disable host from -@netgroup entry for host */ - if ('-' == ahost[0] && '@' == ahost[1] && '\0' != ahost[2] - && _checknetgrouphost(rhost, &ahost[2], baselen)) - return -1; - /* disable user from -user entry */ - if ('\0' != *user && user[0] == '-' && user[1] != '@' - && !strcmp(&user[1], ruser)) - return -1; - /* disable user from -@netgroup entry for user */ - if ('\0' != *user && user[0] == '-' && user[1] == '@' - && user[2] != '\0' && _checknetgroupuser(ruser, &user[2])) - return -1; - /* enable host from +@netgroup entry for host */ - if ('+' == ahost[0] && '@' == ahost[1] && '\0' != ahost[2]) - hostvalid = _checknetgrouphost(rhost, &ahost[2], baselen); - else - hostvalid = _checkhost(rhost, ahost, baselen); - /* enable user from +@netgroup entry for user */ - if ('\0' != *user && user[0] == '+' - && user[1] == '@' && user[2] != '\0') - uservalid = _checknetgroupuser(ruser, &user[2]); - else - uservalid = !strcmp(ruser, *user ? user : luser); - - if (hostvalid && uservalid) - return 0; -#else - hostvalid = hostvalid ? 1 : _checkhost(rhost, ahost, baselen); - uservalid = uservalid ? 1 : !stricmp(ruser,*user ? user : luser); - if (hostvalid && uservalid) - return 0; - -#endif /* YP */ - hostvalid = uservalid = 0; - } - return (-1); -} - -int -_checkhost(const char *rhost, const char *lhost, int len) -{ - static char ldomain[MAXHOSTNAMELEN + 1]; - static char *domainp = NULL; - static int nodomain = 0; - register char *cp; - - if (len == -1) - return(!strcmp(rhost, lhost)); - if (strncmp(rhost, lhost, len)) - return(0); - if (!strcmp(rhost, lhost)) - return(1); - if (*(lhost + len) != '\0') - return(0); - if (nodomain) - return(0); - if (!domainp) { - if (gethostname(ldomain, sizeof(ldomain)) == -1) { - nodomain = 1; - return(0); - } - ldomain[MAXHOSTNAMELEN] = (char) 0; - if ((domainp = index(ldomain, '.')) == (char *)NULL) { - nodomain = 1; - return(0); - } - for (cp = ++domainp; *cp; ++cp) - if (isupper(*cp)) - *cp = tolower(*cp); - } - return(!strcmp(domainp, rhost + len +1)); -} - -#ifdef YP -static int -_checknetgrouphost(const char *rhost, const char *netgr, int baselen) -{ - char *host, *user, *domain; - int status; - - if (NULL == nisdomain) - yp_get_default_domain(&nisdomain); - - setnetgrent(netgr); - while (1) - { - while (1 == (status = getnetgrent(&host, &user, &domain)) - && NULL == host - && NULL != domain - && 0 != strcmp(domain, nisdomain)) - ; /* find valid host entry */ - - if (0 == status || NULL == host) - { - endnetgrent(); - return 0; - } - - if(1 == _checkhost(rhost, host, baselen)) - { - endnetgrent(); - return 1; - } - } -} - -static int -_checknetgroupuser(const char *ruser, const char *netgr) -{ - char *host, *user, *domain; - int status; - - if (NULL == nisdomain) - yp_get_default_domain(&nisdomain); - - setnetgrent(netgr); - while (1) - { - while (1 == (status = getnetgrent(&host, &user, &domain)) - && NULL == user - && NULL != domain - && 0 != strcmp(domain, nisdomain)) - ; /* find valid user entry */ - - if (0 == status || NULL == user) - { - endnetgrent(); - return 0; - } - - if(0 == strcmp(ruser, user)) - { - endnetgrent(); - return 1; - } - } -} -#endif /* YP */ - -#endif diff --git a/src/lib/libast/uwin/rint.c b/src/lib/libast/uwin/rint.c deleted file mode 100644 index 32573d169..000000000 --- a/src/lib/libast/uwin/rint.c +++ /dev/null @@ -1,42 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include "FEATURE/uwin" - -#if !_UWIN || _lib_ceil && _lib_floor && _lib_rint - -void _STUB_rint(){} - -#else - -#include - -extern double rint(x) -double x; -{ - double d = floor((x+=.5)); - if(d==x && d/2.!=floor(d/2)) - d = d-1; - return(d); -} - -#endif diff --git a/src/lib/libast/uwin/rlib.h b/src/lib/libast/uwin/rlib.h deleted file mode 100644 index 79fab8725..000000000 --- a/src/lib/libast/uwin/rlib.h +++ /dev/null @@ -1,81 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 1.0 * -* by AT&T Intellectual Property * -* * -* A copy of the License is available at * -* http://www.eclipse.org/org/documents/epl-v10.html * -* (with md5 checksum b35adb5213ca9657e911e9befb180842) * -* * -* Information and Software Systems Research * -* AT&T Research * -* Florham Park NJ * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* * -***********************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if 0 -#include -#include -#include -#include -#include -#endif - -#ifndef sigmask -#define sigmask(n) ((unsigned long)1 << ((n) - 1)) -#endif - -extern void _sethtent(int f); -extern void _endhtent(void); -extern struct hostent *_gethtent(void); -extern struct hostent *_gethtbyname(const char *name); -extern struct hostent *_gethtbyaddr(const char *addr, int len, - int type); -extern int _validuser(FILE *hostf, const char *rhost, - const char *luser, const char *ruser, int baselen); -extern int _checkhost(const char *rhost, const char *lhost, int len); - -#if 0 -extern void putlong(u_long l, u_char *msgp); -extern void putshort(u_short l, u_char *msgp); -extern u_int32_t _getlong(register const u_char *msgp); -extern u_int16_t _getshort(register const u_char *msgp); -extern void p_query(char *msg); -extern void fp_query(char *msg, FILE *file); -extern char *p_cdname(char *cp, char *msg, FILE *file); -extern char *p_rr(char *cp, char *msg, FILE *file); -extern char *p_type(int type); -extern char * p_class(int class); -extern char *p_time(u_long value); -#endif - -extern char * hostalias(const char *name); -extern void sethostfile(char *name); -extern void _res_close (void); -extern void ruserpass(const char *host, char **aname, char **apass); -extern char* index(const char*, int); -extern int strcasecmp(const char*, const char*); -extern void bcopy(const void*, void*, size_t); diff --git a/src/lib/libast/uwin/support.c b/src/lib/libast/uwin/support.c deleted file mode 100644 index b2db87328..000000000 --- a/src/lib/libast/uwin/support.c +++ /dev/null @@ -1,605 +0,0 @@ -#include "FEATURE/uwin" - -#if !_UWIN || (_lib__copysign||_lib_copysign) && _lib_logb && (_lib__finite||_lib_finite) && (_lib_drem||_lib_remainder) && _lib_sqrt && _lib_ilogb && (_lib__scalb||_lib_scalb) - -void _STUB_support(){} - -#else - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * Some IEEE standard 754 recommended functions and remainder and sqrt for - * supporting the C elementary functions. - ****************************************************************************** - * WARNING: - * These codes are developed (in double) to support the C elementary - * functions temporarily. They are not universal, and some of them are very - * slow (in particular, drem and sqrt is extremely inefficient). Each - * computer system should have its implementation of these functions using - * its own assembler. - ****************************************************************************** - * - * IEEE 754 required operations: - * drem(x,p) - * returns x REM y = x - [x/y]*y , where [x/y] is the integer - * nearest x/y; in half way case, choose the even one. - * sqrt(x) - * returns the square root of x correctly rounded according to - * the rounding mod. - * - * IEEE 754 recommended functions: - * (a) copysign(x,y) - * returns x with the sign of y. - * (b) scalb(x,N) - * returns x * (2**N), for integer values N. - * (c) logb(x) - * returns the unbiased exponent of x, a signed integer in - * double precision, except that logb(0) is -INF, logb(INF) - * is +INF, and logb(NAN) is that NAN. - * (d) finite(x) - * returns the value TRUE if -INF < x < +INF and returns - * FALSE otherwise. - * - * - * CODED IN C BY K.C. NG, 11/25/84; - * REVISED BY K.C. NG on 1/22/85, 2/13/85, 3/24/85. - */ - -#include "mathimpl.h" - -#if defined(vax)||defined(tahoe) /* VAX D format */ -#include - static const unsigned short msign=0x7fff , mexp =0x7f80 ; - static const short prep1=57, gap=7, bias=129 ; - static const double novf=1.7E38, nunf=3.0E-39, zero=0.0 ; -#else /* defined(vax)||defined(tahoe) */ - static const unsigned short msign=0x7fff, mexp =0x7ff0 ; - static const short prep1=54, gap=4, bias=1023 ; - static const double novf=1.7E308, nunf=3.0E-308,zero=0.0; -#endif /* defined(vax)||defined(tahoe) */ - -#if !_lib__scalb || !_lib_scalb - -extern double _scalb(x,N) -double x; double N; -{ - int k; - -#ifdef national - unsigned short *px=(unsigned short *) &x + 3; -#else /* national */ - unsigned short *px=(unsigned short *) &x; -#endif /* national */ - - if( x == zero ) return(x); - -#if defined(vax)||defined(tahoe) - if( (k= *px & mexp ) != ~msign ) { - if (N < -260) - return(nunf*nunf); - else if (N > 260) { - return(copysign(infnan(ERANGE),x)); - } -#else /* defined(vax)||defined(tahoe) */ - if( (k= *px & mexp ) != mexp ) { - if( N<-2100) return(nunf*nunf); else if(N>2100) return(novf+novf); - if( k == 0 ) { - x *= scalb(1.0,prep1); N -= prep1; return(scalb(x,N));} -#endif /* defined(vax)||defined(tahoe) */ - - if((k = (k>>gap)+ N) > 0 ) - if( k < (mexp>>gap) ) *px = (*px&~mexp) | (k< -prep1 ) - /* gradual underflow */ - {*px=(*px&~mexp)|(short)(1<>gap)-bias); -#else /* defined(vax)||defined(tahoe) */ - if( (k= *px & mexp ) != mexp ) - if ( k != 0 ) - return ( (k>>gap) - bias ); - else if( x != zero) - return ( -1022.0 ); - else - return(-(1.0/zero)); - else if(x != x) - return(x); - else - {*px &= msign; return(x);} -#endif /* defined(vax)||defined(tahoe) */ -} - -#endif - -#if !_lib__finite - -extern int _finite(x) -double x; -{ -#if defined(vax)||defined(tahoe) - return(1); -#else /* defined(vax)||defined(tahoe) */ -#ifdef national - return( (*((short *) &x+3 ) & mexp ) != mexp ); -#else /* national */ - return( (*((short *) &x ) & mexp ) != mexp ); -#endif /* national */ -#endif /* defined(vax)||defined(tahoe) */ -} - -#endif - -#if !_lib_finite - -extern int finite(x) -double x; -{ - return _finite(x); -} - -#endif - -#if !_lib_drem - -extern double drem(x,p) -double x,p; -{ -#if _lib_remainder - return remainder(x,p); -#else - short sign; - double hp,dp,tmp; - unsigned short k; -#ifdef national - unsigned short - *px=(unsigned short *) &x +3, - *pp=(unsigned short *) &p +3, - *pd=(unsigned short *) &dp +3, - *pt=(unsigned short *) &tmp+3; -#else /* national */ - unsigned short - *px=(unsigned short *) &x , - *pp=(unsigned short *) &p , - *pd=(unsigned short *) &dp , - *pt=(unsigned short *) &tmp; -#endif /* national */ - - *pp &= msign ; - -#if defined(vax)||defined(tahoe) - if( ( *px & mexp ) == ~msign ) /* is x a reserved operand? */ -#else /* defined(vax)||defined(tahoe) */ - if( ( *px & mexp ) == mexp ) -#endif /* defined(vax)||defined(tahoe) */ - return (x-p)-(x-p); /* create NaN if x is Inf */ - if (p == zero) { -#if defined(vax)||defined(tahoe) - return(infnan(EDOM)); -#else /* defined(vax)||defined(tahoe) */ - return zero/zero; -#endif /* defined(vax)||defined(tahoe) */ - } - -#if defined(vax)||defined(tahoe) - if( ( *pp & mexp ) == ~msign ) /* is p a reserved operand? */ -#else /* defined(vax)||defined(tahoe) */ - if( ( *pp & mexp ) == mexp ) -#endif /* defined(vax)||defined(tahoe) */ - { if (p != p) return p; else return x;} - - else if ( ((*pp & mexp)>>gap) <= 1 ) - /* subnormal p, or almost subnormal p */ - { double b; b=scalb(1.0,(int)prep1); - p *= b; x = drem(x,p); x *= b; return(drem(x,p)/b);} - else if ( p >= novf/2) - { p /= 2 ; x /= 2; return(drem(x,p)*2);} - else - { - dp=p+p; hp=p/2; - sign= *px & ~msign ; - *px &= msign ; - while ( x > dp ) - { - k=(*px & mexp) - (*pd & mexp) ; - tmp = dp ; - *pt += k ; - -#if defined(vax)||defined(tahoe) - if( x < tmp ) *pt -= 128 ; -#else /* defined(vax)||defined(tahoe) */ - if( x < tmp ) *pt -= 16 ; -#endif /* defined(vax)||defined(tahoe) */ - - x -= tmp ; - } - if ( x > hp ) - { x -= p ; if ( x >= hp ) x -= p ; } - -#if defined(vax)||defined(tahoe) - if (x) -#endif /* defined(vax)||defined(tahoe) */ - *px ^= sign; - return( x); - - } -#endif -} - -#endif - -#if !_lib_remainder - -extern double remainder(x,p) -double x,p; -{ - return drem(x,p); -} - -#endif - -#if !_lib_sqrt - -extern double sqrt(x) -double x; -{ - double q,s,b,r; - double t; - double const zero=0.0; - int m,n,i; -#if defined(vax)||defined(tahoe) - int k=54; -#else /* defined(vax)||defined(tahoe) */ - int k=51; -#endif /* defined(vax)||defined(tahoe) */ - - /* sqrt(NaN) is NaN, sqrt(+-0) = +-0 */ - if(x!=x||x==zero) return(x); - - /* sqrt(negative) is invalid */ - if(x1.0) t=1; /* b>1 : Round-to-(+INF) */ - if(t>=0) q+=r; } /* else: Round-to-nearest */ - else { - s *= 2; x *= 4; - t = (x-s)-1; - b=1.0+3*r/4; if(b==1.0) goto end; - b=1.0+r/4; if(b>1.0) t=1; - if(t>=0) q+=r; } - -end: return(scalb(q,n)); -} - -#endif - -#if 0 -/* DREM(X,Y) - * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE) - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * INTENDED FOR ASSEMBLY LANGUAGE - * CODED IN C BY K.C. NG, 3/23/85, 4/8/85. - * - * Warning: this code should not get compiled in unless ALL of - * the following machine-dependent routines are supplied. - * - * Required machine dependent functions (not on a VAX): - * swapINX(i): save inexact flag and reset it to "i" - * swapENI(e): save inexact enable and reset it to "e" - */ - -extern double drem(x,y) -double x,y; -{ - -#ifdef national /* order of words in floating point number */ - static const n0=3,n1=2,n2=1,n3=0; -#else /* VAX, SUN, ZILOG, TAHOE */ - static const n0=0,n1=1,n2=2,n3=3; -#endif - - static const unsigned short mexp =0x7ff0, m25 =0x0190, m57 =0x0390; - static const double zero=0.0; - double hy,y1,t,t1; - short k; - long n; - int i,e; - unsigned short xexp,yexp, *px =(unsigned short *) &x , - nx,nf, *py =(unsigned short *) &y , - sign, *pt =(unsigned short *) &t , - *pt1 =(unsigned short *) &t1 ; - - xexp = px[n0] & mexp ; /* exponent of x */ - yexp = py[n0] & mexp ; /* exponent of y */ - sign = px[n0] &0x8000; /* sign of x */ - -/* return NaN if x is NaN, or y is NaN, or x is INF, or y is zero */ - if(x!=x) return(x); if(y!=y) return(y); /* x or y is NaN */ - if( xexp == mexp ) return(zero/zero); /* x is INF */ - if(y==zero) return(y/y); - -/* save the inexact flag and inexact enable in i and e respectively - * and reset them to zero - */ - i=swapINX(0); e=swapENI(0); - -/* subnormal number */ - nx=0; - if(yexp==0) {t=1.0,pt[n0]+=m57; y*=t; nx=m57;} - -/* if y is tiny (biased exponent <= 57), scale up y to y*2**57 */ - if( yexp <= m57 ) {py[n0]+=m57; nx+=m57; yexp+=m57;} - - nf=nx; - py[n0] &= 0x7fff; - px[n0] &= 0x7fff; - -/* mask off the least significant 27 bits of y */ - t=y; pt[n3]=0; pt[n2]&=0xf800; y1=t; - -/* LOOP: argument reduction on x whenever x > y */ -loop: - while ( x > y ) - { - t=y; - t1=y1; - xexp=px[n0]&mexp; /* exponent of x */ - k=xexp-yexp-m25; - if(k>0) /* if x/y >= 2**26, scale up y so that x/y < 2**26 */ - {pt[n0]+=k;pt1[n0]+=k;} - n=x/t; x=(x-n*t1)-n*(t-t1); - } - /* end while (x > y) */ - - if(nx!=0) {t=1.0; pt[n0]+=nx; x*=t; nx=0; goto loop;} - -/* final adjustment */ - - hy=y/2.0; - if(x>hy||((x==hy)&&n%2==1)) x-=y; - px[n0] ^= sign; - if(nf!=0) { t=1.0; pt[n0]-=nf; x*=t;} - -/* restore inexact flag and inexact enable */ - swapINX(i); swapENI(e); - - return(x); -} -#endif - -#if 0 -/* SQRT - * RETURN CORRECTLY ROUNDED (ACCORDING TO THE ROUNDING MODE) SQRT - * FOR IEEE DOUBLE PRECISION ONLY, INTENDED FOR ASSEMBLY LANGUAGE - * CODED IN C BY K.C. NG, 3/22/85. - * - * Warning: this code should not get compiled in unless ALL of - * the following machine-dependent routines are supplied. - * - * Required machine dependent functions: - * swapINX(i) ...return the status of INEXACT flag and reset it to "i" - * swapRM(r) ...return the current Rounding Mode and reset it to "r" - * swapENI(e) ...return the status of inexact enable and reset it to "e" - * addc(t) ...perform t=t+1 regarding t as a 64 bit unsigned integer - * subc(t) ...perform t=t-1 regarding t as a 64 bit unsigned integer - */ - -static const unsigned long table[] = { -0, 1204, 3062, 5746, 9193, 13348, 18162, 23592, 29598, 36145, 43202, 50740, -58733, 67158, 75992, 85215, 83599, 71378, 60428, 50647, 41945, 34246, 27478, -21581, 16499, 12183, 8588, 5674, 3403, 1742, 661, 130, }; - -extern double newsqrt(x) -double x; -{ - double y,z,t,addc(),subc() - double const b54=134217728.*134217728.; /* b54=2**54 */ - long mx,scalx; - long const mexp=0x7ff00000; - int i,j,r,e,swapINX(),swapRM(),swapENI(); - unsigned long *py=(unsigned long *) &y , - *pt=(unsigned long *) &t , - *px=(unsigned long *) &x ; -#ifdef national /* ordering of word in a floating point number */ - const int n0=1, n1=0; -#else - const int n0=0, n1=1; -#endif -/* Rounding Mode: RN ...round-to-nearest - * RZ ...round-towards 0 - * RP ...round-towards +INF - * RM ...round-towards -INF - */ - const int RN=0,RZ=1,RP=2,RM=3; - /* machine dependent: work on a Zilog Z8070 - * and a National 32081 & 16081 - */ - -/* exceptions */ - if(x!=x||x==0.0) return(x); /* sqrt(NaN) is NaN, sqrt(+-0) = +-0 */ - if(x<0) return((x-x)/(x-x)); /* sqrt(negative) is invalid */ - if((mx=px[n0]&mexp)==mexp) return(x); /* sqrt(+INF) is +INF */ - -/* save, reset, initialize */ - e=swapENI(0); /* ...save and reset the inexact enable */ - i=swapINX(0); /* ...save INEXACT flag */ - r=swapRM(RN); /* ...save and reset the Rounding Mode to RN */ - scalx=0; - -/* subnormal number, scale up x to x*2**54 */ - if(mx==0) {x *= b54 ; scalx-=0x01b00000;} - -/* scale x to avoid intermediate over/underflow: - * if (x > 2**512) x=x/2**512; if (x < 2**-512) x=x*2**512 */ - if(mx>0x5ff00000) {px[n0] -= 0x20000000; scalx+= 0x10000000;} - if(mx<0x1ff00000) {px[n0] += 0x20000000; scalx-= 0x10000000;} - -/* magic initial approximation to almost 8 sig. bits */ - py[n0]=(px[n0]>>1)+0x1ff80000; - py[n0]=py[n0]-table[(py[n0]>>15)&31]; - -/* Heron's rule once with correction to improve y to almost 18 sig. bits */ - t=x/y; y=y+t; py[n0]=py[n0]-0x00100006; py[n1]=0; - -/* triple to almost 56 sig. bits; now y approx. sqrt(x) to within 1 ulp */ - t=y*y; z=t; pt[n0]+=0x00100000; t+=z; z=(x-z)*y; - t=z/(t+x) ; pt[n0]+=0x00100000; y+=t; - -/* twiddle last bit to force y correctly rounded */ - swapRM(RZ); /* ...set Rounding Mode to round-toward-zero */ - swapINX(0); /* ...clear INEXACT flag */ - swapENI(e); /* ...restore inexact enable status */ - t=x/y; /* ...chopped quotient, possibly inexact */ - j=swapINX(i); /* ...read and restore inexact flag */ - if(j==0) { if(t==y) goto end; else t=subc(t); } /* ...t=t-ulp */ - b54+0.1; /* ..trigger inexact flag, sqrt(x) is inexact */ - if(r==RN) t=addc(t); /* ...t=t+ulp */ - else if(r==RP) { t=addc(t);y=addc(y);}/* ...t=t+ulp;y=y+ulp; */ - y=y+t; /* ...chopped sum */ - py[n0]=py[n0]-0x00100000; /* ...correctly rounded sqrt(x) */ -end: py[n0]=py[n0]+scalx; /* ...scale back y */ - swapRM(r); /* ...restore Rounding Mode */ - return(y); -} -#endif - -#if !_lib_ilogb - -extern int ilogb(double x) -{ - return((int)logb(x)); -} - -#endif - -#endif diff --git a/src/lib/libast/vmalloc/malloc.c b/src/lib/libast/vmalloc/malloc.c index 643375d82..9ef7ad663 100644 --- a/src/lib/libast/vmalloc/malloc.c +++ b/src/lib/libast/vmalloc/malloc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,55 +20,10 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_malloc(){} - -#else - -#if _UWIN - -#define calloc ______calloc -#define _ast_free ______free -#define malloc ______malloc -#define mallinfo ______mallinfo -#define mallopt ______mallopt -#define mstats ______mstats -#define realloc ______realloc - -#define _STDLIB_H_ 1 - -extern int atexit(void(*)(void)); -extern char* getenv(const char*); - -#endif #include "vmhdr.h" #include -#if _UWIN - -#include - -#define _map_malloc 1 -#define _mal_alloca 1 - -#undef calloc -#define calloc _ast_calloc -#undef _ast_free -#define free _ast_free -#undef malloc -#define malloc _ast_malloc -#undef mallinfo -typedef struct ______mallinfo Mallinfo_t; -#undef mallopt -#undef mstats -typedef struct ______mstats Mstats_t; -#undef realloc -#define realloc _ast_realloc - -#endif - /* * define _AST_std_malloc=1 to force the standard malloc * if _map_malloc is also defined then _ast_malloc etc. @@ -170,26 +125,6 @@ static int _Vmpffd = -1; #include -#if _UWIN - -#define VMRECORD(p) _vmrecord(p) -#define VMBLOCK { int _vmblock = _sigblock(); -#define VMUNBLOCK _sigunblock(_vmblock); } - -extern int _sigblock(void); -extern void _sigunblock(int); -extern unsigned long _record[2048]; - -__inline void* _vmrecord(void* p) -{ - register unsigned long v = ((unsigned long)p)>>16; - - _record[v>>5] |= 1<<((v&0x1f)); - return p; -} - -#else - #define getenv(s) lcl_getenv(s) static char* @@ -202,9 +137,6 @@ lcl_getenv(const char* s) return 0; return buf; } - -#endif /* _UWIN */ - #endif /* _WINIX */ #ifndef VMRECORD @@ -829,15 +761,11 @@ extern void* __libc_valloc(size_t n) { return valloc(n); } #undef valloc #define valloc ______valloc -#if !_UWIN - #include typedef struct mallinfo Mallinfo_t; typedef struct mstats Mstats_t; -#endif - #if defined(__EXPORT__) #define extern __EXPORT__ #endif @@ -940,15 +868,11 @@ extern void* _ast_valloc(size_t n) { return valloc(n); } #define realloc ______realloc #define valloc ______valloc -#if !_UWIN - #include typedef struct mallinfo Mallinfo_t; typedef struct mstats Mstats_t; -#endif - #if defined(__EXPORT__) #define extern __EXPORT__ #endif @@ -1313,5 +1237,3 @@ _vmkeep(int v) _Vmassert &= ~VM_keep; return r; } - -#endif /*_UWIN*/ diff --git a/src/lib/libast/vmalloc/vmbest.c b/src/lib/libast/vmalloc/vmbest.c index 18ff1cd16..db2c9f5a2 100644 --- a/src/lib/libast/vmalloc/vmbest.c +++ b/src/lib/libast/vmalloc/vmbest.c @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmbest(){} - -#else #include "vmhdr.h" @@ -1307,5 +1302,3 @@ __DEFINE__(Vmdisc_t*, Vmdcsbrk, (Vmdisc_t*)(&_Vmdcsystem) ); #ifdef NoF NoF(vmbest) #endif - -#endif diff --git a/src/lib/libast/vmalloc/vmclear.c b/src/lib/libast/vmalloc/vmclear.c index 89ebc0d12..21c7d2b4e 100644 --- a/src/lib/libast/vmalloc/vmclear.c +++ b/src/lib/libast/vmalloc/vmclear.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmclear(){} - -#else #include "vmhdr.h" @@ -77,5 +72,3 @@ int vmclear(Vmalloc_t* vm) return 0; } - -#endif diff --git a/src/lib/libast/vmalloc/vmclose.c b/src/lib/libast/vmalloc/vmclose.c index 55542cab0..e11f99dfc 100644 --- a/src/lib/libast/vmalloc/vmclose.c +++ b/src/lib/libast/vmalloc/vmclose.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmclose(){} - -#else #include "vmhdr.h" @@ -83,5 +78,3 @@ int vmclose(Vmalloc_t* vm) return 0; } - -#endif diff --git a/src/lib/libast/vmalloc/vmdcheap.c b/src/lib/libast/vmalloc/vmdcheap.c index 28e2ab069..148a835bf 100644 --- a/src/lib/libast/vmalloc/vmdcheap.c +++ b/src/lib/libast/vmalloc/vmdcheap.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmdcheap(){} - -#else #include "vmhdr.h" @@ -53,5 +48,3 @@ __DEFINE__(Vmdisc_t*,Vmdcheap,&_Vmdcheap); #ifdef NoF NoF(vmdcheap) #endif - -#endif diff --git a/src/lib/libast/vmalloc/vmdebug.c b/src/lib/libast/vmalloc/vmdebug.c index 8a0c77196..709839745 100644 --- a/src/lib/libast/vmalloc/vmdebug.c +++ b/src/lib/libast/vmalloc/vmdebug.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmdebug(){} - -#else #include "vmhdr.h" @@ -647,5 +642,3 @@ __DEFINE__(Vmethod_t*,Vmdebug,&_Vmdebug); #ifdef NoF NoF(vmdebug) #endif - -#endif diff --git a/src/lib/libast/vmalloc/vmdisc.c b/src/lib/libast/vmalloc/vmdisc.c index 2a7d30728..225cb65a5 100644 --- a/src/lib/libast/vmalloc/vmdisc.c +++ b/src/lib/libast/vmalloc/vmdisc.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmdisc(){} - -#else #include "vmhdr.h" @@ -46,5 +41,3 @@ Vmdisc_t* vmdisc(Vmalloc_t* vm, Vmdisc_t* disc) } return old; } - -#endif diff --git a/src/lib/libast/vmalloc/vmexit.c b/src/lib/libast/vmalloc/vmexit.c index 06a274eb2..713ddd94b 100644 --- a/src/lib/libast/vmalloc/vmexit.c +++ b/src/lib/libast/vmalloc/vmexit.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmexit(){} - -#else #include "vmhdr.h" @@ -82,5 +77,3 @@ void exit(int type) #endif /* _lib_onexit */ #endif /*!PACKAGE_ast*/ - -#endif diff --git a/src/lib/libast/vmalloc/vmhdr.h b/src/lib/libast/vmalloc/vmhdr.h index e7c264297..ccd4a2d6b 100644 --- a/src/lib/libast/vmalloc/vmhdr.h +++ b/src/lib/libast/vmalloc/vmhdr.h @@ -33,13 +33,11 @@ #if _PACKAGE_ast -#if !_UWIN #define getpagesize ______getpagesize #define _npt_getpagesize 1 #define brk ______brk #define sbrk ______sbrk #define _npt_sbrk 1 -#endif #include @@ -55,10 +53,8 @@ #include -#if !_UWIN #define _npt_getpagesize 1 #define _npt_sbrk 1 -#endif #undef free #undef malloc @@ -112,10 +108,6 @@ typedef struct _pfobj_s Pfobj_t; #define VM_keep 0x0010 /* disable free() */ #define VM_mmap 0x0020 /* try mmap() block allocator first */ -#if _UWIN -#include -#endif - #ifndef DEBUG #ifdef _BLD_DEBUG #define DEBUG 1 diff --git a/src/lib/libast/vmalloc/vmlast.c b/src/lib/libast/vmalloc/vmlast.c index ff96b2e70..e1ce08e63 100644 --- a/src/lib/libast/vmalloc/vmlast.c +++ b/src/lib/libast/vmalloc/vmlast.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmlast(){} - -#else #include "vmhdr.h" @@ -377,5 +372,3 @@ __DEFINE__(Vmethod_t*,Vmlast,&_Vmlast); #ifdef NoF NoF(vmlast) #endif - -#endif diff --git a/src/lib/libast/vmalloc/vmmopen.c b/src/lib/libast/vmalloc/vmmopen.c index 4d073f948..f2a453469 100644 --- a/src/lib/libast/vmalloc/vmmopen.c +++ b/src/lib/libast/vmalloc/vmmopen.c @@ -21,7 +21,7 @@ * * ***********************************************************************/ #include "FEATURE/vmalloc" -#if !_hdr_sys_shm || (defined(_UWIN) && defined(_BLD_ast)) +#if !_hdr_sys_shm void _STUB_vmmapopen(){} diff --git a/src/lib/libast/vmalloc/vmopen.c b/src/lib/libast/vmalloc/vmopen.c index 4a8847fc0..6bcbd0993 100644 --- a/src/lib/libast/vmalloc/vmopen.c +++ b/src/lib/libast/vmalloc/vmopen.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmopen(){} - -#else #include "vmhdr.h" @@ -177,5 +172,3 @@ done: /* now make the region handle */ return vm; } - -#endif diff --git a/src/lib/libast/vmalloc/vmpool.c b/src/lib/libast/vmalloc/vmpool.c index b74988082..2f1f99587 100644 --- a/src/lib/libast/vmalloc/vmpool.c +++ b/src/lib/libast/vmalloc/vmpool.c @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmpool(){} - -#else #include "vmhdr.h" @@ -262,5 +257,3 @@ __DEFINE__(Vmethod_t*,Vmpool,&_Vmpool); #ifdef NoF NoF(vmpool) #endif - -#endif diff --git a/src/lib/libast/vmalloc/vmprivate.c b/src/lib/libast/vmalloc/vmprivate.c index bea7e911d..44aed942a 100644 --- a/src/lib/libast/vmalloc/vmprivate.c +++ b/src/lib/libast/vmalloc/vmprivate.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmprivate(){} - -#else #include "vmhdr.h" @@ -277,5 +272,3 @@ Vmextern_t _Vmextern = size_t,size_t)), /* _Vmtrace */ NIL(void(*)(Vmalloc_t*)) /* _Vmpfclose */ }; - -#endif diff --git a/src/lib/libast/vmalloc/vmprofile.c b/src/lib/libast/vmalloc/vmprofile.c index bb26590a1..43cd67e5b 100644 --- a/src/lib/libast/vmalloc/vmprofile.c +++ b/src/lib/libast/vmalloc/vmprofile.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmprofile(){} - -#else #include "vmhdr.h" @@ -614,5 +609,3 @@ __DEFINE__(Vmethod_t*,Vmprofile,&_Vmprofile); #ifdef NoF NoF(vmprofile) #endif - -#endif diff --git a/src/lib/libast/vmalloc/vmregion.c b/src/lib/libast/vmalloc/vmregion.c index 021c96551..48b37430d 100644 --- a/src/lib/libast/vmalloc/vmregion.c +++ b/src/lib/libast/vmalloc/vmregion.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmregion(){} - -#else #include "vmhdr.h" @@ -53,5 +48,3 @@ Vmalloc_t* vmregion(void* addr) return vm; } - -#endif diff --git a/src/lib/libast/vmalloc/vmsegment.c b/src/lib/libast/vmalloc/vmsegment.c index 62d65327b..9be6b1141 100644 --- a/src/lib/libast/vmalloc/vmsegment.c +++ b/src/lib/libast/vmalloc/vmsegment.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmsegment(){} - -#else #include "vmhdr.h" @@ -50,5 +45,3 @@ void* vmsegment(Vmalloc_t* vm, /* region */ return seg ? (void*)seg->addr : NIL(void*); } - -#endif diff --git a/src/lib/libast/vmalloc/vmset.c b/src/lib/libast/vmalloc/vmset.c index 7437a5ba5..37323f78a 100644 --- a/src/lib/libast/vmalloc/vmset.c +++ b/src/lib/libast/vmalloc/vmset.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmset(){} - -#else #include "vmhdr.h" @@ -54,5 +49,3 @@ int vmset(reg Vmalloc_t* vm, /* region being worked on */ return mode; } - -#endif diff --git a/src/lib/libast/vmalloc/vmstat.c b/src/lib/libast/vmalloc/vmstat.c index 1a48ad6fa..a30299d82 100644 --- a/src/lib/libast/vmalloc/vmstat.c +++ b/src/lib/libast/vmalloc/vmstat.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2012 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmstat(){} - -#else #include "vmhdr.h" @@ -135,5 +130,3 @@ int vmstat(Vmalloc_t* vm, Vmstat_t* st) return 0; } - -#endif diff --git a/src/lib/libast/vmalloc/vmstrdup.c b/src/lib/libast/vmalloc/vmstrdup.c index 42b5e95b2..c0c79bf63 100644 --- a/src/lib/libast/vmalloc/vmstrdup.c +++ b/src/lib/libast/vmalloc/vmstrdup.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmstrdup(){} - -#else #include "vmhdr.h" @@ -39,5 +34,3 @@ char* vmstrdup(Vmalloc_t* v, register const char* s) return (s && (t = vmalloc(v, n = strlen(s) + 1))) ? (char*)memcpy(t, s, n) : (char*)0; } - -#endif diff --git a/src/lib/libast/vmalloc/vmtrace.c b/src/lib/libast/vmalloc/vmtrace.c index 5bb245e7b..6bea119e3 100644 --- a/src/lib/libast/vmalloc/vmtrace.c +++ b/src/lib/libast/vmalloc/vmtrace.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmtrace(){} - -#else #include "vmhdr.h" @@ -247,5 +242,3 @@ int vmtrbusy(Vmalloc_t* vm) return 0; } - -#endif diff --git a/src/lib/libast/vmalloc/vmwalk.c b/src/lib/libast/vmalloc/vmwalk.c index a3451e4e2..1113908a2 100644 --- a/src/lib/libast/vmalloc/vmwalk.c +++ b/src/lib/libast/vmalloc/vmwalk.c @@ -2,7 +2,7 @@ * * * This software is part of the ast package * * Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2021 Contributors to ksh 93u+m * +* Copyright (c) 2020-2022 Contributors to ksh 93u+m * * and is licensed under the * * Eclipse Public License, Version 1.0 * * by AT&T Intellectual Property * @@ -20,11 +20,6 @@ * Phong Vo * * * ***********************************************************************/ -#if defined(_UWIN) && defined(_BLD_ast) - -void _STUB_vmwalk(){} - -#else #include "vmhdr.h" @@ -59,5 +54,3 @@ int vmwalk(Vmalloc_t* vm, int(*segf)(Vmalloc_t*, void*, size_t, Vmdisc_t*, void* return rv; } - -#endif