add LCC - a better C-Compiler for WEGA

This commit is contained in:
Oliver Lehmann 1990-03-28 18:52:17 +00:00
parent 2b6598fb74
commit 541230dbb8
12 changed files with 671 additions and 0 deletions

View File

@ -0,0 +1,26 @@
/*
* Hardware bits
*/
#define DTR 00002 /* Data Terminal Ready (primary alarm) */
#define R2S 00004 /* Request to Send (clear signal) */
#define RCT 00010 /* Secondary Transmit Data (auxiliary alarm) */
#define RCR 02000 /* Secondary Received Data (primary alarm status) */
#define C2S 020000 /* Clear to Send (auxiliary alarm status) */
#define RCHAR 063 /* The "reset character" */
/*
* Function codes
*/
#define ALPRI 002000 /* Primary set, and test mask */
#define ALAUX 020000 /* Auxiliary set, and test mask */
#define ALTIME 000377 /* Timeout delay value mask */
#define ALSET 001000 /* Set timer delay */
#define ALRESET 004000 /* Restart watchdog timer */
#define ALCLEAR 010000 /* Clear all alarms */
struct sgtty alsgtty;
#define alrmopn(name) (alfildes = open(name,2))
#define alrmclo() close(alfildes)
#define alrm(cmd) \
(&alsgtty->sg_flags = cmd, stty(alfildes, &alsgtty), &alsgtty->sg_flags)

View File

@ -0,0 +1,28 @@
#define _U 01
#define _L 02
#define _N 04
#define _S 010
#define _P 020
#define _C 040
#define _B 0100
#define _X 0200
extern char _ctype[];
#ifndef lint
#define isalpha(c) ((_ctype+1)[c]&(_U|_L))
#define isupper(c) ((_ctype+1)[c]&_U)
#define islower(c) ((_ctype+1)[c]&_L)
#define isdigit(c) ((_ctype+1)[c]&_N)
#define isxdigit(c) ((_ctype+1)[c]&_X)
#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_N))
#define isspace(c) ((_ctype+1)[c]&_S)
#define ispunct(c) ((_ctype+1)[c]&_P)
#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_N|_B))
#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_N))
#define iscntrl(c) ((_ctype+1)[c]&_C)
#define isascii(c) ((unsigned char)(c)<=0177)
#define _toupper(c) ((c)-'a'+'A')
#define _tolower(c) ((c)-'A'+'a')
#define toascii(c) ((c)&0177)
#endif

View File

@ -0,0 +1,33 @@
#define NTREC 20
#define MLEN 16
#define MSIZ 4096
#define TS_TAPE 1
#define TS_INODE 2
#define TS_BITS 3
#define TS_ADDR 4
#define TS_END 5
#define TS_CLRI 6
#define MAGIC (int)60011
#define CHECKSUM (int)84446
struct spcl
{
int c_type;
time_t c_date;
time_t c_ddate;
int c_volume;
daddr_t c_tapea;
ino_t c_inumber;
int c_magic;
int c_checksum;
struct dinode c_dinode;
int c_count;
char c_addr[BSIZE];
} spcl;
struct idates
{
char id_name[16];
char id_incno;
time_t id_ddate;
};

View File

@ -0,0 +1,19 @@
/* Flag values accessible to open(2) and fcntl(2) */
/* (The first three can only be set by open) */
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
#define O_NDELAY 04 /* Non-blocking I/O */
#define O_APPEND 010 /* append (writes guaranteed at the end) */
/* Flag values accessible only to open(2) */
#define O_CREAT 00400 /* open with file create (uses third open arg)*/
#define O_TRUNC 01000 /* open with truncation */
#define O_EXCL 02000 /* exclusive open */
/* fcntl(2) requests */
#define F_DUPFD 0 /* Duplicate fildes */
#define F_GETFD 1 /* Get fildes flags */
#define F_SETFD 2 /* Set fildes flags */
#define F_GETFL 3 /* Get file flags */
#define F_SETFL 4 /* Set file flags */

6
WEGA/contrib/lcc/h/grp.h Normal file
View File

@ -0,0 +1,6 @@
struct group { /* see getgrent(3) */
char *gr_name;
char *gr_passwd;
int gr_gid;
char **gr_mem;
};

18
WEGA/contrib/lcc/h/pwd.h Normal file
View File

@ -0,0 +1,18 @@
struct passwd {
char *pw_name;
char *pw_passwd;
int pw_uid;
int pw_gid;
char *pw_age;
char *pw_comment;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
struct comment {
char *c_dept;
char *c_name;
char *c_acct;
char *c_bin;
};

417
WEGA/contrib/lcc/h/regexp.h Normal file
View File

@ -0,0 +1,417 @@
#define CBRA 2
#define CCHR 4
#define CDOT 8
#define CCL 12
#define CDOL 20
#define CCEOF 22
#define CKET 24
#define CBACK 36
#define STAR 01
#define RNGE 03
#define NBRA 9
#define PLACE(c) ep[c >> 3] |= bittab[c & 07]
#define ISTHERE(c) (ep[c >> 3] & bittab[c & 07])
char *braslist[NBRA];
char *braelist[NBRA];
int ebra;
int sed, nbra;
char *loc1, *loc2, *locs;
int nodelim;
int circf;
int low;
int size;
char bittab[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
char *
compile(instring, ep, endbuf, seof)
register char *ep;
char *instring, *endbuf;
{
INIT /* Dependent declarations and initializations */
register c;
register eof = seof;
char *lastep = instring;
int cclcnt;
char bracket[NBRA], *bracketp;
int closed;
char neg;
int lc;
int i, cflg;
lastep = 0;
if((c = GETC()) == eof || c == '\n') {
if(c == '\n') {
UNGETC(c);
nodelim = 1;
}
if(*ep == 0 && !sed)
ERROR(41);
RETURN(ep);
}
bracketp = bracket;
circf = closed = nbra = ebra = 0;
if(c == '^')
circf++;
else
UNGETC(c);
while(1) {
if(ep >= endbuf)
ERROR(50);
c = GETC();
if(c != '*' && ((c != '\\') || (PEEKC() != '{')))
lastep = ep;
if(c == eof) {
*ep++ = CCEOF;
RETURN(ep);
}
switch(c) {
case '.':
*ep++ = CDOT;
continue;
case '\n':
if(!sed) {
UNGETC(c);
*ep++ = CCEOF;
nodelim = 1;
RETURN(ep);
}
else ERROR(36);
case '*':
if(lastep == 0 || *lastep == CBRA || *lastep == CKET)
goto defchar;
*lastep |= STAR;
continue;
case '$':
if(PEEKC() != eof && PEEKC() != '\n')
goto defchar;
*ep++ = CDOL;
continue;
case '[':
if(&ep[17] >= endbuf)
ERROR(50);
*ep++ = CCL;
lc = 0;
for(i = 0; i < 16; i++)
ep[i] = 0;
neg = 0;
if((c = GETC()) == '^') {
neg = 1;
c = GETC();
}
do {
if(c == '\0' || c == '\n')
ERROR(49);
if(c == '-' && lc != 0) {
if((c = GETC()) == ']') {
PLACE('-');
break;
}
while(lc < c) {
PLACE(lc);
lc++;
}
}
lc = c;
PLACE(c);
} while((c = GETC()) != ']');
if(neg) {
for(cclcnt = 0; cclcnt < 16; cclcnt++)
ep[cclcnt] ^= -1;
ep[0] &= 0376;
}
ep += 16;
continue;
case '\\':
switch(c = GETC()) {
case '(':
if(nbra >= NBRA)
ERROR(43);
*bracketp++ = nbra;
*ep++ = CBRA;
*ep++ = nbra++;
continue;
case ')':
if(bracketp <= bracket || ++ebra != nbra)
ERROR(42);
*ep++ = CKET;
*ep++ = *--bracketp;
closed++;
continue;
case '{':
if(lastep == (char *) 0)
goto defchar;
*lastep |= RNGE;
cflg = 0;
nlim:
c = GETC();
i = 0;
do {
if('0' <= c && c <= '9')
i = 10 * i + c - '0';
else
ERROR(16);
} while(((c = GETC()) != '\\') && (c != ','));
if(i > 255)
ERROR(11);
*ep++ = i;
if(c == ',') {
if(cflg++)
ERROR(44);
if((c = GETC()) == '\\')
*ep++ = 255;
else {
UNGETC(c);
goto nlim;
/* get 2'nd number */
}
}
if(GETC() != '}')
ERROR(45);
if(!cflg) /* one number */
*ep++ = i;
else if((ep[-1] & 0377) < (ep[-2] & 0377))
ERROR(46);
continue;
case '\n':
ERROR(36);
case 'n':
c = '\n';
goto defchar;
default:
if(c >= '1' && c <= '9') {
if((c -= '1') >= closed)
ERROR(25);
*ep++ = CBACK;
*ep++ = c;
continue;
}
}
/* Drop through to default to use \ to turn off special chars */
defchar:
default:
lastep = ep;
*ep++ = CCHR;
*ep++ = c;
}
}
}
step(p1, p2)
register char *p1, *p2;
{
register c;
if(circf) {
loc1 = p1;
return(advance(p1, p2));
}
/* fast check for first character */
if(*p2 == CCHR) {
c = p2[1];
do {
if(*p1 != c)
continue;
if(advance(p1, p2)) {
loc1 = p1;
return(1);
}
} while(*p1++);
return(0);
}
/* regular algorithm */
do {
if(advance(p1, p2)) {
loc1 = p1;
return(1);
}
} while(*p1++);
return(0);
}
advance(lp, ep)
register char *lp, *ep;
{
register char *curlp;
char c;
char *bbeg;
int ct;
while(1) {
switch(*ep++) {
case CCHR:
if(*ep++ == *lp++)
continue;
return(0);
case CDOT:
if(*lp++)
continue;
return(0);
case CDOL:
if(*lp == 0)
continue;
return(0);
case CCEOF:
loc2 = lp;
return(1);
case CCL:
c = *lp++ & 0177;
if(ISTHERE(c)) {
ep += 16;
continue;
}
return(0);
case CBRA:
braslist[*ep++] = lp;
continue;
case CKET:
braelist[*ep++] = lp;
continue;
case CCHR | RNGE:
c = *ep++;
getrnge(ep);
while(low--)
if(*lp++ != c)
return(0);
curlp = lp;
while(size--)
if(*lp++ != c)
break;
if(size < 0)
lp++;
ep += 2;
goto star;
case CDOT | RNGE:
getrnge(ep);
while(low--)
if(*lp++ == '\0')
return(0);
curlp = lp;
while(size--)
if(*lp++ == '\0')
break;
if(size < 0)
lp++;
ep += 2;
goto star;
case CCL | RNGE:
getrnge(ep + 16);
while(low--) {
c = *lp++ & 0177;
if(!ISTHERE(c))
return(0);
}
curlp = lp;
while(size--) {
c = *lp++ & 0177;
if(!ISTHERE(c))
break;
}
if(size < 0)
lp++;
ep += 18; /* 16 + 2 */
goto star;
case CBACK:
bbeg = braslist[*ep];
ct = braelist[*ep++] - bbeg;
if(ecmp(bbeg, lp, ct)) {
lp += ct;
continue;
}
return(0);
case CBACK | STAR:
bbeg = braslist[*ep];
ct = braelist[*ep++] - bbeg;
curlp = lp;
while(ecmp(bbeg, lp, ct))
lp += ct;
while(lp >= curlp) {
if(advance(lp, ep)) return(1);
lp -= ct;
}
return(0);
case CDOT | STAR:
curlp = lp;
while(*lp++);
goto star;
case CCHR | STAR:
curlp = lp;
while(*lp++ == *ep);
ep++;
goto star;
case CCL | STAR:
curlp = lp;
do {
c = *lp++ & 0177;
} while(ISTHERE(c));
ep += 16;
goto star;
star:
do {
if(--lp == locs)
break;
if(advance(lp, ep))
return(1);
} while(lp > curlp);
return(0);
}
}
}
getrnge(str)
register char *str;
{
low = *str++ & 0377;
size = (*str == 255)? 20000: (*str &0377) - low;
}
ecmp(a, b, count)
register char *a, *b;
register count;
{
while(count--)
if(*a++ != *b++)
return(0);
return(1);
}

View File

@ -0,0 +1,80 @@
/*
* Structure for stty and gtty system calls.
*/
struct sgttyb {
char sg_ispeed; /* input speed */
char sg_ospeed; /* output speed */
char sg_erase; /* erase character */
char sg_kill; /* kill character */
int sg_flags; /* mode flags */
};
/*
* Modes
*/
#define HUPCL 01
#define XTABS 02
#define LCASE 04
#define ECHO 010
#define CRMOD 020
#define RAW 040
#define ODDP 0100
#define EVENP 0200
#define ANYP 0300
#define NLDELAY 001400
#define TBDELAY 002000
#define CRDELAY 030000
#define VTDELAY 040000
#define BSDELAY 0100000
#define ALLDELAY 0177400
/*
* Delay algorithms
*/
#define CR0 0
#define CR1 010000
#define CR2 020000
#define CR3 030000
#define NL0 0
#define NL1 000400
#define NL2 001000
#define NL3 001400
#define TAB0 0
#define TAB1 002000
#define NOAL 004000
#define FF0 0
#define FF1 040000
#define BS0 0
#define BS1 0100000
/*
* Speeds
*/
#define B0 0
#define B50 1
#define B75 2
#define B110 3
#define B134 4
#define B150 5
#define B200 6
#define B300 7
#define B600 8
#define B1200 9
#define B1800 10
#define B2400 11
#define B4800 12
#define B9600 13
#define EXTA 14
#define EXTB 15
/*
* ioctl arguments
*/
#define FIOCLEX (('f'<<8)|1)
#define FIONCLEX (('f'<<8)|2)
#define TIOCHPCL (('t'<<8)|2)
#define TIOCGETP (('t'<<8)|8)
#define TIOCSETP (('t'<<8)|9)
#define TIOCEXCL (('t'<<8)|13)
#define TIOCNXCL (('t'<<8)|14)

View File

@ -0,0 +1,9 @@
/*
* Structure of a symbol table entry
*/
struct symbol {
char sy_name[8];
char sy_type;
int sy_value;
};

17
WEGA/contrib/lcc/h/time.h Normal file
View File

@ -0,0 +1,17 @@
struct tm { /* see ctime(3) */
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
extern struct tm *gmtime(), *localtime();
extern char *ctime(), *asctime();
extern void tzset();
extern long timezone;
extern int daylight;
extern char *tzname[];

View File

@ -0,0 +1,6 @@
struct ustat {
daddr_t f_tfree; /* total free */
ino_t f_tinode; /* total inodes free */
char f_fname[6]; /* filsys name */
char f_fpack[6]; /* filsys pack name */
};

12
WEGA/contrib/lcc/h/utmp.h Normal file
View File

@ -0,0 +1,12 @@
/* <sys/types.h> must be included. */
#define UTMP_FILE "/etc/utmp"
#define WTMP_FILE "/usr/adm/wtmp"
#define ut_name ut_user
struct utmp
{
char ut_line[8] ; /* device name (console, lnxx) */
char ut_user[8] ; /* User login name */
long ut_time ; /* time entry was made */
} ;