From 3c7c4ef5e1ff901f1f32f4975077d05440d3aace Mon Sep 17 00:00:00 2001 From: Matt Needes Date: Tue, 21 Jun 1994 21:21:47 +0000 Subject: [PATCH] LANL libCom merge for R3.12 --- src/libCom/ezsSockSubr.c | 6 +- src/libCom/fdmgr.c | 9 +- src/libCom/pal.c | 591 +++++++++++++++++++++++++++++++++++++++ src/libCom/paldef.c | 246 ++++++++++++++++ src/libCom/tsSubr.c | 11 +- 5 files changed, 855 insertions(+), 8 deletions(-) create mode 100644 src/libCom/pal.c create mode 100644 src/libCom/paldef.c diff --git a/src/libCom/ezsSockSubr.c b/src/libCom/ezsSockSubr.c index 5f247e577..2f26e0614 100644 --- a/src/libCom/ezsSockSubr.c +++ b/src/libCom/ezsSockSubr.c @@ -1,4 +1,4 @@ -/* $Id$ +/* @(#)ezsSockSubr.c 1.8 5/17/94 * Author: Roger A. Cole * Date: 11-23-90 * @@ -31,6 +31,7 @@ * .03 12-08-91 rac added a comment for ezsFopenToFd * .04 10-09-92 rac use SO_REUSEADDR with socket * .05 08-11-93 mrk removed V5_vxWorks + * .06 05-04-94 pg HPUX port changes. * * make options * -DvxWorks makes a version for VxWorks @@ -178,6 +179,7 @@ char *message; /* O message from server (dimension of 80 assumed) */ struct hostent *gethostbyname(); #endif int i; + int optval=1; assert(pServerSock != NULL); assert(portNum > 0); @@ -211,7 +213,7 @@ char *message; /* O message from server (dimension of 80 assumed) */ *pServerSock = socket(AF_INET, SOCK_STREAM, 0); if (*pServerSock < 0) return -1; - if (setsockopt(*pServerSock, SOL_SOCKET, SO_REUSEADDR, NULL, 0) != 0) { + if (setsockopt(*pServerSock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) != 0) { close(*pServerSock); *pServerSock = -1; return -1; diff --git a/src/libCom/fdmgr.c b/src/libCom/fdmgr.c index f195df157..cec76ce54 100644 --- a/src/libCom/fdmgr.c +++ b/src/libCom/fdmgr.c @@ -1,6 +1,6 @@ /* * - * share/src/libCom/$Id$ + * @(#)fdmgr.c 1.9 5/17/94 * * A file descriptor manager for use with the UNIX system call select * @@ -62,6 +62,7 @@ * if we are in fdmgr_pend_event() * .15 joh 011993 Created fdmgr header file * .16 joh 011993 Converted to ANSI C + * .17 pg 050494 HPUX cpp changes (elif converted to else & if) * * NOTES: * @@ -89,7 +90,7 @@ * */ -static char *pSccsId = "$Id$\t$Date$"; +static char *pSccsId = "@(#)fdmgr.c 1.9\t05/05/94"; #include #ifdef vxWorks @@ -146,7 +147,8 @@ typedef struct{ # define printf logMsg # define fdmgr_gettimeval fdmgr_vxWorks_gettimeval # define memset(D,V,N) bfill(D,N,V) -#elif defined(UNIX) +#else +#if defined(UNIX) # define LOCK(PFDCTX) # define UNLOCK(PFDCTX) # define LOCK_FDMGR_PEND_EVENT(PFDCTX) \ @@ -167,6 +169,7 @@ typedef struct{ #else @@@@ dont compile in this case @@@@ #endif +#endif #define USEC_PER_SEC 1000000 diff --git a/src/libCom/pal.c b/src/libCom/pal.c new file mode 100644 index 000000000..86315d905 --- /dev/null +++ b/src/libCom/pal.c @@ -0,0 +1,591 @@ +/* + * pal.c + * + * pal emulator + * AT-8 hardware design + * + */ + +#include +#include +#include "pal.h" + +/* + * globals + */ + struct pal *phead; /* start of PAL list */ + +/* + * getbit - get an ascii bit (0 or 1) from a JEDEC file + */ +getbit(datfile) + FILE *datfile; +{ + char inchar; + char temp[80]; + + for (inchar = fgetc(datfile); inchar != EOF; inchar = fgetc(datfile)) + if ((inchar == '1') || (inchar =='0')) + break; + else if ((inchar =='L') || (inchar =='l')) + fscanf(datfile,"%s",temp); + return inchar; +} +/* + * palinit - initialize PAL data structures + * + * This is the initialization routine which parses a JEDEC file, + * determines the file type, reads the device specific chip data, + * and initializes the logic arrays for execution. Two data files + * are required: the JEDEC file (in UNIX format), and the PAL + * definition file. + * + * At present, a third data file is read - the limit definition + * file. This file determines the logic "0" and "1" level for + * each input. It is anticipated that this function will become + * an intrinsic part of the EPICS record in the future. + * + */ +struct pal * palinit(file,recname,thresh) + char *file; + char *recname; + double thresh[]; +{ + FILE *datfile; + char temp[80], jedfile[80], inchar; + int i, j, k, l, m, fusenum, itemp, members; + unsigned int *elptr, tmask; + struct thresh *tptr; + struct blk *fptr; + static struct pal *curpal; + + strcpy(jedfile,file); + strcat(jedfile,".jed"); + printf("palinit - opening JEDEC file %s\n",jedfile); + for (i = 0; i < RETRY; i++) + if ((datfile = fopen(jedfile, "r")) != NULL) + break; + if (i == RETRY) + { + printf("palinit:cannot open JEDEC file %s - aborting\n",jedfile); + return (struct pal *)0; + } +/* + * allocate memory for new PAL + */ + if (!phead) + phead = curpal = (struct pal *)malloc(sizeof (struct pal)); + else + { + curpal->flink = (struct pal *)malloc(sizeof (struct pal)); + curpal = curpal->flink; + } + curpal->bptr = (struct blk *)0; + curpal->flink = (struct pal *)0; + curpal->iptr = (struct palinit *)malloc(sizeof (struct palinit)); + curpal->iptr->def = (char *)malloc(strlen(file)+1); + strcpy(curpal->iptr->def,file); + curpal->recnam = (char *)malloc(strlen(recname)+1); + strcpy(curpal->recnam,recname); +/* + * look for PAL type - this info is marked with the character value 02 + */ + for (; (inchar = fgetc(datfile)) != EOF;) + if (inchar == 2) + break; + if (inchar == 2) + { + fscanf(datfile,"%s",temp); + curpal->iptr->name = (char *)malloc(strlen(temp)+1); + strcpy(curpal->iptr->name,temp); + strcpy(temp,file); /* strip off path info from JEDEC input file */ + for (i = strlen(temp); i > 0; i--) + if (temp[i] == '/') + break; + if (i) + temp[i+1] = NULL; + else + temp[0] = NULL; + curpal->iptr->path = (char *)malloc(strlen(temp)+1); + strcpy(curpal->iptr->path,temp); + } + else if (inchar == EOF) + { + printf("palinit:cannot find PAL device type in %s - aborting\n",jedfile); + return (struct pal *)0; + } +/* + * find PAL device specific data + */ + if (paldef(curpal)) + return (struct pal *)0; +/* + * load input threshold data + */ + for (i = j = 0, tptr = curpal->ithresh; i < curpal->inp; i++, tptr++) + { + tptr->lothresh = thresh[j++]; + tptr->hithresh = thresh[j++]; + } +/* + * look for start of fuse data + */ + for (i = fscanf(datfile,"%s",temp); (i != EOF) && (strcmp(temp,"L0000")); i = fscanf(datfile,"%s",temp)); + if (i == EOF) + { + printf("palinit:cannot find fuse data in %s - aborting\n",jedfile); + return (struct pal *)0; + } + fusenum = 0; +/* + * initialize fuse data for each pal block + */ + for (i = 0; i < curpal->blknum; i++) /* for each PAL block */ + { + if (fusenum != curpal->bptr[i].loc) + { + for (; fusenum != curpal->bptr[i].loc; fusenum++) + if (getbit(datfile) == EOF) + { + printf("palinit:cannot find start of PAL block %d file %s - aborting\n",i,jedfile); + return (struct pal *)0; + } + } + for (j = 0, elptr = curpal->bptr[i].array; j < curpal->bptr[i].blksiz; j++) /* for each block element */ + { + members = curpal->blkbits/INTBITS; /* # members per element */ + if (curpal->blkbits%INTBITS) /* check for partially filled member */ + members++; + for (k = 0; k < members; k++, elptr++) /* for each element member */ + { + if (k < curpal->blkbits/INTBITS) /* last member may be partially filled */ + itemp = INTBITS; /* if not do 32 bits worth */ + else + itemp = curpal->blkbits%INTBITS; /* if so how much */ + for (l = 0, *elptr = 0; l < itemp; l++) /* do it */ + { + if ((inchar = getbit(datfile)) == EOF) /* get next data bit */ + { + printf("palinit:unexpected EOF in JEDEC file (pal blocks)\n"); + return (struct pal *)0; + } + else if (inchar == '0') + tmask = 1; /* set bit in element */ + else + tmask = 0; /* clear bit in element */ + *elptr |= tmask<blknum; i++) + for (j = 0, elptr = curpal->bptr[i].array; j < curpal->bptr[i].blksiz; j++, elptr++) + { + for (k = 0, l = 0; k < curpal->blkbits; k++) + { + if (k > ((INTBITS-1)+(INTBITS*l))) + l ++; + if (!(*(elptr+l) & (1<<(k-(l*INTBITS))))) + break; + } + if (k == curpal->blkbits) + for(m = 0; m < curpal->blkelm; m++) + *(elptr + m) = 0; + elptr += curpal->blkelm - 1; + } +/* + * determine scan order - initialize list with combinatorial logic first + */ + for (i = 0, j = 0; i < curpal->blknum; i++) + if (curpal->bptr[i].typ == COMBINATORIAL) + curpal->scan[j++] = i; + for (i = 0; i < curpal->blknum; i++) + if (curpal->bptr[i].typ == REGISTERED) + curpal->scan[j++] = i; +/* + * delete uneeded structures + */ + for (i = 0, fptr = curpal->bptr; i < curpal->blknum; i++, fptr++) + { + free(fptr->rsel); + fptr->rsel = (struct rowsel *)0; + } + for (i = 0, tptr = curpal->ithresh; i < curpal->inp; i++, tptr++) + { + free(tptr->rsel); + tptr->rsel = (struct rowsel *)0; + } + free(curpal->iptr); + curpal->iptr = (struct palinit *)0; +/* + * temporary diagnostic - print out PAL info + * + printf("record name %s\n",curpal->recnam); + printf("%d blocks %d bits %d elements %d inputs\n",curpal->blknum,curpal->blkbits, + curpal->blkelm,curpal->inp); + for (i = 0; i < curpal->blknum; i++) + { + printf("block %d size %d polarity %d type %d\n",i,curpal->bptr[i].blksiz, + curpal->bptr[i].pol,curpal->bptr[i].typ); + printf("fuse %d row %d neg offset %d\n",curpal->bptr[i].loc, + curpal->bptr[i].row,curpal->bptr[i].nrofst); + for (j = 0, elptr = curpal->bptr[i].array; j < curpal->bptr[i].blksiz; j++, elptr++) + { + for (k = 0, l = 0; k < curpal->blkbits; k++) + { + if (k > (INTBITS-1)+l) + { + l += 32; + elptr++; + } + if (*elptr & (1<<(k-l))) + printf("1"); + else + printf("0"); + } + printf("\n"); + } + } + * end diagnostic */ +/* + * initialization done + */ + fclose(datfile); + return curpal; +} +/* + * palconfig + * + * read in device specific configuration information + * + */ +palconfig(datfile, curpal, fusenum) + FILE *datfile; + struct pal *curpal; + int fusenum; +{ + int i, j, k, l, m; + struct thresh *tptr; + struct blk *fptr; + char inchar; + + if (!strcmp(curpal->iptr->name,"PAL16V8")) + { + /* + * The PAL16V8 has a complex macrocell involving 2 configuration + * fuses for feedback, 8 seperate polarity, and 8 seperate type fuses. + * Look for polarity data first + */ + for (; fusenum != curpal->iptr->polloc; fusenum++) + if (getbit(datfile) == EOF) + { + printf("palconfig:cannot find polarity data\n"); + return -1; + } + /* + * read in polarity data for each pal block + */ + for (i = 0; i < curpal->blknum; i++) + { + if ((inchar = getbit(datfile)) == EOF) + { + printf("palconfig:unexpected EOF in JEDEC file %s (polarity)\n",curpal->iptr->def); + return -1; + } + else if (inchar == '0') + curpal->bptr[i].pol = INVERTED; + else + curpal->bptr[i].pol = NORMAL; + fusenum++; + } + /* + * look for output type data + */ + for (; fusenum != curpal->iptr->typloc; fusenum++) + if (getbit(datfile) == EOF) + { + printf("palconfig:cannot find type data\n"); + return -1; + } + /* + * read in type data for each pal block + */ + for (i = 0; i < curpal->blknum; i++) + { + if ((inchar = getbit(datfile)) == EOF) + { + printf("palconfig:unexpected EOF in JEDEC file %s (type)\n",curpal->iptr->def); + return -1; + } + if (inchar == '1') + curpal->bptr[i].typ = COMBINATORIAL; + else + curpal->bptr[i].typ = REGISTERED; + fusenum++; + } + /* + * look for global macrocell configuration data + */ + for (; fusenum != curpal->iptr->s0; fusenum++) + if (getbit(datfile) == EOF) + { + printf("palconfig:cannot find macrocell data\n"); + return -1; + } + /* + * read in global macrocell data + */ + for (i = 0; i < curpal->iptr->snum; i++) + { + if ((inchar = getbit(datfile)) == EOF) + { + printf("palconfig:unexpected EOF in JEDEC file %s (macrocell)\n",curpal->iptr->def); + return -1; + } + if (inchar == '1') + curpal->iptr->mc[i] = 1; + else + curpal->iptr->mc[i] = 0; + fusenum++; + } + /* + * determine input fuse assignments + */ + for (i = 0, tptr = curpal->ithresh; i < curpal->inp; i++, tptr++) + if (tptr->rsel->arow != -1) + if (curpal->iptr->mc[tptr->rsel->sel] == tptr->rsel->psel) + tptr->row = tptr->rsel->prow; + else + tptr->row = tptr->rsel->arow; + else + tptr->row = tptr->rsel->prow; + /* + * determine logic block feedback fuse assignments + */ + for (i = 0, fptr = curpal->bptr; i < curpal->blknum; i++, fptr++) + if (fptr->rsel->arow != -1) + if (curpal->iptr->mc[fptr->rsel->sel] == fptr->rsel->psel) + fptr->row = fptr->rsel->prow; + else + fptr->row = fptr->rsel->arow; + else + fptr->row = fptr->rsel->prow; + } + else if (!strcmp(curpal->iptr->name,"PAL22V10")) + { + /* + * The 22V10 has a simple macrocell where polarity and type are + * controlled by two configuration fuses. + * Look for global macrocell configuration data first + */ + for (; fusenum != curpal->iptr->s0; fusenum++) + if (getbit(datfile) == EOF) + { + printf("palconfig:cannot find macrocell data\n"); + return -1; + } + /* + * read in global macrocell data + */ + for (j = 0; j < curpal->blknum; j++) + { + for (i = 0, k = 0; i < curpal->iptr->snum; i++, k<<1) + { + if ((inchar = getbit(datfile)) == EOF) + { + printf("palconfig:unexpected EOF in JEDEC file %s (macrocell)\n",curpal->iptr->def); + return -1; + } + else if (inchar == '1') + k |= 1<bptr[j].pol = NORMAL; + else + curpal->bptr[j].pol = INVERTED; + if (k & 2) + curpal->bptr[j].typ = COMBINATORIAL; + else + curpal->bptr[j].typ = REGISTERED; + } + /* + * determine input fuse assignments + */ + for (i = 0, tptr = curpal->ithresh; i < curpal->inp; i++, tptr++) + tptr->row = tptr->rsel->prow; + /* + * determine logic block feedback fuse assignments + */ + for (i = 0, fptr = curpal->bptr; i < curpal->blknum; i++, fptr++) + fptr->row = fptr->rsel->prow; + } + return 0; +} +/* + * pal - PAL emulator + * + */ +pal(pptr,in,inum,result) + struct pal *pptr; + double in[]; + int inum; + unsigned int *result; +{ + int i, j; + struct thresh *tptr; + struct blk *lptr; + unsigned int inarray[2]; + unsigned int tval; + + inarray[0] = inarray[1] = tval = 0; + if (!pptr) + return -1; + for (i = 0, tptr = pptr->ithresh; (i < pptr->inp) && (i < inum); i++, tptr++) /* load input bits */ + if (in[i] < tptr->lothresh) + inbitload(tptr,inarray,0); + else if (in[i] > tptr->hithresh) + inbitload(tptr,inarray,1); + for (i = 0, lptr = pptr->bptr; i < pptr->blknum; i++, lptr++) /* load feedback bits */ + if ((!pptr->blktyp) || (!lptr->typ)) /* if not registered 22v10 */ + outbitload(lptr,inarray,(*result>>i)&1); /* feedback from VAL field */ + else + outbitload(lptr,inarray,!((*result>>i)&1)); +/* + * temporary diagnostic - print out array inputs + * + for (i = 0, j = 0; i < pptr->blkbits; i++) + { + if (i > ((INTBITS-1)+(INTBITS*j))) + j ++; + if (inarray[j] & (1<<(i-(j*INTBITS)))) + printf("1"); + else + printf("0"); + } + printf("\t"); +* end diagnostic */ + *result = 0; /* clear VAL field */ + for (i = 0, lptr = pptr->bptr + *(pptr->scan); i < pptr->blknum; i++, lptr = pptr->bptr + *(pptr->scan + i)) /* evaluate blocks */ + { + tval = eval(lptr,inarray,pptr->blkelm); /* evaluate PAL logic block */ + *result |= tval<<(*(pptr->scan+i)); /* load bits into VAL */ + } + return 0; +} +/* + * inbitload - load bits in input array + * + */ +inbitload(tptr,inarray,val) + struct thresh *tptr; + unsigned int inarray[2]; + unsigned int val; +{ + int i; + + tptr->val = val; + if (tptr->row == -1) + return 0; + if (tptr->row < INTBITS) + { + inarray[0] |= val<row; + inarray[0] |= (!val)<<(tptr->row + tptr->nrofst); + } + else + { + i = tptr->row - INTBITS; + inarray[1] |= val<nrofst); + } + return 0; +} +/* + * outbitload - load feedback bits in input array + * + */ +outbitload(lptr,inarray,val) + struct blk *lptr; + unsigned int inarray[2]; + unsigned int val; +{ + int i; + + if (lptr->row == -1) + return 0; + if (lptr->row < INTBITS) + if (val) + { + inarray[0] |= val<row; + inarray[0] &= (val<<(lptr->row + lptr->nrofst)) ^ 0xffffffff; + } + else + { + inarray[0] &= ((!val)<row) ^ 0xffffffff; + inarray[0] |= (!val)<<(lptr->row + lptr->nrofst); + } + else + if (val) + { + i = lptr->row - INTBITS; + inarray[1] |= val<nrofst)) ^ 0xffffffff; + } + else + { + i = lptr->row - INTBITS; + inarray[1] &= ((!val)<nrofst); + } + return 0; +} +/* + * eval - evaluate logic block + * + */ +eval(lptr,inarray,blkelm) + struct blk *lptr; + unsigned int inarray[2]; + int blkelm; +{ + int i, j; + unsigned int *eptr; + int tval, t[2]; + + for (i = tval = 0, eptr = lptr->array; i < lptr->blksiz; i++) + { + for (j = t[0] = t[1] = 0; j < blkelm; j++, eptr++) + if ((inarray[j] & *eptr) == *eptr) + { + t[j] = 1; + if (*eptr) + tval = 1; + } + for (j = 0; j < blkelm; j++) + tval &= t[j]; + if (tval) + { + if (lptr->pol == INVERTED) + tval = 0; + lptr->val = tval; + if (lptr->typ == COMBINATORIAL) + outbitload(lptr,inarray,lptr->val); + return lptr->val; + } + } + if (lptr->pol == INVERTED) + tval = 1; + lptr->val = tval; + if (lptr->typ == COMBINATORIAL) + outbitload(lptr,inarray,lptr->val); + return lptr->val; +} diff --git a/src/libCom/paldef.c b/src/libCom/paldef.c new file mode 100644 index 000000000..6494b0188 --- /dev/null +++ b/src/libCom/paldef.c @@ -0,0 +1,246 @@ +/* + * paldef - read PAL type definition file + * + * The PAL definition file contains the device specific + * information required to emulate a particular PAL chip + * type. It is a simple tab delimited ASCII file. This + * routine parses the file and loads the information in + * the PAL definition structure. + * + */ +#include +#include +#include "pal.h" + +/* + * PAL definition keywords recognised by paldef parser + */ +#define BLK0 0 /* starting fuse address of first pal block */ +#define BLKSIZ 1 /* pal block size */ +#define BLKELM 2 /* longwords per product term */ +#define BLKBITS 3 /* bits per product term */ +#define BLKNUM 4 /* number of pal blocks */ +#define POLLOC 5 /* starting fuse address of polarity info */ +#define TYPLOC 6 /* starting fuse address of output type info */ +#define INPNUM 7 /* number of inputs */ +#define INPUT 8 /* start of input definition info */ +#define S0 9 /* starting fuse address of macrocell definition */ +#define NAME 10 /* PAL device type */ +#define BLOCK 11 /* start of PAL logic block info */ +#define ROW 12 /* fuse row (bit) location */ +#define AROW 13 /* alternate fuse row (bit) location */ +#define POL 14 /* polarity information */ +#define SNUM 15 /* number of macrocell definition bits */ +#define ENDBLK 16 +#define ENDINP 17 +#define SFUSE 18 /* macrocell select bit */ +#define SVAL 19 /* select value for primary row */ +#define NROW 20 /* negative feedback offset */ +#define LOC 21 /* starting address of block fuse array */ +#define BLKTYP 22 /* macrocell type */ +static char *keylist[] = {"blk0","blksiz","blkelm","blkbits","blknum","polloc", + "typloc","inpnum","input","s0","name","block","row", + "arow","pol","snum","endblk","endinp","sfuse","sval", + "nrow","loc","blktyp"}; +static int keynum = sizeof(keylist)/sizeof(keylist[0]); +char temp[80]; + + +/* + * getkey - look for keyword + * + */ +getkey(file,list,num) + FILE *file; + char *list[]; + int num; +{ + int key; + + if (fscanf(file,"%s",temp) == EOF) + return -1; + for (key = 0; key < num; key++) + if (!strcmp(temp,list[key])) + break; + return key; +} + +paldef(defpal) + struct pal *defpal; +{ + FILE *datfile; + char filenam[80]; + char inchar; + int key; + struct blk *curblk = (struct blk *)0; + struct thresh *curinp = (struct thresh *)0; + int blknum, inpnum; + int i; + + strcpy(filenam,defpal->iptr->path); + strcat(filenam,defpal->iptr->name); + strcat(filenam,".def"); + printf("paldef - opening %s\n",filenam); + for (i = 0; i < RETRY; i++) + if ((datfile = fopen(filenam,"r")) != NULL) + break; + if (i == RETRY) + { + printf("paldef:cannot open PAL definition file %s - aborting\n",filenam); + return -1; + } + defpal->iptr->polloc = defpal->iptr->typloc = defpal->iptr->s0 = -1; + for(key = getkey(datfile,keylist,keynum); key != -1; key = getkey(datfile,keylist,keynum)) + switch (key) + { + case BLK0: + fscanf(datfile,"%d",&defpal->iptr->blk0); + break; + case BLKELM: + fscanf(datfile,"%d",&defpal->blkelm); + break; + case BLKBITS: + fscanf(datfile,"%d",&defpal->blkbits); + break; + case BLKNUM: + if (defpal->blknum) + { + printf("paldef:error in %s - redefining number of PAL blocks - aborting\n",filenam); + return -1; + } + fscanf(datfile,"%d",&defpal->blknum); + defpal->bptr = (struct blk *)malloc((sizeof (struct blk)) * defpal->blknum); + defpal->scan = (int *)malloc((sizeof (int)) * defpal->blknum); + break; + case BLKTYP: + fscanf(datfile,"%d",&defpal->blktyp); + break; + case POLLOC: + fscanf(datfile,"%d",&defpal->iptr->polloc); + break; + case TYPLOC: + fscanf(datfile,"%d",&defpal->iptr->typloc); + break; + case INPNUM: + fscanf(datfile,"%d",&defpal->inp); + defpal->ithresh = (struct thresh *)malloc((sizeof (struct thresh)) * defpal->inp); + break; + case BLOCK: + fscanf(datfile,"%d",&blknum); + if (!defpal->blkelm) + { + printf("paldef:error - no current block element size - aborting\n"); + return -1; + } + if (blknum < defpal->blknum) + { + curblk = defpal->bptr + blknum; + curblk->array = (unsigned int *)0; + curblk->pol = curblk->typ = curblk->val = curblk->blksiz = 0; + curblk->rsel = (struct rowsel *)malloc(sizeof (struct rowsel)); + curblk->rsel->prow = curblk->rsel->arow = curblk->rsel->sel = curblk->rsel->psel = -1; + } + readblk(datfile,curblk,defpal->blkelm); + break; + case INPUT: + fscanf(datfile,"%d",&inpnum); + if (inpnum < defpal->inp) + { + curinp = defpal->ithresh + inpnum; + curinp->rsel = (struct rowsel *)malloc(sizeof (struct rowsel)); + curinp->rsel->prow = curinp->rsel->arow = curinp->rsel->sel = curinp->rsel->psel = -1; + } + readinp(datfile,curinp); + break; + case S0: + fscanf(datfile,"%d",&defpal->iptr->s0); + break; + case SNUM: + fscanf(datfile,"%d",&defpal->iptr->snum); + break; + default: + if (temp[0] == ';') + for (inchar = fgetc(datfile); (inchar != '\n') && (inchar != EOF); inchar = fgetc(datfile)); + break; + } + return 0; +} +/* + * readblk - read PAL logic block + * + */ +readblk(datfile,curblk,blkelm) + FILE *datfile; + struct blk *curblk; + int blkelm; +{ + int key; + char inchar; + + for(key = getkey(datfile,keylist,keynum); key != ENDBLK; key = getkey(datfile,keylist,keynum)) + switch (key) + { + case BLKSIZ: + fscanf(datfile,"%d",&curblk->blksiz); + curblk->array = (unsigned int *)malloc((sizeof (unsigned int)) * curblk->blksiz * blkelm); + break; + case ROW: + fscanf(datfile,"%d",&curblk->rsel->prow); + break; + case AROW: + fscanf(datfile,"%d",&curblk->rsel->arow); + break; + case SFUSE: + fscanf(datfile,"%d",&curblk->rsel->sel); + break; + case SVAL: + fscanf(datfile,"%d",&curblk->rsel->psel); + break; + case NROW: + fscanf(datfile,"%d",&curblk->nrofst); + break; + case LOC: + fscanf(datfile,"%d",&curblk->loc); + break; + default: + if (temp[0] == ';') + for (inchar = fgetc(datfile); (inchar != '\n') && (inchar != EOF); inchar = fgetc(datfile)); + break; + } + return 0; +} +/* + * readinp - read PAL input info + * + */ +readinp(datfile,curinp) + FILE *datfile; + struct thresh *curinp; +{ + int key; + char inchar; + + for(key = getkey(datfile,keylist,keynum); key != ENDINP; key = getkey(datfile,keylist,keynum)) + switch (key) + { + case ROW: + fscanf(datfile,"%d",&curinp->rsel->prow); + break; + case AROW: + fscanf(datfile,"%d",&curinp->rsel->arow); + break; + case SFUSE: + fscanf(datfile,"%d",&curinp->rsel->sel); + break; + case SVAL: + fscanf(datfile,"%d",&curinp->rsel->psel); + break; + case NROW: + fscanf(datfile,"%d",&curinp->nrofst); + default: + if (temp[0] == ';') + for (inchar = fgetc(datfile); (inchar != '\n') && (inchar != EOF); inchar = fgetc(datfile)); + break; + } + return 0; +} diff --git a/src/libCom/tsSubr.c b/src/libCom/tsSubr.c index dcc1c5da8..4aba69b84 100644 --- a/src/libCom/tsSubr.c +++ b/src/libCom/tsSubr.c @@ -1,4 +1,4 @@ -/* $Id$ +/* @(#)tsSubr.c 1.12 5/23/94 * Author: Roger A. Cole * Date: 08-09-90 * @@ -36,6 +36,7 @@ * .08 04-02-92 joh fixed number of days in a year uninitialized * .09 02-09-94 jbk tsLocalTime() now calls TScurrentTimeStamp() vxWorks * for the EPOCH year + * .10 05-04-94 pg HPUX cpp changes. (elif to else and if) * * make options * -DvxWorks makes a version for VxWorks @@ -111,7 +112,8 @@ # include # include # include -#elif VMS +#else +#if VMS #else # include # include @@ -119,6 +121,7 @@ # include # include #endif +#endif #ifndef INC_genDefs_h # include /* provides assert() */ @@ -596,7 +599,8 @@ TS_STAMP *pStamp; /* O pointer to time stamp buffer */ # else return TScurrentTimeStamp((struct timespec*)pStamp); # endif -#elif VMS +#else +#if VMS assert(0); /* not available on VMS */ assert(pStamp != NULL); #else /* SunOS */ @@ -609,6 +613,7 @@ TS_STAMP *pStamp; /* O pointer to time stamp buffer */ pStamp->nsec = ( curtime.tv_usec/1000 ) * 1000000; pStamp->secPastEpoch = curtime.tv_sec - TS_EPOCH_SEC_PAST_1970; } +#endif #endif pStamp->nsec = pStamp->nsec - (pStamp->nsec % TS_TRUNC);