From 91d270eb90a212695b27768777477d76e6b012f3 Mon Sep 17 00:00:00 2001 From: ceriel Date: Wed, 10 Nov 1993 12:57:16 +0000 Subject: [PATCH] Modified for Solaris 2 --- mach/sparc/ce/back.src/do_open.c | 19 +++++--- mach/sparc/ce/cache.c.x | 14 +++--- mach/sparc/ce/ce.src/.distr | 2 +- mach/sparc/ce/ce.src/C_con_scon.c | 1 + mach/sparc/ce/ce.src/C_exa_dnam.c | 1 + mach/sparc/ce/ce.src/C_pro.c | 28 ++++++++++++ mach/sparc/ce/ce.src/C_rom_scon.c | 1 + mach/sparc/ce/ce.src/ms_reg.c | 72 +++++++++++++++++++++++++++++++ mach/sparc/ce/mach.c | 13 ------ mach/sparc/ce/push_pop.h | 13 +----- 10 files changed, 128 insertions(+), 36 deletions(-) create mode 100644 mach/sparc/ce/ce.src/C_pro.c diff --git a/mach/sparc/ce/back.src/do_open.c b/mach/sparc/ce/back.src/do_open.c index b90c11023..3887e0d9e 100644 --- a/mach/sparc/ce/back.src/do_open.c +++ b/mach/sparc/ce/back.src/do_open.c @@ -3,13 +3,22 @@ open_back( filename) char *filename; { - if ( filename == (char *) 0) + if ( filename == (char *) 0) { codefile= STDOUT; - else +#ifdef __solaris__ + fprint(codefile, ".section \".text\"\n"); +#endif + return 1; + } #ifndef sys_close - return( sys_open( filename, OP_WRITE, &codefile)); + if ( sys_open( filename, OP_WRITE, &codefile)) { #else - return (codefile = fopen(filename, "w")) != NULL; + if ((codefile = fopen(filename, "w")) != NULL) { +#endif +#ifdef __solaris__ + fprint(codefile, ".section \".text\"\n"); #endif - return 1; + return 1; + } + return 0; } diff --git a/mach/sparc/ce/cache.c.x b/mach/sparc/ce/cache.c.x index bdf095fbe..56792a940 100644 --- a/mach/sparc/ce/cache.c.x +++ b/mach/sparc/ce/cache.c.x @@ -2,13 +2,12 @@ #include #include +#include #include "mach.h" #ifdef __STDC__ -#include #include #else -extern char *malloc(); extern char *strcpy(); #endif @@ -108,6 +107,12 @@ static struct cache_elt cache[CACHE_SIZE], *tos = 0; static int c_count = 0; static const_str_t s; +_PROTOTYPE(static void panic, (char*)); +_PROTOTYPE(static void dump_cache, (File *stream)); +_PROTOTYPE(static int cache_read, (int n, int i)); +_PROTOTYPE(static void flush_part_cache, (int c, int r, int f, int d)); +_PROTOTYPE(static void subst_reg, (reg_t, reg_t)); + static void panic(s) char *s; { @@ -824,8 +829,7 @@ char *s; char *p; enter("push_ext"); - p = malloc(strlen(s)+1); - assert(p); + p = Malloc(strlen(s)+1); INC_TOS; tos->reg = reg_g0; @@ -1282,7 +1286,7 @@ enter("dup_tos"); *tos = tos[-n]; if (tos->ext) { - ext= malloc(strlen(tos->ext)+1); + ext= Malloc(strlen(tos->ext)+1); strcpy(ext, tos->ext); tos->ext= ext; } diff --git a/mach/sparc/ce/ce.src/.distr b/mach/sparc/ce/ce.src/.distr index 955e73532..b264bf3a7 100644 --- a/mach/sparc/ce/ce.src/.distr +++ b/mach/sparc/ce/ce.src/.distr @@ -8,7 +8,7 @@ C_mes_end.c C_pnam.c C_rom_scon.c C_scon.c -C_exp.c +C_pro.c C_exa_dnam.c misc.c ms_reg.c diff --git a/mach/sparc/ce/ce.src/C_con_scon.c b/mach/sparc/ce/ce.src/C_con_scon.c index e8652fb83..69d6ac695 100644 --- a/mach/sparc/ce/ce.src/C_con_scon.c +++ b/mach/sparc/ce/ce.src/C_con_scon.c @@ -3,6 +3,7 @@ #include "mach.h" #include "back.h" +void C_con_scon( s, n) char *s; arith n; diff --git a/mach/sparc/ce/ce.src/C_exa_dnam.c b/mach/sparc/ce/ce.src/C_exa_dnam.c index 1347bbc98..a6cf80dac 100644 --- a/mach/sparc/ce/ce.src/C_exa_dnam.c +++ b/mach/sparc/ce/ce.src/C_exa_dnam.c @@ -2,6 +2,7 @@ #include #include "back.h" +void C_exa_dnam( s) char *s; { diff --git a/mach/sparc/ce/ce.src/C_pro.c b/mach/sparc/ce/ce.src/C_pro.c new file mode 100644 index 000000000..e1fb32f86 --- /dev/null +++ b/mach/sparc/ce/ce.src/C_pro.c @@ -0,0 +1,28 @@ +#define CODE_EXPANDER +#include +#include "back.h" +#include + +extern int B_locals_created; +extern int B_procno; +char *B_procnam; + +void +C_pro( s, l) +char *s; +arith l; +{ + swtxt(); + s = extnd_name(s); +#ifdef __solaris__ + fprint(codefile, "\t.type\t%s,#function\n", s); + if (B_procnam) free(B_procnam); + B_procnam = Salloc(s, strlen(s)+1); +#endif + + symbol_definition( s); + B_procno++; + C_prolog(); + C_locals(l); + B_locals_created = 1; +} diff --git a/mach/sparc/ce/ce.src/C_rom_scon.c b/mach/sparc/ce/ce.src/C_rom_scon.c index 09ca2d6dc..bb60be592 100644 --- a/mach/sparc/ce/ce.src/C_rom_scon.c +++ b/mach/sparc/ce/ce.src/C_rom_scon.c @@ -3,6 +3,7 @@ #include "mach.h" #include "back.h" +void C_rom_scon( s, n) char *s; arith n; diff --git a/mach/sparc/ce/ce.src/ms_reg.c b/mach/sparc/ce/ce.src/ms_reg.c index d915746ef..53bdc3311 100644 --- a/mach/sparc/ce/ce.src/ms_reg.c +++ b/mach/sparc/ce/ce.src/ms_reg.c @@ -34,6 +34,7 @@ static int current_reg_mes[RM_COUNT+4]; static int in_reg_mes = 0; /* boolean */ static int reg_mes_nr; static int db_mes = 0; +static int db_kind = 0; static int db_str = 0; static int db_nul = 0; /* boolean */ @@ -252,18 +253,36 @@ load_float_regs() } +void C_mes_begin( ms) int ms; { +#ifdef __solaris__ + static int inits; +#endif + reg_mes_nr = 0; in_reg_mes = (ms == ms_reg); if (ms == ms_gto) fprint(codefile, "ta 3\n"); db_mes = (ms == ms_stb || ms == ms_std) ? ms : 0; +#ifdef __solaris__ + if (db_mes && ! inits) { + fprint(codefile, ".pushsection \".text\"\nBtext.text:\n.popsection\n"); + fprint(codefile, ".pushsection \".data\"\nBdata.data:\n.popsection\n"); + fprint(codefile, ".pushsection \".bss\"\nBbss.bss:\n.popsection\n"); + inits = 1; + } +#endif } static dump_reg_tabs(); +#ifdef __solaris__ +extern char *B_procnam; +#endif + +void C_mes_end() { int pos; @@ -271,10 +290,22 @@ C_mes_end() if (db_mes) { db_nul = 0; +#ifdef __solaris__ + if (db_mes == ms_std) { + if (db_str == 2) { + fprint(codefile, ",1f\n1:\n"); + } + else { + fprint(codefile, ",1f-%s\n1:\n", B_procnam); + } + } +#else if (db_mes == ms_std && db_str == 2) fprint(codefile,",1f\n1:\n"); +#endif else fprint(codefile, "\n"); db_str = 0; db_mes = 0; + db_kind = 0; } if (!in_reg_mes) /* end of some other mes */ return; @@ -326,22 +357,32 @@ C_mes_end() extern int __gdb_flag; +void C_cst( l) arith l; { static int correct_offset; if (db_mes) { + if (! db_kind) db_kind = l; if (! db_str) { switchseg( SEGTXT); if (l == N_SLINE && ! __gdb_flag) { flush_cache(); +#ifdef __solaris__ + fprint(codefile, "call $__uX_LiB\nnop\n"); +#else fprint(codefile, "call ___uX_LiB\nnop\n"); +#endif } +#ifdef __solaris__ + fprint(codefile, ".stabn 0x%lx,0", (long) l); +#else if (db_mes == ms_std) { fprint(codefile, ".stabd 0x%lx,0", (long) l); } else fprint(codefile, ".stabn 0x%lx,0", (long) l); +#endif db_str = 1; db_nul = 1; } @@ -364,6 +405,7 @@ arith l; current_reg_mes[reg_mes_nr++] = l; } +void C_scon(s, l) register char *s; register arith l; @@ -383,6 +425,7 @@ register arith l; } } +void C_dlb(l, off) label l; arith off; @@ -391,9 +434,20 @@ arith off; fprint(codefile,","); fprint(codefile, DLB_FMT, (long) l); if (off) fprint(codefile,"+%ld", (long) off); +#ifdef __solaris__ + switch(db_kind) { + case N_LCSYM: + fprint(codefile, "-Bbss.bss"); + break; + case N_STSYM: + fprint(codefile, "-Bdata.data"); + break; + } +#endif } } +void C_dnam(l, off) char *l; arith off; @@ -402,26 +456,44 @@ arith off; fprint(codefile,","); fprint(codefile, DNAM_FMT, l); if (off) fprint(codefile,"+%ld", (long) off); +#ifdef __solaris__ + switch(db_kind) { + case N_LCSYM: + fprint(codefile, "-Bbss.bss"); + break; + case N_STSYM: + fprint(codefile, "-Bdata.data"); + break; + } +#endif } } extern int B_procno; +void C_ilb(l) label l; { if (db_mes) { fprint(codefile,","); fprint(codefile, ILB_FMT, B_procno, (long)l); +#ifdef __solaris__ + fprint(codefile, "-Btext.text"); +#endif } } +void C_pnam(s) char *s; { if (db_mes) { fprint(codefile,","); fprint(codefile, NAME_FMT, s); +#ifdef __solaris__ + fprint(codefile, "-Btext.text"); +#endif } } diff --git a/mach/sparc/ce/mach.c b/mach/sparc/ce/mach.c index 680721efa..6a6547e65 100644 --- a/mach/sparc/ce/mach.c +++ b/mach/sparc/ce/mach.c @@ -13,19 +13,6 @@ int arg; } #endif - -/* -do_open( filename) -char *filename; -{ - if ( filename == (char *)0 || !sys_open( filename, OP_WRITE, &codefile)) - return( 0); - - fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n"); - return( 1); -} -*/ - #define IEEEFLOAT #define FL_MSL_AT_LOW_ADDRESS 1 #define FL_MSW_AT_LOW_ADDRESS 1 diff --git a/mach/sparc/ce/push_pop.h b/mach/sparc/ce/push_pop.h index 64991c9a3..9a94fc933 100644 --- a/mach/sparc/ce/push_pop.h +++ b/mach/sparc/ce/push_pop.h @@ -34,11 +34,7 @@ extern reg_t reg_f0; extern reg_t reg_sp, reg_lb, reg_gap; extern reg_t reg_tmp; -#ifdef __STDC__ -#define _PROTOTYPE(x,y) x y -#else -#define _PROTOTYPE(x,y) x() -#endif +#include "ansi.h" _PROTOTYPE(int const13, (int)); _PROTOTYPE(void init_cache, (void)); @@ -54,13 +50,8 @@ _PROTOTYPE(void push_const, (arith)); _PROTOTYPE(void push_reg, (reg_t)); _PROTOTYPE(void push_ext, (char *)); _PROTOTYPE(void flush_cache, (void)); -static _PROTOTYPE(void flush_part_cache, (int c, int r, int f, int d)); -static _PROTOTYPE(void subst_reg, (reg_t, reg_t)); _PROTOTYPE(void cache_need, (int)); -static _PROTOTYPE(int cache_read, (int n, int i)); -static _PROTOTYPE(void dump_cache, (File *stream)); _PROTOTYPE(void pop_nop, (int)); -static _PROTOTYPE(void panic, (char*)); _PROTOTYPE(reg_t alloc_reg, (void)); _PROTOTYPE(reg_t alloc_reg_var, (void)); @@ -74,8 +65,6 @@ _PROTOTYPE(reg_t pop_reg_reg, (reg_t*)); _PROTOTYPE(reg_t pop_float, (void)); _PROTOTYPE(reg_t pop_double, (reg_t *sub_reg)); _PROTOTYPE(void pop_reg_as, (reg_t r)); -static _PROTOTYPE(reg_t top_reg, (void)); -static _PROTOTYPE(reg_t top_reg_c13, (char*)); _PROTOTYPE(arith pop_const, (char *n_str)); _PROTOTYPE(arith top_const, (void)); -- 2.34.1