2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 0bc61214 authored by Martin Ruckert's avatar Martin Ruckert
Browse files

removing printf from libperform

parent 19f80df7
......@@ -16,7 +16,6 @@ LIBSRC= libname.c libbase.c
LIBOBJ= $(LIBSIM:.c=.o) $(LIBAL:.c=.o) $(LIBSRC:.c=.o) mmix-arith.o mmix-io.o
CC= gcc
CFLAGS= -Wall -ggdb -O0
AR = ar
......
......@@ -41,11 +41,6 @@
/* this code defines additional options */
#define MMIX_OPTIONS
/* this defines new interactions for the user */
#define MMIX_INTERACT_STRING
/* this code defines the actions for the strings above */
#define MMIX_INTERACT_ACTION
/* if MMIX_BOOT is defined, mmis-sim will boot from addres #8000...0000
otherwise it will resume at Main */
......@@ -59,7 +54,7 @@ extern int mmix_fputc(int c, FILE *f);
#define fputc(c,f) mmix_fputc(c,f)
#endif
#define MMIX_USAGE if (!*cur_arg) scan_option("?",true) /* exit with usage note */
#define MMIX_NO_FILE if (!*cur_arg) scan_option("?",true) /* exit with usage note */
/* define this to get the real TRAP implementation not the MMIXWARE fake TRAPS */
#undef MMIX_TRAP
......@@ -67,8 +62,6 @@ extern int mmix_fputc(int c, FILE *f);
/* this is the error display function */
#define MMIX_ERROR(f,m) fprintf(stderr,f,m)
#define MMIX_OPTION_STRING
/* define this if you need the tetra inside the mem_node */
#define MMIX_MEM_TET tetra tet; /* the tetrabyte of simulated memory */
......
......@@ -8,7 +8,6 @@
/* define this if you need a local copy of mem_tetra ll */
#define MMIX_LOCAL_LL /* mem_tetra *ll; current place in the simulated memory */
#define MMIX_STO(val,addr) store_data(8,val,addr)
#define MMIX_STT(val,addr) store_data(4,val,addr)
#define MMIX_STW(val,addr) store_data(2,val,addr)
......@@ -30,24 +29,39 @@
#define MMIX_DELAY(ms,d) d = vmb_wait_for_event_timed(&vmb,ms)
/* define this to check for external asynchronous ineterrupts*/
#define MMIX_GET_INTERRUPT
#define MMIX_GET_INTERRUPT \
if (vmb_get_interrupt(&vmb,&new_Q.h,&new_Q.l)==1) \
{ g[rQ].h |= new_Q.h; g[rQ].l |= new_Q.l; }
/* this code is executed when MMIX enters the handler for Ctrl-C */
#define MMIX_CTRL_HANDLER
/* this code defines additional options */
#define MMIX_OPTIONS
/* this defines new interactions for the user */
#define MMIX_INTERACT_STRING
#define MMIX_CTRL_HANDLER vmb_cancel_wait_for_event(&vmb); show_operating_system=true;
/* this code defines additional command line options */
#define MMIX_OPTIONS \
case 'B': \
{ char *p; \
p = strchr(arg+1,':'); \
if (p==NULL) \
{ host=localhost; \
port = atoi(arg+1); \
} \
else \
{ port = atoi(p+1); \
host = malloc(p+1-arg+1); \
if (host==NULL) panic("No room for hostname"); \
strncpy(host,arg+1,p-arg-1); \
host[p-arg-1]=0; \
} \
} \
return; \
/* this code defines the actions for the strings above */
#define MMIX_INTERACT_ACTION
/* if MMIX_BOOT is defined, mmis-sim will boot from addres #8000...0000
otherwise it will resume at Main */
#define MMIX_BOOT
#define MMIX_PRINT
#ifdef MMIX_PRINT
extern int mmix_printf(char *format,...);
......@@ -57,10 +71,8 @@ extern int mmix_fputc(int c, FILE *f);
#define fputc(c,f) mmix_fputc(c,f)
#endif
#define MMIX_USAGE if (!*cur_arg) scan_option("?",true) /* exit with usage note */
/* give a condition to break from the inner loop */
#define MMIX_BREAK_LOOP false
/* this action is executed when ther is no mmo file on the command line */
#define MMIX_NO_FILE
/* define this to get the real TRAP implementation not the MMIXWARE fake TRAPS */
......@@ -69,8 +81,6 @@ extern int mmix_fputc(int c, FILE *f);
/* this is the error display function */
#define MMIX_ERROR(f,m) fprintf(stderr,f,m)
#define MMIX_OPTION_STRING
/* define this if you need the tetra inside the mem_node */
#define MMIX_MEM_TET /* tetra tet; the tetrabyte of simulated memory */
......
......@@ -275,22 +275,16 @@ int main(argc,argv)
}
@y
@c
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <setjmp.h>
#include "libconfig.h"
@#
@<Preprocessor definitions@>@;
@<Type definitions@>@;
extern int expanding;
extern int buf_size;
extern char*src_file_name;
extern char obj_file_name[FILENAME_MAX+1];
extern char listing_name[FILENAME_MAX+1];
extern jmp_buf mmixal_exit;
extern void report_error(char * message, char *filename, int line_no);
extern int mmixal(char *mms_name, char *mmo_name, char *mml_name, int x_option, int b_option);
......@@ -383,12 +377,6 @@ int mmixal(char *mms_name, char *mmo_name, char *mml_name, int x_option, int b_o
We end with return or longjmp instead of exit.
@x
exit(-1);
@y
longjmp(mmixal_exit,-1);
@z
@x
if (err_count) {
if (err_count>1) fprintf(stderr,"(%d errors were found.)\n",err_count);
......
......@@ -760,11 +760,8 @@ void stack_store(x)
ll=mem_find(g[rS]);
test_store_bkpt(ll);
test_store_bkpt(ll+1);
if (stack_tracing) {
tracing=true;
printf(" M8[#%08x%08x]=#%08x%08x, rS+=8\n",
mmix_stack_trace(" M8[#%08x%08x]=#%08x%08x, rS+=8\n",
g[rS].h,g[rS].l,x.h,x.l);
}
g[rS]=incr(g[rS],8), S++;
}
......@@ -801,8 +798,15 @@ void stack_load @,@,@[ARGS((void))@];@+@t}\6{@>
showing lines is part of main.
@x
if (stack_tracing) {
tracing=true;
if (cur_line) show_line();
printf(" rS-=8, l[%d]=M8[#%08x%08x]=#%08x%08x\n",
k,g[rS].h,g[rS].l,l[k].h,l[k].l);
}
@y
mmix_stack_trace(" rS-=8, l[%d]=M8[#%08x%08x]=#%08x%08x\n",
k,g[rS].h,g[rS].l,l[k].h,l[k].l);
@z
@x
......@@ -1167,15 +1171,12 @@ if (k==rZ+1)
}
else
if (!MMIX_LDO(g[k],g[rS])) { w=g[rS]; goto page_fault; }
if (stack_tracing) {
tracing=true;
if (k>=32) printf(" rS-=8, g[%d]=M8[#%08x%08x]=#%08x%08x\n",
k,g[rS].h,g[rS].l,g[k].h,g[k].l);
else if (k==rZ+1) printf(" (rG,rA)=M8[#%08x%08x]=#%08x%08x\n",
g[rS].h,g[rS].l,g[k].h,g[k].l);
else printf(" rS-=8, %s=M8[#%08x%08x]=#%08x%08x\n",
special_name[k],g[rS].h,g[rS].l,g[k].h,g[k].l);
}
if (k>=32) mmix_stack_trace(" rS-=8, g[%d]=M8[#%08x%08x]=#%08x%08x\n",
k,g[rS].h,g[rS].l,g[k].h,g[k].l);
else if (k==rZ+1) mmix_stack_trace(" (rG,rA)=M8[#%08x%08x]=#%08x%08x\n",
g[rS].h,g[rS].l,g[k].h,g[k].l);
else mmix_stack_trace(" rS-=8, %s=M8[#%08x%08x]=#%08x%08x\n",
special_name[k],g[rS].h,g[rS].l,g[k].h,g[k].l);
@z
@x
......@@ -1884,6 +1885,7 @@ void trace_print @,@,@[ARGS((octa))@];@+@t}\6{@>
@ @(libtrace.c@>=
#include <stdio.h>
#include <setjmp.h>
#include <stdarg.h>
#include "libconfig.h"
#include <time.h>
#include "libtype.h"
......@@ -1892,6 +1894,17 @@ void trace_print @,@,@[ARGS((octa))@];@+@t}\6{@>
#include "libarith.h"
#include "libimport.h"
void mmix_stack_trace(char *format,...)
{
if (stack_tracing) {
va_list vargs;
tracing=true;
va_start(vargs,format);
vprintf(format, vargs);
}
}
static fmt_style style;
static char *stream_name[]={"StdIn","StdOut","StdErr"};
@.StdIn@>
......@@ -2171,6 +2184,7 @@ page_fault:
#include "mmix-io.h"
#include "libimport.h"
static bool interact_after_resume= false;
@<Stack store@>@;
......@@ -2342,7 +2356,7 @@ mmo_file_name may become a variable not an alias.
if (!*cur_arg) scan_option("?",true); /* exit with usage note */
argc -= cur_arg-argv; /* this is the |argc| of the user program */
@y
MMIX_USAGE;
MMIX_NO_FILE;
argc -= (int)(cur_arg-argv); /* this is the |argc| of the user program */
@z
......@@ -2430,11 +2444,11 @@ BOOL CtrlHandler( DWORD fdwCtrlType )
interrupt=true;
if (fdwCtrlType==CTRL_C_EVENT || fdwCtrlType==CTRL_BREAK_EVENT )
{
printf("Ctrl-C received\n");
/* do nothing */
}
else
{ printf("Closing MMIX\n");
halted=true;
{
interrupt=halted=true;
}
return TRUE;
}
......@@ -2444,7 +2458,6 @@ void catchint(n)
int n;
{ MMIX_CTRL_HANDLER
interrupt=true;
printf("Ctrl-C received\n");
signal(SIGINT,catchint); /* now |catchint| will catch the next interrupt */
}
#endif
......
......@@ -61,7 +61,8 @@ extern int mmix_printf(char *format,...);
/* printf replacement */
extern int mmix_fputc(int c, FILE *f);
/* fputc replacement */
void mmix_stack_trace(char *format,...);
/* function to do the stack trace */
#if 0
extern int cur_file; /* index of the current file in |filename| */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment