diff options
author | /dev/humancontroller <devhc@example.com> | 2017-04-13 11:30:00 +0000 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-04-15 12:11:01 +0200 |
commit | 60d92bbdcfc22c7248989ad7efb856989d299daa (patch) | |
tree | 74de9d4cb1f1a938705e13257ba136b9872b6600 /src/tools/lcc/src | |
parent | 1a5afab2fcd1d43e5d43160ee601fa3bfa375a76 (diff) |
update the tools to the latest revision
URL: https://github.com/darklegion/tremulous
revision: c862a5340c8de44dcc7abaff170c20c04f9340e8, equivalently f45fbef604e05144057dec8d1dbfc5d4f5a2a822
Diffstat (limited to 'src/tools/lcc/src')
-rw-r--r-- | src/tools/lcc/src/bytecode.c | 11 | ||||
-rw-r--r-- | src/tools/lcc/src/c.h | 7 | ||||
-rw-r--r-- | src/tools/lcc/src/enode.c | 3 | ||||
-rw-r--r-- | src/tools/lcc/src/expr.c | 2 | ||||
-rw-r--r-- | src/tools/lcc/src/list.c | 2 |
5 files changed, 16 insertions, 9 deletions
diff --git a/src/tools/lcc/src/bytecode.c b/src/tools/lcc/src/bytecode.c index b267d6f..871056a 100644 --- a/src/tools/lcc/src/bytecode.c +++ b/src/tools/lcc/src/bytecode.c @@ -40,8 +40,9 @@ static void I(defconst)(int suffix, int size, Value v) { case P: print("byte %d %U\n", size, (unsigned long)v.p); return; case F: if (size == 4) { - float f = v.d; - print("byte 4 %u\n", *(unsigned *)&f); + floatint_t fi; + fi.f = v.d; + print("byte 4 %u\n", fi.ui); } else { unsigned *p = (unsigned *)&v.d; print("byte 4 %u\n", p[swap]); @@ -67,10 +68,10 @@ static void I(defsymbol)(Symbol p) { case P: p->x.name = stringf("%U", p->u.c.v.p); break; case F: { // JDC: added this to get inline floats - unsigned temp; + floatint_t temp; - *(float *)&temp = p->u.c.v.d; - p->x.name = stringf("%U", temp ); + temp.f = p->u.c.v.d; + p->x.name = stringf("%U", temp.ui ); } break;// JDC: added this default: assert(0); diff --git a/src/tools/lcc/src/c.h b/src/tools/lcc/src/c.h index e36380e..43bec08 100644 --- a/src/tools/lcc/src/c.h +++ b/src/tools/lcc/src/c.h @@ -98,6 +98,12 @@ typedef struct { void *xt; } Xtype; +typedef union { + float f; + int i; + unsigned int ui; +} floatint_t; + #include "config.h" typedef struct metrics { unsigned char size, align, outofline; @@ -571,6 +577,7 @@ extern Tree cnsttree(Type, ...); extern Tree consttree(unsigned int, Type); extern Tree eqtree(int, Tree, Tree); extern int iscallb(Tree); +extern int isnullptr(Tree); extern Tree shtree(int, Tree, Tree); extern void typeerror(int, Tree, Tree); diff --git a/src/tools/lcc/src/enode.c b/src/tools/lcc/src/enode.c index 760096d..4a37618 100644 --- a/src/tools/lcc/src/enode.c +++ b/src/tools/lcc/src/enode.c @@ -5,7 +5,6 @@ static Tree addtree(int, Tree, Tree); static Tree andtree(int, Tree, Tree); static Tree cmptree(int, Tree, Tree); static int compatible(Type, Type); -static int isnullptr(Tree e); static Tree multree(int, Tree, Tree); static Tree subtree(int, Tree, Tree); #define isvoidptr(ty) \ @@ -220,7 +219,7 @@ static int compatible(Type ty1, Type ty2) { && isptr(ty2) && !isfunc(ty2->type) && eqtype(unqual(ty1->type), unqual(ty2->type), 0); } -static int isnullptr(Tree e) { +int isnullptr(Tree e) { Type ty = unqual(e->type); return generic(e->op) == CNST diff --git a/src/tools/lcc/src/expr.c b/src/tools/lcc/src/expr.c index b8cb08b..96eec21 100644 --- a/src/tools/lcc/src/expr.c +++ b/src/tools/lcc/src/expr.c @@ -621,7 +621,7 @@ Tree cast(Tree p, Type type) { p = simplify(CVP, dst, p, NULL); else { if ((isfunc(src->type) && !isfunc(dst->type)) - || (!isfunc(src->type) && isfunc(dst->type))) + || (!isnullptr(p) && !isfunc(src->type) && isfunc(dst->type))) warning("conversion from `%t' to `%t' is compiler dependent\n", p->type, type); if (src->size != dst->size) diff --git a/src/tools/lcc/src/list.c b/src/tools/lcc/src/list.c index 29e660a..9c3ec9f 100644 --- a/src/tools/lcc/src/list.c +++ b/src/tools/lcc/src/list.c @@ -33,7 +33,7 @@ int length(List list) { return n; } -/* ltov - convert list to an NULL-terminated vector allocated in arena */ +/* ltov - convert list to a NULL-terminated vector allocated in arena */ void *ltov(List *list, unsigned arena) { int i = 0; void **array = newarray(length(*list) + 1, sizeof array[0], arena); |