cvsuser 03/05/31 16:37:42
Modified: languages/imcc imcc.l imclexer.c instructions.c
instructions.h optimizer.c parser_util.c sets.c
symreg.c symreg.h
Log:
Fix warnings and errors when compiling with LCC and TCC.
Revision Changes Path
1.35 +2 -2 parrot/languages/imcc/imcc.l
Index: imcc.l
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imcc.l,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -w -r1.34 -r1.35
--- imcc.l 19 May 2003 12:23:48 -0000 1.34
+++ imcc.l 31 May 2003 23:37:41 -0000 1.35
@@ -458,7 +458,7 @@
{
int c;
YYSTYPE val;
- char *current = strdup("");
+ char *current = str_dup("");
int len = 0;
params->num_param = 0;
@@ -470,7 +470,7 @@
"End of file reached while reading arguments");
else if (c == ',') {
params->name[params->num_param++] = current;
- current = strdup("");
+ current = str_dup("");
len = 0;
c = yylex_skip(&val, interp, " \n");
}
1.34 +27 -9 parrot/languages/imcc/imclexer.c
Index: imclexer.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imclexer.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -w -r1.33 -r1.34
--- imclexer.c 19 May 2003 12:24:07 -0000 1.33
+++ imclexer.c 31 May 2003 23:37:41 -0000 1.34
@@ -2,7 +2,7 @@
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
- * $Header: /cvs/public/parrot/languages/imcc/imclexer.c,v 1.33 2003/05/19 12:24:07
leo Exp $
+ * $Header: /cvs/public/parrot/languages/imcc/imclexer.c,v 1.34 2003/05/31 23:37:41
josh Exp $
*/
#define FLEX_SCANNER
@@ -10,7 +10,7 @@
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
-
+#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
@@ -23,7 +23,9 @@
#ifdef __cplusplus
#include <stdlib.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
@@ -695,7 +697,7 @@
#define macro 2
-#line 699 "imclexer.c"
+#line 701 "imclexer.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -795,9 +797,20 @@
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -864,7 +877,7 @@
return 0;
}
-#line 868 "imclexer.c"
+#line 881 "imclexer.c"
if ( yy_init )
{
@@ -1520,7 +1533,7 @@
#line 374 "imcc.l"
ECHO;
YY_BREAK
-#line 1524 "imclexer.c"
+#line 1537 "imclexer.c"
case YY_END_OF_BUFFER:
{
@@ -2084,11 +2097,15 @@
}
+#ifndef _WIN32
+#include <unistd.h>
+#else
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#endif
+#endif
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
@@ -2488,13 +2505,14 @@
DUP_AND_RET(valp, c);
}
+
static int
read_params (YYSTYPE *valp, void *interp, struct params_t *params,
const char *macro_name, int need_id)
{
int c;
YYSTYPE val;
- char *current = strdup("");
+ char *current = str_dup("");
int len = 0;
params->num_param = 0;
@@ -2506,7 +2524,7 @@
"End of file reached while reading arguments");
else if (c == ',') {
params->name[params->num_param++] = current;
- current = strdup("");
+ current = str_dup("");
len = 0;
c = yylex_skip(&val, interp, " \n");
}
1.31 +0 -1 parrot/languages/imcc/instructions.c
Index: instructions.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/instructions.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -w -r1.30 -r1.31
--- instructions.c 28 Feb 2003 14:21:43 -0000 1.30
+++ instructions.c 31 May 2003 23:37:42 -0000 1.31
@@ -512,7 +512,6 @@
has_compile = 0;
dont_optimize = 0;
return (emitters[emitter]).open(param);
- return 0;
}
int emit_flush(void *param) {
1.21 +1 -1 parrot/languages/imcc/instructions.h
Index: instructions.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/instructions.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- instructions.h 28 Feb 2003 14:21:43 -0000 1.20
+++ instructions.h 31 May 2003 23:37:42 -0000 1.21
@@ -56,7 +56,7 @@
IF_r0_branch = (1 << 0),
IF_r1_branch = (1 << 1),
IF_r2_branch = (1 << 2),
- IF_goto = (1 << 15),
+ IF_goto = (1 << 15)
} Instruction_Flags;
1.27 +6 -3 parrot/languages/imcc/optimizer.c
Index: optimizer.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/optimizer.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -w -r1.26 -r1.27
--- optimizer.c 31 May 2003 14:56:10 -0000 1.26
+++ optimizer.c 31 May 2003 23:37:42 -0000 1.27
@@ -169,7 +169,7 @@
last->opnum = tmp->opnum;
last->opsize = tmp->opsize;
free(last->op);
- last->op = strdup(neg_op);
+ last->op = str_dup(neg_op);
free_ins(tmp);
/* delete branch */
@@ -793,12 +793,15 @@
goto do_res;
case 'S':
break;
+#if 0
+ /* UNREACHABLE */
/* TODO strings have quote marks around them,
* strip these in lexer
*/
s = ins->r[0]->name;
res = *s && (*s != '0' || s[1]);
goto do_res;
+#endif
}
break;
}
@@ -1213,7 +1216,7 @@
}
-int
+static int
loop_optimization(struct Parrot_Interp *interp)
{
int l, bb, loop_depth;
@@ -1251,7 +1254,7 @@
is_ins_save(ins, rr, CHK_CLONE)) {
debug(DEBUG_OPT2, "clone %s removed\n", ins_string(ins));
free(ins->op);
- ins->op = strdup("set");
+ ins->op = str_dup("set");
return 1;
}
return 0;
1.14 +2 -2 parrot/languages/imcc/parser_util.c
Index: parser_util.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/parser_util.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- parser_util.c 31 May 2003 14:56:10 -0000 1.13
+++ parser_util.c 31 May 2003 23:37:42 -0000 1.14
@@ -184,8 +184,8 @@
STRING *pasm = string_make(interp, "PASM", 4, NULL,0,NULL);
STRING *pir = string_make(interp, "PIR", 3, NULL,0,NULL);
PMC * func;
- Parrot_csub_t pa = (Parrot_csub_t) F2DPTR(imcc_compile_pasm);
- Parrot_csub_t pi = (Parrot_csub_t) F2DPTR(imcc_compile_pir);
+ Parrot_csub_t pa = (Parrot_csub_t)imcc_compile_pasm;
+ Parrot_csub_t pi = (Parrot_csub_t)imcc_compile_pir;
func = pmc_new(interp, enum_class_Compiler);
Parrot_compreg(interp, pasm, func);
1.4 +9 -1 parrot/languages/imcc/sets.c
Index: sets.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/sets.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- sets.c 22 Sep 2002 17:38:27 -0000 1.3
+++ sets.c 31 May 2003 23:37:42 -0000 1.4
@@ -70,7 +70,13 @@
}
int set_contains(Set *s, int element) {
+#ifdef __LCC__
+ /* workaround for another lcc bug.. */
+ int tmp = (1 << (element & 7));
+ return s->bmp[element >> 3] & tmp;
+#else
return s->bmp[element >> 3] & (1 << (element & 7));
+#endif
}
Set * set_union(Set *s1, Set *s2) {
@@ -88,6 +94,8 @@
return s;
}
+
+
Set * set_intersec(Set *s1, Set *s2) {
int i;
1.19 +1 -1 parrot/languages/imcc/symreg.c
Index: symreg.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/symreg.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -w -r1.18 -r1.19
--- symreg.c 16 May 2003 08:31:01 -0000 1.18
+++ symreg.c 31 May 2003 23:37:42 -0000 1.19
@@ -89,7 +89,7 @@
char * _mk_fullname(Namespace * ns, const char * name) {
char * result;
- if (ns == NULL) return strdup(name);
+ if (ns == NULL) return str_dup(name);
result = (char *) malloc(strlen(name) + strlen(ns->name) + 3);
sprintf(result, "%s::%s", ns->name, name);
return result;
1.16 +1 -1 parrot/languages/imcc/symreg.h
Index: symreg.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/symreg.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- symreg.h 4 Mar 2003 10:46:46 -0000 1.15
+++ symreg.h 31 May 2003 23:37:42 -0000 1.16
@@ -41,7 +41,7 @@
enum USAGE {
U_KEYED = 1 << 0, /* array, hash, keyed */
U_NEW = 1 << 1, /* PMC was inited */
- U_SPILL = 1 << 2, /* reg is spilled */
+ U_SPILL = 1 << 2 /* reg is spilled */
};
typedef struct _SymReg {