diff options
Diffstat (limited to 'sys/symtab/stsave.x')
-rw-r--r-- | sys/symtab/stsave.x | 41 |
1 files changed, 41 insertions, 0 deletions
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 |