changeset 307:fda28752d301 stdarg-support

stdarg (varargs done... PowerPC, IA32 checked)
author kono
date Wed, 09 Jun 2004 23:01:18 +0900
parents 1ec915dcd2d1
children e1d17d6adfcc
files Changes Makefile mc-code-ia32.c mc-code-powerpc.c mc-parse.c
diffstat 5 files changed, 32 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Wed Jun 09 15:59:06 2004 +0900
+++ b/Changes	Wed Jun 09 23:01:18 2004 +0900
@@ -4853,3 +4853,11 @@
 切符買わないと。なんか、関数の引数の型のチェックをしてない
 みたい。
 
+stdarg できました。struct size のエラーはなに?
+
+えーと、
+	alloca 
+	asm
+	struct partial field init
+        hoge##name
+がないね。というか、これだけ? (頑張れ〜)
--- a/Makefile	Wed Jun 09 15:59:06 2004 +0900
+++ b/Makefile	Wed Jun 09 23:01:18 2004 +0900
@@ -72,6 +72,7 @@
 	make check TARGET=test/enum
 	make check TARGET=test/obsf
 	make check TARGET=test/long
+	make check TARGET=test/tstdarg
 	make check TARGET=test/code-gen-all
 #MK =-make
 MK=
--- a/mc-code-ia32.c	Wed Jun 09 15:59:06 2004 +0900
+++ b/mc-code-ia32.c	Wed Jun 09 23:01:18 2004 +0900
@@ -6,8 +6,6 @@
 #include "mc-codegen.h"
 #include "mc-code.h"
 
-char *init_src = 0;
-
 char *l_include_path[] = {
     "/usr/include/",
     "/usr/include/linux/",
@@ -217,20 +215,23 @@
     return i==REG_L?"%esi":"%eax";
 }
 
+char *init_src = "\
+#define va_list int\n\
+#define va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
+#define va_arg(ap,type)  (*((type *)ap)++)\n\
+#define va_end\n\
+#define __i386__ 1\n\
+#define __LITTLE_ENDIAN__ 1\n\
+#define __STDC__ 1\n\
+#define size_t int\n\
+#define __externsion__\n\
+#define __flexarr\n\
+#define wchar_t int\n\
+";
 
 void
 code_init(void)
 {
-    macro_define("__i386__ 1\n");
-    macro_define("__LITTLE_ENDIAN__ 1\n");
-    macro_define("__STDC__ 1\n");
-    macro_define("size_t int\n");
-    macro_define("__externsion__\n");
-    macro_define("__flexarr\n");
-    macro_define("__builtin_va_list int*\n");
-    macro_define("wchar_t int\n");
-    // macro_define("__THROW\n");
-    macro_define("__gnuc_va_list int*\n");
 
     arg_offset = 8;
     // func_disp_offset = -12;
--- a/mc-code-powerpc.c	Wed Jun 09 15:59:06 2004 +0900
+++ b/mc-code-powerpc.c	Wed Jun 09 23:01:18 2004 +0900
@@ -2682,13 +2682,8 @@
 void
 gen_comment(char *s)
 {
-    int c;
     if (chk) return;
-    printf("## ");
-    while((c=*s++)) {
-	putchar(c);
-	if (c=='\n') break;
-    }
+    printf("## %s",s);
 }
 
 void
--- a/mc-parse.c	Wed Jun 09 15:59:06 2004 +0900
+++ b/mc-parse.c	Wed Jun 09 23:01:18 2004 +0900
@@ -4420,11 +4420,10 @@
 		chinput=0;
 		continue;
 	    }
-	    chptr=chinput;
-	    while((c=*chinput++)&&(c!='\n'));
-	    if (lsrc && !asmf && !macro_if_skip) gen_comment(chinput);
-	    if (*chptr== '#' && !in_comment && !in_quote) {
-		if (macro_processing()) return;
+	    chptr=linebuf;
+	    i=0;
+	    while((*chptr++=c=*chinput++)&&(c!='\n')) {
+		if (++i > LBUFSIZE-2) error(LNERR);
 	    }
 	} else {
 	    lineno++;
@@ -4438,11 +4437,11 @@
 			--chptr;
 		}
 	    }
-	    *chptr = '\0';
-	    if (lsrc && !asmf && !macro_if_skip) gen_comment(linebuf);
-	    if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
-		if (macro_processing()) return;
-	    }
+	}
+	*chptr = '\0';
+	if (lsrc && !asmf && !macro_if_skip) gen_comment(linebuf);
+	if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
+	    if (macro_processing()) return;
 	}
     } while(!in_quote && (macro_if_skip || linebuf[0] == '#'));
 }