Merge from trunk.
This commit is contained in:
		
						commit
						01fdfef8c0
					
				
					 5 changed files with 84 additions and 27 deletions
				
			
		| 
						 | 
				
			
			@ -634,7 +634,7 @@ GROUP 3 \- INTEGER ARITHMETIC
 | 
			
		|||
  RMI \*w :	Remainder (*)
 | 
			
		||||
  NGI \*w :	Negate (two's complement) (*)
 | 
			
		||||
  SLI \*w :	Shift left (*)
 | 
			
		||||
  SRI \*w :	Shift right (*)
 | 
			
		||||
  SRI \*w :	Shift right
 | 
			
		||||
.DE
 | 
			
		||||
 | 
			
		||||
.DS
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -152,7 +152,7 @@ const struct system_information machine_info[2] =
 | 
			
		|||
		}}
 | 
			
		||||
#else
 | 
			
		||||
#ifdef FM2
 | 
			
		||||
		/* pc Flags */
 | 
			
		||||
		/* modula-2 Flags */
 | 
			
		||||
		{1, {
 | 
			
		||||
		   "-Vw2.2i2.2l4.2p2.2f8.2S2.2"
 | 
			
		||||
		}}
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +207,7 @@ const struct system_information machine_info[2] =
 | 
			
		|||
		}}
 | 
			
		||||
#else
 | 
			
		||||
#ifdef FM2
 | 
			
		||||
		/* pc Flags */
 | 
			
		||||
		/* modula-2 Flags */
 | 
			
		||||
		{1, {
 | 
			
		||||
		   "-Vw2.2i2.2l4.2p4.2f8.2S2.2"
 | 
			
		||||
		}}
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +221,6 @@ const struct system_information machine_info[2] =
 | 
			
		|||
struct arglist CPP_FLAGS = {0,{NULL}};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct arglist LD_HEAD =
 | 
			
		||||
{ 2,
 | 
			
		||||
{ "$H/lib/$S/head_em",
 | 
			
		||||
| 
						 | 
				
			
			@ -298,12 +297,12 @@ static int cv_flag = 0;
 | 
			
		|||
char *mkstr(char *, ...);
 | 
			
		||||
static char *alloc(unsigned int);
 | 
			
		||||
static char *extension(char *);
 | 
			
		||||
static char *expand_string(char *);
 | 
			
		||||
static char *expand_string(char *s, struct system_information *);
 | 
			
		||||
static void error(char *, char *, char *);
 | 
			
		||||
static void warning(char *, char *, char *);
 | 
			
		||||
static void panic(char *);
 | 
			
		||||
static void append(register struct arglist *, char *);
 | 
			
		||||
static void expand(register struct arglist *);
 | 
			
		||||
static void expand(register struct arglist *, struct system_information *);
 | 
			
		||||
static void concat(struct arglist *, struct arglist *);
 | 
			
		||||
static int runvec(struct arglist *, char *);
 | 
			
		||||
static int needsprep(char *);
 | 
			
		||||
| 
						 | 
				
			
			@ -345,6 +344,12 @@ void trapcc(int sig)
 | 
			
		|||
#define comp_name()	"$H/lib/ack/em_pc"
 | 
			
		||||
#endif /* FPC */
 | 
			
		||||
 | 
			
		||||
/** Default library directories to search in. */
 | 
			
		||||
 | 
			
		||||
#define LIB_DIR_1		"$H/share/ack/$S"
 | 
			
		||||
#define LIB_DIR_2		"$H/lib/ack/plat/$S"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef FCC
 | 
			
		||||
int lang_opt(char *str)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -524,6 +529,8 @@ char* search_library_path(struct stringlist *dirs, char* lib)
 | 
			
		|||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	/* Contains the directories being searched for libraries */
 | 
			
		||||
| 
						 | 
				
			
			@ -574,11 +581,16 @@ int main(int argc, char *argv[])
 | 
			
		|||
	sys_basename(*argv++, ProgCall);
 | 
			
		||||
 | 
			
		||||
	/* get compiler to use. */
 | 
			
		||||
	COMP = expand_string(comp_name());
 | 
			
		||||
	COMP = expand_string(comp_name(),sys_info);
 | 
			
		||||
	/* get c pre-processor to use */
 | 
			
		||||
	CPP = expand_string(CPP_NAME);
 | 
			
		||||
	CPP = expand_string(CPP_NAME,sys_info);
 | 
			
		||||
	/** get linker to use */
 | 
			
		||||
	LD = expand_string(sys_info->linker);
 | 
			
		||||
	LD = expand_string(sys_info->linker,sys_info);
 | 
			
		||||
 | 
			
		||||
	/* Add system directory path. */
 | 
			
		||||
	stringlist_add(&library_dirs,expand_string(LIB_DIR_1,sys_info));
 | 
			
		||||
	stringlist_add(&library_dirs,expand_string(LIB_DIR_2,sys_info));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (signal(SIGINT, SIG_IGN) != SIG_IGN)
 | 
			
		||||
| 
						 | 
				
			
			@ -682,6 +694,9 @@ int main(int argc, char *argv[])
 | 
			
		|||
	{
 | 
			
		||||
		append(&COMP_FLAGS, sys_info->compiler_flags.al_argv[count]);
 | 
			
		||||
	}
 | 
			
		||||
#ifdef FPC
 | 
			
		||||
	append(&COMP_FLAGS, "-d");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/* Now for each srcfile, if it starts with -l then replace it with the correct real
 | 
			
		||||
	 * path immediately.
 | 
			
		||||
| 
						 | 
				
			
			@ -734,12 +749,12 @@ int main(int argc, char *argv[])
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
#ifdef FM2
 | 
			
		||||
	INCLUDE = expand_string("-I$H/lib/m2");
 | 
			
		||||
	INCLUDE = expand_string("-I$H/lib/m2",sys_info);
 | 
			
		||||
#endif /* FM2 */
 | 
			
		||||
#ifdef FCC
 | 
			
		||||
/*	INCLUDE = expand_string(
 | 
			
		||||
			ansi_c ? "-I$H/include/tail_ac" : "-I$H/include/_tail_cc"); */
 | 
			
		||||
	INCLUDE = expand_string("-I$H/share/ack/include");
 | 
			
		||||
	INCLUDE = expand_string("-I$H/share/ack/include",sys_info);
 | 
			
		||||
/*	append(&COMP_FLAGS, "-L");*/
 | 
			
		||||
#endif /* FCC */
 | 
			
		||||
	count = SRCFILES.al_argc;
 | 
			
		||||
| 
						 | 
				
			
			@ -912,7 +927,7 @@ int main(int argc, char *argv[])
 | 
			
		|||
		if (cv_flag)
 | 
			
		||||
		{
 | 
			
		||||
			init(call);
 | 
			
		||||
			append(call, expand_string(sys_info->cv));
 | 
			
		||||
			append(call, expand_string(sys_info->cv, sys_info));
 | 
			
		||||
			append(call, tmp_file);
 | 
			
		||||
			append(call, o_FILE);
 | 
			
		||||
			if (runvec(call, (char *) 0)==EXIT_FAILURE)
 | 
			
		||||
| 
						 | 
				
			
			@ -959,7 +974,7 @@ static char * alloc(unsigned int u)
 | 
			
		|||
	return p;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char * expand_string(char *s)
 | 
			
		||||
static char * expand_string(char *s, struct system_information *sysinfo)
 | 
			
		||||
{
 | 
			
		||||
	char buf[1024];
 | 
			
		||||
	register char *p = s;
 | 
			
		||||
| 
						 | 
				
			
			@ -986,10 +1001,10 @@ static char * expand_string(char *s)
 | 
			
		|||
				strcpy(q, ackhome);
 | 
			
		||||
				break;
 | 
			
		||||
			case 'M':
 | 
			
		||||
				strcpy(q, MACHNAME);
 | 
			
		||||
				strcpy(q, sysinfo->arch);
 | 
			
		||||
				break;
 | 
			
		||||
			case 'S':
 | 
			
		||||
				strcpy(q, SYSNAME);
 | 
			
		||||
				strcpy(q, sysinfo->platform);
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				panic("internal error");
 | 
			
		||||
| 
						 | 
				
			
			@ -1018,14 +1033,14 @@ static void append(register struct arglist *al, char *arg)
 | 
			
		|||
	al->al_argv[(al->al_argc)++] = arg;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void expand(register struct arglist *al)
 | 
			
		||||
static void expand(register struct arglist *al, struct system_information *sysinfo)
 | 
			
		||||
{
 | 
			
		||||
	register int i = al->al_argc;
 | 
			
		||||
	register char **p = &(al->al_argv[0]);
 | 
			
		||||
 | 
			
		||||
	while (i-- > 0)
 | 
			
		||||
	{
 | 
			
		||||
		*p = expand_string(*p);
 | 
			
		||||
		*p = expand_string(*p,sysinfo);
 | 
			
		||||
		p++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,12 +58,13 @@ PRIVATE void arr(int type, /* operation TYPE */
 | 
			
		|||
{
 | 
			
		||||
	register ptr desc = dppop();	/* array DESCriptor */
 | 
			
		||||
	register size obj_size;		/* OBJect SIZE */
 | 
			
		||||
	register long diff =		/* between index and lower bound */
 | 
			
		||||
		spop(elm_size) - mem_lds(desc, elm_size);
 | 
			
		||||
	long index = spop(elm_size);
 | 
			
		||||
	long diff =		/* between index and lower bound */
 | 
			
		||||
		index - mem_lds(desc, elm_size);
 | 
			
		||||
	register ptr arr_addr = dppop();/* ARRay ADDRess */
 | 
			
		||||
 | 
			
		||||
	if (must_test && !(IgnMask&BIT(EARRAY))) {
 | 
			
		||||
		if (diff < 0 || diff > mem_lds(desc + elm_size, elm_size)) {
 | 
			
		||||
		if (diff < 0 || index > mem_lds(desc + elm_size, elm_size)) {
 | 
			
		||||
			trap(EARRAY);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@
 | 
			
		|||
#include	"text.h"
 | 
			
		||||
#include	"fra.h"
 | 
			
		||||
 | 
			
		||||
PRIVATE long adi(long, long, size), sbi(long, long, size), dvi(long, long);
 | 
			
		||||
PRIVATE long adi(long, long, size), sbi(long, long, size), dvi(long, long, size);
 | 
			
		||||
PRIVATE long mli(long, long, size), rmi(long, long), ngi(long, size);
 | 
			
		||||
PRIVATE long sli(long, long, size), sri(long, long, size);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ void DoDVI(register size l)
 | 
			
		|||
 | 
			
		||||
	LOG(("@I6 DoDVI(%ld)", l));
 | 
			
		||||
	spoilFRA();
 | 
			
		||||
	npush(dvi(spop(l), t), l);
 | 
			
		||||
	npush(dvi(spop(l), t, l), l);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** RMI w: Remainder (*) */
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +162,7 @@ PRIVATE long mli(long w1, long w2, size nbytes)
 | 
			
		|||
	return (w1 * w2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PRIVATE long dvi(long w1, long w2)
 | 
			
		||||
PRIVATE long dvi(long w1, long w2, size nbytes)
 | 
			
		||||
{
 | 
			
		||||
	if (w2 == 0) {
 | 
			
		||||
		if (!(IgnMask&BIT(EIDIVZ))) {
 | 
			
		||||
| 
						 | 
				
			
			@ -170,6 +170,17 @@ PRIVATE long dvi(long w1, long w2)
 | 
			
		|||
		}
 | 
			
		||||
		else	return (0L);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Check for division overflow. */
 | 
			
		||||
	if ((w1 == i_mins(nbytes)) && (w2 == -1))
 | 
			
		||||
	{
 | 
			
		||||
		if (must_test && !(IgnMask&BIT(EIOVFL)))
 | 
			
		||||
		{
 | 
			
		||||
			trap(EIOVFL);
 | 
			
		||||
		} else return i_mins(nbytes);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return (w1 / w2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -212,11 +223,20 @@ PRIVATE long sli(long w1, long w2, size nbytes)
 | 
			
		|||
	
 | 
			
		||||
		if (!(IgnMask&BIT(EIOVFL))) {
 | 
			
		||||
			/* check overflow */
 | 
			
		||||
			if (	(w1 >= 0 && (w1 >> (nbytes*8 - w2)) != 0)
 | 
			
		||||
			||	(w1 < 0 && (w1 >> (nbytes*8 - w2)) != -1)
 | 
			
		||||
			) {
 | 
			
		||||
 | 
			
		||||
			/* If the value is positive, then check, this is taken
 | 
			
		||||
			 * from rule INT32-C of SEI website.
 | 
			
		||||
			 */
 | 
			
		||||
			if ((w1 >= 0) && (w1 > (i_maxs(nbytes) >> w2)))
 | 
			
		||||
			{
 | 
			
		||||
				trap(EIOVFL);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if ((w1 < 0) && (w1 < (i_mins(nbytes) >> w2)))
 | 
			
		||||
			{
 | 
			
		||||
				trap(EIOVFL);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}	
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,15 +45,36 @@ extern void disassemble(void);
 | 
			
		|||
extern void tally(void);
 | 
			
		||||
extern void out_tally(void);
 | 
			
		||||
 | 
			
		||||
/** Check dynamically that the interpreter can run on the target machine. */
 | 
			
		||||
static void check_requirements(char *name)
 | 
			
		||||
{
 | 
			
		||||
	
 | 
			
		||||
	/* Verify that shift right supported signed shifts. According to ISO C90,
 | 
			
		||||
	 * this is not mandatory, we should not support it here!
 | 
			
		||||
	 */
 | 
			
		||||
	int shrv = -4;
 | 
			
		||||
	if ((shrv >> 1) != -2)
 | 
			
		||||
	{
 | 
			
		||||
		fprintf(stderr,
 | 
			
		||||
			"%s compiled with compiler that does not support signed right shifts. Aborted.",
 | 
			
		||||
			name);
 | 
			
		||||
		exit(1);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	register int i;
 | 
			
		||||
	register int nosetjmp = 1;
 | 
			
		||||
	int must_disassemble = 0;
 | 
			
		||||
	int must_tally = 0;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	prog_name = argv[0];
 | 
			
		||||
 | 
			
		||||
	check_requirements(prog_name);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/* Initialize the EM machine */
 | 
			
		||||
	PreIgnMask = 0;
 | 
			
		||||
	FRALimit = FRALIMIT;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue