diff --git a/src/lib/libast/Mamfile b/src/lib/libast/Mamfile index 4627c65f5845..c6ce01be8afc 100644 --- a/src/lib/libast/Mamfile +++ b/src/lib/libast/Mamfile @@ -152,10 +152,6 @@ make install virtual prev FEATURE/lib exec - cp -f %{<} %{@} done - make ast_mmap.h - prev FEATURE/mmap - exec - cp -f %{<} %{@} - done make ast_fs.h prev FEATURE/fs exec - cp -f %{<} %{@} @@ -4295,15 +4291,6 @@ make install virtual exec - compile %{<} done - make astcopy.o - make port/astcopy.c - prev include/ls.h - prev ast_mmap.h - prev include/ast.h - done - exec - compile %{<} - done - make astconf.o make port/astconf.c prev FEATURE/libpath @@ -4480,7 +4467,7 @@ make install virtual done done note * ...generated headers - loop HDR ast_release ast_standards ast_common ast_lib ast_sys lc align sig tmx tv ast_api ast_ccode ast_fcntl ast_float ast_fs ast_map ast_mmap ast_mode ast_ndbm ast_param ast_random ast_time ast_tty ast_limits ast_sizeof ast_dirent ast_iconv ast_nl_types ast_stdio ast_wchar ast_wctype + loop HDR ast_release ast_standards ast_common ast_lib ast_sys lc align sig tmx tv ast_api ast_ccode ast_fcntl ast_float ast_fs ast_map ast_mode ast_ndbm ast_param ast_random ast_time ast_tty ast_limits ast_sizeof ast_dirent ast_iconv ast_nl_types ast_stdio ast_wchar ast_wctype make %{INCLUDE_AST}/%{HDR}.h prev %{HDR}.h exec - cp -f %{<} %{@} diff --git a/src/lib/libast/include/ast.h b/src/lib/libast/include/ast.h index 8c754c6a1ec2..81cc7adfdcbe 100644 --- a/src/lib/libast/include/ast.h +++ b/src/lib/libast/include/ast.h @@ -293,7 +293,6 @@ extern char* astgetconf(const char*, const char*, const char*, int, Error_f); extern char* astconf(const char*, const char*, const char*); extern Ast_confdisc_f astconfdisc(Ast_confdisc_f); extern void astconflist(Sfio_t*, const char*, int, const char*); -extern off_t astcopy(int, int, off_t); extern int astquery(int, const char*, ...); extern void astwinsize(int, int*, int*); #if _lib_sysconf diff --git a/src/lib/libast/man/ast.3 b/src/lib/libast/man/ast.3 index c88927aad512..54c32213c3fd 100644 --- a/src/lib/libast/man/ast.3 +++ b/src/lib/libast/man/ast.3 @@ -48,7 +48,6 @@ long astconf_long(\fIarg\fP); unsigned long astconf_ulong(\fIarg\fP); Ast_confdisc_t astconfdisc(Ast_confdisc_t new_notify); void astconflist(Sfio_t* stream, const char* path, int flags); -off_t astcopy(int \fIrfd\fP, int \fIwfd\fP, off_t \fIn\fP); int astquery(int \fIfd\fP, const char* \fIformat\fP , ...); .EE .SH DESCRIPTION @@ -223,29 +222,6 @@ snarfed for input to the .IR getconf (1) command. .PP -.L astcopy -efficiently copies up to -.I n -bytes from the file descriptor -.I rfd -to the file descriptor -.IR wfd . -The actual number of bytes copied is returned; \-1 is returned on error. -If -.I n -is 0 then an optimal number of bytes (with respect to both -.I rfd -and -.IR wfd ) -is copied. -.PP -If possible -.IR mmap (2) -is used to do the transfer. -Some implementations may bypass user buffer copies usually required by the -.IR read (2)- write (2) -paradigm. -.PP .L astquery outputs an .IR sfprintf (3) diff --git a/src/lib/libast/port/astcopy.c b/src/lib/libast/port/astcopy.c deleted file mode 100644 index 49d58366bdb2..000000000000 --- a/src/lib/libast/port/astcopy.c +++ /dev/null @@ -1,86 +0,0 @@ -/*********************************************************************** -* * -* This software is part of the ast package * -* Copyright (c) 1985-2011 AT&T Intellectual Property * -* Copyright (c) 2020-2023 Contributors to ksh 93u+m * -* and is licensed under the * -* Eclipse Public License, Version 2.0 * -* * -* A copy of the License is available at * -* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html * -* (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) * -* * -* Glenn Fowler * -* David Korn * -* Phong Vo * -* Martijn Dekker * -* * -***********************************************************************/ -/* - * Glenn Fowler - * AT&T Bell Laboratories - * - * copy from rfd to wfd (with conditional mmap hacks) - */ - -#include -#include - -#if _mmap_worthy > 1 - -#include - -#define MAPSIZE (1024*256) - -#endif - -#undef BUFSIZ -#define BUFSIZ 4096 - -/* - * copy n bytes from rfd to wfd - * actual byte count returned - * if n<=0 then ``good'' size is used - */ - -off_t -astcopy(int rfd, int wfd, off_t n) -{ - off_t c; -#ifdef MAPSIZE - off_t pos; - off_t mapsize; - char* mapbuf; - struct stat st; -#endif - - static int bufsiz; - static char* buf; - - if (n <= 0 || n >= BUFSIZ * 2) - { -#if MAPSIZE - if (!fstat(rfd, &st) && S_ISREG(st.st_mode) && (pos = lseek(rfd, 0, 1)) != ((off_t)-1)) - { - if (pos >= st.st_size) return 0; - mapsize = st.st_size - pos; - if (mapsize > MAPSIZE) mapsize = (mapsize > n && n > 0) ? n : MAPSIZE; - if (mapsize >= BUFSIZ * 2 && (mapbuf = (char*)mmap(NULL, mapsize, PROT_READ, MAP_SHARED, rfd, pos)) != ((caddr_t)-1)) - { - if (write(wfd, mapbuf, mapsize) != mapsize || lseek(rfd, mapsize, 1) == ((off_t)-1)) return -1; - munmap((caddr_t)mapbuf, mapsize); - return mapsize; - } - } -#endif - if (n <= 0) n = BUFSIZ; - } - if (n > bufsiz) - { - if (buf) free(buf); - bufsiz = roundof(n, BUFSIZ); - if (!(buf = newof(0, char, bufsiz, 0))) return -1; - } - if ((c = read(rfd, buf, (size_t)n)) > 0 && write(wfd, buf, (size_t)c) != c) c = -1; - return c; -}