From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/symtab/stsave.x | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sys/symtab/stsave.x (limited to 'sys/symtab/stsave.x') diff --git a/sys/symtab/stsave.x b/sys/symtab/stsave.x new file mode 100644 index 00000000..a77d710f --- /dev/null +++ b/sys/symtab/stsave.x @@ -0,0 +1,41 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include "symtab.h" + +define SZ_BLOCK 2048 + + +# STSAVE -- Save the symbol table in an external binary file in a machine +# independent format. This works provided only integer and character data +# is stored in the symbol table. + +procedure stsave (stp, fd) + +pointer stp # symtab descriptor +int fd # output file + +int nelem +int ip, itop +errchk miiwritei, miiwritec + +begin + call miiwritei (fd, Memi[stp], LEN_SYMTAB) + call miiwritei (fd, Memi[ST_INDEX(stp)], ST_INDEXLEN(stp)) + + # Since the symbol table can be very large, write it out in chunks + # of a reasonable size to avoid allocating large buffers. + + itop = ST_STABP(stp) + ST_STABLEN(stp) + for (ip=ST_STABP(stp); ip < itop; ip=ip+nelem) { + nelem = min (SZ_BLOCK, itop - ip) + call miiwritei (fd, Memi[ip], nelem) + } + + # Ditto for the string buffer. + + itop = ST_SBUFP(stp) + ST_SBUFLEN(stp) + for (ip=ST_SBUFP(stp); ip < itop; ip=ip+nelem) { + nelem = min (SZ_BLOCK, itop - ip) + call miiwritec (fd, Memc[ip], nelem) + } +end -- cgit