Better ANSI C compatibility and portability - part 1:

+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h
This commit is contained in:
carl 2019-02-19 00:32:48 +08:00
parent 90d4797ff7
commit 0ac16f6116
54 changed files with 274 additions and 332 deletions

View file

@ -0,0 +1,99 @@
cmake_minimum_required (VERSION 2.9)
project(em_code)
set(SRC
bhcst.c
bhdlb.c
bhdnam.c
bhfcon.c
bhicon.c
bhilb.c
bhpnam.c
bhucon.c
crcst.c
crdlb.c
crdnam.c
crxcon.c
crilb.c
crpnam.c
crscon.c
cst.c
dfdlb.c
dfdnam.c
dfilb.c
dlb.c
dnam.c
end.c
endarg.c
exc.c
fcon.c
getid.c
icon.c
ilb.c
insert.c
internerr.c
msend.c
op.c
opcst.c
opdlb.c
opdnam.c
opilb.c
opnarg.c
oppnam.c
pnam.c
pro.c
pronarg.c
msstart.c
psdlb.c
psdnam.c
pspnam.c
scon.c
ucon.c
C_out.c
failed.c
em.c
em_codeEK.h
em_code.h
em_codeCE.h
em_codeO.h
em_private.h
)
set(INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
add_library(eme ${SRC})
target_include_directories(eme PUBLIC ${INCLUDE_DIRS})
target_compile_definitions(eme PRIVATE READABLE_EM)
target_link_libraries(eme em_data alloc print system)
add_library(emk ${SRC})
target_include_directories(emk PUBLIC ${INCLUDE_DIRS})
target_link_libraries(emk em_data alloc print system)
set_target_properties(eme PROPERTIES PUBLIC_HEADER "em_codeEK.h")
set_target_properties(emk PROPERTIES PUBLIC_HEADER "em_codeEK.h")
add_custom_command(
OUTPUT em_codeEK.h file1.tmp
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/makeem.sed
${CMAKE_CURRENT_BINARY_DIR}/makeem.sed
COMMAND sed -f makeem.sed ${CMAKE_CURRENT_SOURCE_DIR}/../../../h/em_table>file1.tmp
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/em.nogen file1.tmp>em_codeEK.h
COMMENT "Regenerate em_codeEK.h from em_table"
)
install(TARGETS eme emk
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/em_code.3X DESTINATION man OPTIONAL)

View file

@ -9,25 +9,22 @@
/* $Id$ */ /* $Id$ */
static arg(); static void arg(struct e_instr *p, int comma);
static pseudo(); static void pseudo(struct e_instr *p);
extern char em_flag[]; extern char em_flag[];
char *C_error; char *C_error;
#define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR) #define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR)
struct e_instr * struct e_instr *C_alloc(void)
C_alloc()
{ {
static struct e_instr b; static struct e_instr b;
return &b; return &b;
} }
int int C_out(register struct e_instr *p)
C_out(p)
register struct e_instr *p;
{ {
/* Generate EM-code from the e_instr structure "p" /* Generate EM-code from the e_instr structure "p"
*/ */
@ -82,9 +79,7 @@ C_out(p)
return 1; return 1;
} }
static static void arg(register struct e_instr *p, int comma)
arg(p, comma)
register struct e_instr *p;
{ {
/* Output the argument of "p". /* Output the argument of "p".
*/ */
@ -145,9 +140,7 @@ arg(p, comma)
} }
} }
static static void pseudo(register struct e_instr *p)
pseudo(p)
register struct e_instr *p;
{ {
PS(p->em_opcode); PS(p->em_opcode);

View file

@ -2,11 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhcst(int op, arith n, arith w, int i)
CC_bhcst(op, n, w, i)
arith n;
arith w;
int i;
{ {
/* BSS or HOL with size n, initial value a cst w, and flag i /* BSS or HOL with size n, initial value a cst w, and flag i
*/ */

View file

@ -2,12 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhdlb(int op, arith n, label s, arith off, int i)
CC_bhdlb(op, n, s, off, i)
arith n;
label s;
arith off;
int i;
{ {
/* BSS or HOL with size n, initial value a dlb(s, off), /* BSS or HOL with size n, initial value a dlb(s, off),
and flag i and flag i

View file

@ -2,12 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhdnam(int op, arith n, char *s, arith off, int i)
CC_bhdnam(op, n, s, off, i)
arith n;
char *s;
arith off;
int i;
{ {
/* BSS or HOL with size n, initial value a dnam(s, off), /* BSS or HOL with size n, initial value a dnam(s, off),
and flag i and flag i

View file

@ -2,12 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhfcon(int op, arith n, char *s, arith sz, int i)
CC_bhfcon(op, n, s, sz, i)
arith n;
char *s;
arith sz;
int i;
{ {
/* BSS or HOL with size n, initial value an FCON (s, sz), /* BSS or HOL with size n, initial value an FCON (s, sz),
and flag i and flag i

View file

@ -2,12 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhicon(int op, arith n, char *s, arith sz, int i)
CC_bhicon(op, n, s, sz, i)
arith n;
char *s;
arith sz;
int i;
{ {
/* BSS or HOL with size n, initial value an ICON (s, sz), /* BSS or HOL with size n, initial value an ICON (s, sz),
and flag i and flag i

View file

@ -2,11 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhilb(int op, arith n, label l, int i)
CC_bhilb(op, n, l, i)
arith n;
label l;
int i;
{ {
/* BSS or HOL with size n, initial value a ILB(l), /* BSS or HOL with size n, initial value a ILB(l),
and flag i and flag i

View file

@ -2,11 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhpnam(int op, arith n, char *p, int i)
CC_bhpnam(op, n, p, i)
arith n;
char *p;
int i;
{ {
/* BSS or HOL with size n, initial value a PNAM(p), /* BSS or HOL with size n, initial value a PNAM(p),
and flag i and flag i

View file

@ -2,12 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_bhucon(int op, arith n, char *s, arith sz, int i)
CC_bhucon(op, n, s, sz, i)
arith n;
char *s;
arith sz;
int i;
{ {
/* BSS or HOL with size n, initial value an UCON (s, sz), /* BSS or HOL with size n, initial value an UCON (s, sz),
and flag i and flag i

View file

@ -89,6 +89,7 @@ local function build_variant(code, cflags)
"modules+headers", "modules+headers",
"modules/src/alloc+lib", "modules/src/alloc+lib",
"modules/src/em_data+lib", "modules/src/em_data+lib",
"modules/src/print+lib",
"modules/src/system+lib", "modules/src/system+lib",
}, },
vars = { vars = {

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crcst(int op, arith v)
CC_crcst(op, v)
arith v;
{ {
/* CON or ROM with argument CST(v) /* CON or ROM with argument CST(v)
*/ */

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crdlb(int op, label v, arith off)
CC_crdlb(op, v, off)
label v;
arith off;
{ {
/* CON or ROM with argument DLB(v, off) /* CON or ROM with argument DLB(v, off)
*/ */

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crdnam(int op, char* s, arith off)
CC_crdnam(op, s, off)
char *s;
arith off;
{ {
/* CON or ROM with argument DNAM(s, off) /* CON or ROM with argument DNAM(s, off)
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crilb(int op, label l)
CC_crilb(op, l)
label l;
{ {
/* CON or ROM with argument ILB(l) /* CON or ROM with argument ILB(l)
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crpnam(int op, char* p)
CC_crpnam(op, p)
char *p;
{ {
/* CON or ROM with argument PNAM(p) /* CON or ROM with argument PNAM(p)
*/ */

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crscon(int op, char* v, arith s)
CC_crscon(op, v, s)
char *v;
arith s;
{ {
/* CON or ROM with argument SCON(v,z) /* CON or ROM with argument SCON(v,z)
*/ */

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_crxcon(int op, int spec, char* v, arith s)
CC_crxcon(op, spec, v, s)
char *v;
arith s;
{ {
/* CON or ROM with argument ICON(v,z) /* CON or ROM with argument ICON(v,z)
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_cst(arith l)
CC_cst(l)
arith l;
{ {
COMMA(); COMMA();
CST(l); CST(l);

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_dfdlb(label l)
CC_dfdlb(l)
label l;
{ {
/* Define numeric data label /* Define numeric data label
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_dfdnam(char* s)
CC_dfdnam(s)
char *s;
{ {
/* Define data label /* Define data label
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_dfilb(label l)
CC_dfilb(l)
label l;
{ {
/* Define instruction label /* Define instruction label
*/ */

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_dlb(label l, arith val)
CC_dlb(l, val)
label l;
arith val;
{ {
COMMA(); COMMA();
DOFF(l, val); DOFF(l, val);

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_dnam(char* str, arith val)
CC_dnam(str, val)
char *str;
arith val;
{ {
COMMA(); COMMA();
NOFF(str, val); NOFF(str, val);

View file

@ -12,7 +12,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "system.h"
#include "alloc.h" #include "alloc.h"
#include "print.h"
#include "em_arith.h" #include "em_arith.h"
#include "insert.h" #include "insert.h"
#include "em_private.h" #include "em_private.h"
@ -49,8 +51,9 @@ char *C_current_out = obuf;
char *C_opp = obuf; char *C_opp = obuf;
#endif #endif
void void C_flush(void)
C_flush() { {
int count;
#ifdef INCORE #ifdef INCORE
static unsigned int bufsiz; static unsigned int bufsiz;
@ -69,6 +72,7 @@ C_flush() {
return; return;
} }
#endif #endif
count = (int)(C_opp - obuf);
if (C_opp != obuf && sys_write(C_ofp, obuf, (int)(C_opp - obuf)) == 0) { if (C_opp != obuf && sys_write(C_ofp, obuf, (int)(C_opp - obuf)) == 0) {
C_ofp = 0; C_ofp = 0;
C_failed(); C_failed();
@ -82,9 +86,7 @@ C_flush() {
#define Xputbyte(c) put(c) #define Xputbyte(c) put(c)
#endif #endif
void void C_putbyte(int c)
C_putbyte(c)
int c;
{ {
Xputbyte(c); Xputbyte(c);
} }
@ -94,15 +96,11 @@ C_putbyte(c)
#endif #endif
/*ARGSUSED*/ /*ARGSUSED*/
void void C_init(arith w, arith p)
C_init(w, p)
arith w, p;
{ {
} }
int int C_open(char* nm)
C_open(nm)
char *nm;
{ {
/* Open file "nm" for output /* Open file "nm" for output
*/ */
@ -110,13 +108,15 @@ C_open(nm)
if (nm == 0) if (nm == 0)
C_ofp = STDOUT; /* standard output */ C_ofp = STDOUT; /* standard output */
else else
{
if (sys_open(nm, OP_WRITE, &C_ofp) == 0) if (sys_open(nm, OP_WRITE, &C_ofp) == 0)
return 0; return 0;
}
return 1; return 1;
} }
void void C_close(void)
C_close()
{ {
/* Finish the code-generation. /* Finish the code-generation.
*/ */
@ -150,8 +150,7 @@ C_close()
C_ofp = 0; C_ofp = 0;
} }
int int C_busy(void)
C_busy()
{ {
return C_ofp != 0; /* true if code is being generated */ return C_ofp != 0; /* true if code is being generated */
} }
@ -165,32 +164,27 @@ C_busy()
names. names.
*/ */
void void C_magic(void)
C_magic()
{ {
} }
/*** the readable code generating routines ***/ /*** the readable code generating routines ***/
static static int wrs(register char *s)
wrs(s)
register char *s;
{ {
while (*s) { while (*s)
{
C_putbyte(*s++); C_putbyte(*s++);
} }
return 0;
} }
void void C_pt_dnam(char* s)
C_pt_dnam(s)
char *s;
{ {
wrs(s); wrs(s);
} }
void void C_pt_ilb(label l)
C_pt_ilb(l)
label l;
{ {
char buf[16]; char buf[16];
@ -201,17 +195,14 @@ C_pt_ilb(l)
extern char em_mnem[][4]; extern char em_mnem[][4];
extern char em_pseu[][4]; extern char em_pseu[][4];
void void C_pt_op(int x)
C_pt_op(x)
{ {
C_putbyte(' '); C_putbyte(' ');
wrs(em_mnem[x - sp_fmnem]); wrs(em_mnem[x - sp_fmnem]);
C_putbyte(' '); C_putbyte(' ');
} }
void void C_pt_cst(arith l)
C_pt_cst(l)
arith l;
{ {
char buf[16]; char buf[16];
@ -219,10 +210,7 @@ C_pt_cst(l)
wrs(buf); wrs(buf);
} }
void void C_pt_scon(char *x, arith y)
C_pt_scon(x, y)
char *x;
arith y;
{ {
char xbuf[1024]; char xbuf[1024];
register char *p; register char *p;
@ -239,17 +227,14 @@ C_pt_scon(x, y)
C_putbyte('\''); C_putbyte('\'');
} }
void void C_pt_ps(int x)
C_pt_ps(x)
{ {
C_putbyte(' '); C_putbyte(' ');
wrs(em_pseu[x - sp_fpseu]); wrs(em_pseu[x - sp_fpseu]);
C_putbyte(' '); C_putbyte(' ');
} }
void void C_pt_dlb(label l)
C_pt_dlb(l)
label l;
{ {
char buf[16]; char buf[16];
@ -257,10 +242,7 @@ C_pt_dlb(l)
wrs(buf); wrs(buf);
} }
void void C_pt_doff(label l, arith v)
C_pt_doff(l, v)
label l;
arith v;
{ {
char buf[16]; char buf[16];
@ -271,10 +253,7 @@ C_pt_doff(l, v)
} }
} }
void void C_pt_noff(char *s, arith v)
C_pt_noff(s, v)
char *s;
arith v;
{ {
char buf[16]; char buf[16];
@ -285,17 +264,13 @@ C_pt_noff(s, v)
} }
} }
void void C_pt_pnam(char *s)
C_pt_pnam(s)
char *s;
{ {
C_putbyte('$'); C_putbyte('$');
wrs(s); wrs(s);
} }
void void C_pt_dfilb(label l)
C_pt_dfilb(l)
label l;
{ {
char buf[16]; char buf[16];
@ -303,11 +278,7 @@ C_pt_dfilb(l)
wrs(buf); wrs(buf);
} }
void void C_pt_wcon(int sp, char *v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
int sp;
char *v;
arith sz;
{ {
int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F'; int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F';
@ -316,18 +287,18 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
C_pt_cst(sz); C_pt_cst(sz);
} }
void void C_pt_nl(void)
C_pt_nl() { {
C_putbyte('\n'); C_putbyte('\n');
} }
void void C_pt_comma(void)
C_pt_comma() { {
C_putbyte(','); C_putbyte(',');
} }
void void C_pt_ccend(void)
C_pt_ccend() { {
C_putbyte('?'); C_putbyte('?');
} }
@ -345,8 +316,7 @@ C_pt_ccend() {
names. names.
*/ */
void void C_magic(void)
C_magic()
{ {
put16(sp_magic); put16(sp_magic);
} }
@ -355,9 +325,7 @@ C_magic()
#define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF) #define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF)
#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */ #define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */
void void C_pt_ilb(register label l)
C_pt_ilb(l)
register label l;
{ {
if (fit8u(l)) { if (fit8u(l)) {
put8(sp_ilb1); put8(sp_ilb1);
@ -369,9 +337,7 @@ C_pt_ilb(l)
} }
} }
void void C_pt_dlb(register label l)
C_pt_dlb(l)
register label l;
{ {
if (fit8u(l)) { if (fit8u(l)) {
put8(sp_dlb1); put8(sp_dlb1);
@ -383,9 +349,7 @@ C_pt_dlb(l)
} }
} }
void void C_pt_cst(register arith l)
C_pt_cst(l)
register arith l;
{ {
if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) { if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) {
/* we can convert 'l' to an int because its value /* we can convert 'l' to an int because its value
@ -404,10 +368,7 @@ C_pt_cst(l)
} }
} }
void void C_pt_doff(label l, arith v)
C_pt_doff(l, v)
label l;
arith v;
{ {
if (v == 0) { if (v == 0) {
C_pt_dlb(l); C_pt_dlb(l);
@ -419,9 +380,7 @@ C_pt_doff(l, v)
} }
} }
void void C_pt_str(register char *s)
C_pt_str(s)
register char *s;
{ {
register int len; register int len;
@ -431,18 +390,13 @@ C_pt_str(s)
} }
} }
void void C_pt_dnam(char* s)
C_pt_dnam(s)
char *s;
{ {
put8(sp_dnam); put8(sp_dnam);
C_pt_str(s); C_pt_str(s);
} }
void void C_pt_noff(char* s, arith v)
C_pt_noff(s, v)
char *s;
arith v;
{ {
if (v == 0) { if (v == 0) {
C_pt_dnam(s); C_pt_dnam(s);
@ -454,19 +408,13 @@ C_pt_noff(s, v)
} }
} }
void void C_pt_pnam(char* s)
C_pt_pnam(s)
char *s;
{ {
put8(sp_pnam); put8(sp_pnam);
C_pt_str(s); C_pt_str(s);
} }
void void C_pt_wcon(int sp, char* v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
int sp;
char *v;
arith sz;
{ {
/* how 'bout signextension int --> long ??? */ /* how 'bout signextension int --> long ??? */
put8(sp); put8(sp);
@ -474,10 +422,7 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
C_pt_str(v); C_pt_str(v);
} }
void void C_pt_scon(register char *b, register arith n)
C_pt_scon(b, n)
register char *b;
register arith n;
{ {
put8(sp_scon); put8(sp_scon);
C_pt_cst(n); C_pt_cst(n);

View file

@ -5,6 +5,7 @@
*/ */
#include "em_mesX.h" #include "em_mesX.h"
#include "em_arith.h"
#include "ansi.h" #include "ansi.h"
_PROTOTYPE(void C_ms_com, (char *)); _PROTOTYPE(void C_ms_com, (char *));
@ -24,6 +25,8 @@ _PROTOTYPE(void C_ms_stb_ilb, (char *, int, int, label));
_PROTOTYPE(void C_ms_stb_pnam, (char *, int, int, char *)); _PROTOTYPE(void C_ms_stb_pnam, (char *, int, int, char *));
_PROTOTYPE(void C_ms_std, (char *, int, int)); _PROTOTYPE(void C_ms_std, (char *, int, int));
#ifdef PEEPHOLE #ifdef PEEPHOLE
#include "em_codeO.h" #include "em_codeO.h"
#include "emO_code.h" #include "emO_code.h"

View file

@ -5,16 +5,16 @@
*/ */
/* private inclusion file */ /* private inclusion file */
#include <em_arith.h> #include "em_arith.h"
#include <em_label.h> #include "em_label.h"
/* include the EM description files */ /* include the EM description files */
#include <em_spec.h> #include "em_spec.h"
#include <em_pseu.h> #include "em_pseu.h"
#include <em_mnem.h> #include "em_mnem.h"
#include <em_reg.h> #include "em_reg.h"
#include <ansi.h> #include "ansi.h"
#include "em_codeEK.h" #include "em_codeEK.h"
@ -79,6 +79,10 @@ _PROTOTYPE(void C_pt_noff, (char *, arith));
_PROTOTYPE(void C_pt_pnam, (char *)); _PROTOTYPE(void C_pt_pnam, (char *));
_PROTOTYPE(void C_pt_dfilb, (label)); _PROTOTYPE(void C_pt_dfilb, (label));
_PROTOTYPE(void C_pt_wcon, (int, char *, arith)); _PROTOTYPE(void C_pt_wcon, (int, char *, arith));
_PROTOTYPE(void C_failed, (void));
_PROTOTYPE(void C_flush, (void));
_PROTOTYPE(void C_internal_error, (void));
_PROTOTYPE(void C_putbyte, (int));
#ifdef READABLE_EM #ifdef READABLE_EM
_PROTOTYPE(void C_pt_ps, (int)); _PROTOTYPE(void C_pt_ps, (int));
_PROTOTYPE(void C_pt_op, (int)); _PROTOTYPE(void C_pt_op, (int));

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_end(arith l)
CC_end(l)
arith l;
{ {
/* END pseudo of procedure with l locals /* END pseudo of procedure with l locals
*/ */

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_endnarg()
CC_endnarg()
{ {
/* END pseudo of procedure with unknown # of locals /* END pseudo of procedure with unknown # of locals
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_exc(arith c1,arith c2)
CC_exc(c1,c2)
arith c1,c2;
{ {
PS(ps_exc); PS(ps_exc);
CST(c1); CST(c1);

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_fcon(char* val, arith siz)
CC_fcon(val, siz)
char *val;
arith siz;
{ {
COMMA(); COMMA();
WCON(sp_fcon, val, siz); WCON(sp_fcon, val, siz);

View file

@ -3,8 +3,7 @@
/* Get a unique id for C_insertpart, etc. /* Get a unique id for C_insertpart, etc.
*/ */
int int C_getid(void)
C_getid()
{ {
static int id = 0; static int id = 0;

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_icon(char* val, arith siz)
CC_icon(val, siz)
char *val;
arith siz;
{ {
COMMA(); COMMA();
WCON(sp_icon, val, siz); WCON(sp_icon, val, siz);

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_ilb(label l)
CC_ilb(l)
label l;
{ {
COMMA(); COMMA();
ILB(l); ILB(l);

View file

@ -11,11 +11,18 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <em_path.h> #include <stdio.h>
#include <alloc.h> #include <assert.h>
#include "em_private.h"
#include "system.h"
/*#include "em_path.h"*/
#include "alloc.h"
#include "insert.h" #include "insert.h"
char *C_tmpdir = TMP_DIR; /* To make this portable, the initial value here is NULL
* and system is used to retrieve the correct directory
*/
char *C_tmpdir = NULL;
static Part *C_stable[TABSIZ]; static Part *C_stable[TABSIZ];
static char *C_old_top; static char *C_old_top;
@ -58,12 +65,10 @@ getbyte(b)
} }
#endif #endif
static C_out_parts(); static void C_out_parts(register PartOfPart *pp);
static Part *C_findpart(); static Part *C_findpart(int part);
static static int outpart(int id)
outpart(id)
int id;
{ {
/* Output part "id", if present. /* Output part "id", if present.
*/ */
@ -73,11 +78,10 @@ outpart(id)
C_out_parts(p->p_parts); C_out_parts(p->p_parts);
p->p_parts = 0; p->p_parts = 0;
} }
return 0;
} }
static static void C_out_parts(register PartOfPart *pp)
C_out_parts(pp)
register PartOfPart *pp;
{ {
/* Output the list of chunks started by "pp". /* Output the list of chunks started by "pp".
The list is build in reverse order, so this routine is The list is build in reverse order, so this routine is
@ -119,9 +123,7 @@ C_out_parts(pp)
} }
} }
static Part * static Part *C_findpart(int part)
C_findpart(part)
int part;
{ {
/* Look for part "part" in the table. /* Look for part "part" in the table.
Return 0 if not present, Return 0 if not present,
@ -134,14 +136,22 @@ C_findpart(part)
return p; return p;
} }
static
swttmp()
static int swttmp(void)
{ {
#ifndef INCORE #ifndef INCORE
if (C_tmpfile == 0) { if (C_tmpfile == NULL) {
static char tmpbuf[64];
static char tmpbuf[FILENAME_MAX];
register char *p = tmpbuf; register char *p = tmpbuf;
if (C_tmpdir == NULL)
{
C_tmpdir = sys_gettmpdir();
assert(C_tmpdir != NULL);
}
strcpy(p, C_tmpdir); strcpy(p, C_tmpdir);
strcat(p, "/CodeXXXXXX"); strcat(p, "/CodeXXXXXX");
close(mkstemp(p)); close(mkstemp(p));
@ -175,10 +185,10 @@ swttmp()
C_ontmpfile = 1; C_ontmpfile = 1;
} }
#endif #endif
return 0;
} }
static static int swtout(void)
swtout()
{ {
#ifndef INCORE #ifndef INCORE
if (C_ontmpfile) { if (C_ontmpfile) {
@ -203,11 +213,10 @@ swtout()
C_ontmpfile = 0; C_ontmpfile = 0;
} }
#endif #endif
return 0;
} }
static int static int available(int part)
available(part)
int part;
{ {
/* See if part "part", and all the parts it consists of, /* See if part "part", and all the parts it consists of,
are available. Return 1 if they are, 0 otherwize are available. Return 1 if they are, 0 otherwize
@ -240,9 +249,7 @@ available(part)
return retval; return retval;
} }
static Part * static Part *mkpart(int part)
mkpart(part)
int part;
{ {
/* Create a Part structure with id "part", and return a /* Create a Part structure with id "part", and return a
pointer to it, after checking that is does not exist pointer to it, after checking that is does not exist
@ -266,9 +273,7 @@ mkpart(part)
return p; return p;
} }
static static void end_partofpart(register Part *p)
end_partofpart(p)
register Part *p;
{ {
/* End the current chunk of part *p. /* End the current chunk of part *p.
*/ */
@ -285,9 +290,7 @@ end_partofpart(p)
} }
} }
static static void resume(register Part *p)
resume(p)
register Part *p;
{ {
/* Resume part "p", by creating a new PartOfPart structure /* Resume part "p", by creating a new PartOfPart structure
for it. for it.
@ -302,9 +305,7 @@ resume(p)
pp->pp_begin = C_current_out - C_BASE; pp->pp_begin = C_current_out - C_BASE;
} }
void void C_insertpart(int part)
C_insertpart(part)
int part;
{ {
/* Insert part "part" in the current part. If C_sequential is /* Insert part "part" in the current part. If C_sequential is
still set and the part to be inserted is available now, still set and the part to be inserted is available now,
@ -341,9 +342,7 @@ C_insertpart(part)
resume(p); resume(p);
} }
void void C_beginpart(int part)
C_beginpart(part)
int part;
{ {
/* Now follows the definition for part "part". /* Now follows the definition for part "part".
Suspend the current part, and add part "part" to the Suspend the current part, and add part "part" to the
@ -361,9 +360,7 @@ C_beginpart(part)
resume(p); resume(p);
} }
void void C_endpart(int part)
C_endpart(part)
int part;
{ {
/* End the current part. The parameter "part" is just there /* End the current part. The parameter "part" is just there
for the checking. Do we really need it ??? for the checking. Do we really need it ???

View file

@ -3,10 +3,11 @@
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
#include <system.h> #include <stdio.h>
#include <stdlib.h>
#include "system.h"
void void C_internal_error(void)
C_internal_error()
{ {
sys_write(STDERR,"internal error\n",15); sys_write(STDERR,"internal error\n",15);
sys_stop(S_EXIT); sys_stop(S_EXIT);

View file

@ -0,0 +1,18 @@
1i\
/* this part is generated from em_table */
# Remove pseudo instructions
/^\(...\) \([0-9]\).*/d
# Remove opcode constant categories/count
/^\(....\) \([0-9]\).*/d
/^\(.....\) \([0-9]\).*/d
# Below are the actual replacement of opcodes.
s/^\(...\) \(d\).*/#define C_\1(c) CC_opcst(op_\1, c)/
s/^\(...\) \([cslnfzor]\).*/#define C_\1(c) CC_opcst(op_\1, c)/
s/^\(...\) \(w\).*/#define C_\1(w) CC_opcst(op_\1, w)\
#define C_\1_narg() CC_opnarg(op_\1)/
s/^\(...\) \(g\).*/#define C_\1(g) CC_opcst(op_\1, g)\
#define C_\1_dnam(g, o) CC_opdnam(op_\1, g, o)\
#define C_\1_dlb(g, o) CC_opdlb(op_\1, g, o)/
s/^\(...\) \(p\).*/#define C_\1(p) CC_oppnam(op_\1, p)/
s/^\(...\) \(b\).*/#define C_\1(b) CC_opilb(op_\1, b)/
s/^\(...\) \(-\).*/#define C_\1() CC_op(op_\1)/

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_msend(void)
CC_msend()
{ {
CEND(); CEND();
NL(); NL();

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_msstart(int cst)
CC_msstart(cst)
int cst;
{ {
/* start of message /* start of message
*/ */

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_op(int opcode)
CC_op(opcode)
{ {
/* Instruction that never has an argument /* Instruction that never has an argument
Argument types: - Argument types: -

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_opcst(int opcode, arith cst)
CC_opcst(opcode, cst)
arith cst;
{ {
/* Instruction with a constant argument /* Instruction with a constant argument
Argument types: c, d, l, g, f, n, s, z, o, w, r Argument types: c, d, l, g, f, n, s, z, o, w, r

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_opdlb(int opcode, label dlb, arith offset)
CC_opdlb(opcode, dlb, offset)
label dlb;
arith offset;
{ {
/* Instruction that as a numeric datalabel + offset as argument /* Instruction that as a numeric datalabel + offset as argument
Argument types: g Argument types: g

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_opdnam(int opcode, char* dnam, arith offset)
CC_opdnam(opcode, dnam, offset)
char *dnam;
arith offset;
{ {
/* Instruction that has a datalabel + offset as argument /* Instruction that has a datalabel + offset as argument
Argument types: g Argument types: g

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_opilb(int opcode, label ilb)
CC_opilb(opcode, ilb)
label ilb;
{ {
/* Instruction with instruction label argument /* Instruction with instruction label argument
Argument types: b Argument types: b

View file

@ -2,8 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_opnarg(int opcode)
CC_opnarg(opcode)
{ {
/* Instruction with optional argument, but now without one /* Instruction with optional argument, but now without one
Argument types: w Argument types: w

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_oppnam(int opcode, char* pnam)
CC_oppnam(opcode, pnam)
char *pnam;
{ {
/* Instruction that has a procedure name as argument /* Instruction that has a procedure name as argument
Argument types: p Argument types: p

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_pnam(char* str)
CC_pnam(str)
char *str;
{ {
COMMA(); COMMA();
PNAM(str); PNAM(str);

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_pro(char* pnam, arith l)
CC_pro(pnam, l)
char *pnam;
arith l;
{ {
/* PRO pseudo with procedure name pnam and # of locals l /* PRO pseudo with procedure name pnam and # of locals l
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_pronarg(char* pnam)
CC_pronarg(pnam)
char *pnam;
{ {
/* PRO pseudo with procedure name pnam and unknown # of locals /* PRO pseudo with procedure name pnam and unknown # of locals
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_psdlb(int op, label dlb)
CC_psdlb(op, dlb)
label dlb;
{ {
/* Pseudo with numeric datalabel /* Pseudo with numeric datalabel
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_psdnam(int op, char* dnam)
CC_psdnam(op, dnam)
char *dnam;
{ {
/* Pseudo with data label /* Pseudo with data label
*/ */

View file

@ -2,9 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_pspnam(int op, char* pnam)
CC_pspnam(op, pnam)
char *pnam;
{ {
/* Pseudo with procedure name /* Pseudo with procedure name
*/ */

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_scon(char* str, arith siz)
CC_scon(str, siz)
char *str;
arith siz;
{ {
COMMA(); COMMA();
SCON(str, siz); SCON(str, siz);

View file

@ -2,10 +2,7 @@
/* $Id$ */ /* $Id$ */
void void CC_ucon(char* val,arith siz)
CC_ucon(val,siz)
char *val;
arith siz;
{ {
COMMA(); COMMA();
WCON(sp_ucon, val, siz); WCON(sp_ucon, val, siz);