File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / usr.bin / cdb / transBsd / sym42init.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:25:33 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/* $Header: /var/lib/cvsd/repos/cci/cci/usr/src/usr.bin/cdb/transBsd/sym42init.c,v 1.1.1.1 2019/07/28 12:25:33 root Exp $ */
/* (C) Copyright 1985 Third Eye Software, Inc. - All Rights Reserved */

#include "tes42.h"

#include <sys/file.h>

#define UpRatio(x, y, z)  (((x + y - 1) * y) / z)


export int	vfdSym; 	/* file descriptor to read from the file */
export int	vcsym;          /* globally accessable length of symbol table */
export char	*vsbStr;        /* string table buffer for our symbol table */
int             vcbStr; 	/* size of string table */
struct exec	vhead;          /* header info of the object file */

export int visymMax;		/* max total symbols (regular+global) */
export int viauxMax;		/* max aux entries */
export int vifdMax;		/* max file entries */
export int vipdMax;		/* max proc entries */
export int vilineMax;		/* max line entries */


/* S Y M 4 2   I N I T */

export void Sym42Init (sbObjName)
char *sbObjName;
{
    int		cb, i;

    if ((vfdSym= open (sbObjName, O_RDONLY, 0)) < 0) {
	perror (sbObjName);
	exit (1);
    } /* if */

    if (read (vfdSym, &vhead, sizeof (vhead)) != sizeof (vhead)) {
	perror (sbObjName);
	exit (1);
    } /* if */

    if (lseek (vfdSym, N_STROFF (vhead), 0) < 0) {
	perror (sbObjName);
	exit (1);
    } /* if */

    if (read (vfdSym, &vcbStr, sizeof (vcbStr)) != sizeof (vcbStr)) {
	perror (sbObjName);
	exit (1);
    } /* if */

    if ((vsbStr= (char *) malloc (vcbStr))== 0) {
	printf ("%s: no memory for string table(%d)\n", sbObjName, vcbStr);
	exit (1);
    } /* if */

    if (read (vfdSym, vsbStr+4, vcbStr-4) != vcbStr-4) {
	perror (sbObjName);
	exit (1);
    } /* if */

    if (lseek (vfdSym, N_SYMOFF (vhead), 0) < 0) {
	perror (sbObjName);
	exit (1);
    } /* if */

    vcsym= vhead.a_syms / cbNLISTR;

    /* make the various tables proportionate to the incoming symtab */
    viauxMax = Max(10000, (vcsym / 2) * vadjust);
    vrgAux = (pAUXU) malloc(viauxMax * cbAUXU);	/* aux table */

    vipdMax = Max(2000, (vcsym / 6) * vadjust);
    vrgPd = (pPDR) malloc(vipdMax * cbPDR);	/* proc table */

    vifdMax = Max(2000, (vcsym / 15) * vadjust);
    vrgFd = (pFDR) malloc(vifdMax * cbFDR);	/* file table */

    vilineMax = Max(10000, (vcsym / 2) * vadjust);
    vrgLine = (pLINER) malloc(vilineMax * cbLINER); /* line no table */

    visymMax = Max(10000, vcsym * vadjust);
    vrgSym = (pSYMR) malloc(visymMax * cbSYMR);	/* symbol table */
    
    visymGlMax = Max(10000, (vcsym / 10) * vadjust);
    vrgSymGlobal = (pSYMR) malloc(visymGlMax * cbSYMR);	/* globals */
    
    vissMax = vcbStr * vadjust;	/* should be enough */
    vsbNewStr = vsbMax = (char *) malloc(vissMax);
    *vsbMax++ = 0;
    vissMac = 1;

    cb = 4000 * sizeof(int);
    vrgTesF42 = (int *) malloc(cb);
    ZeroBlock(vrgTesF42, cb);
    for (i = 0; i < tesF42Low; i++)
	vrgTesF42[i] = i;
} /* sym42Init */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.