summaryrefslogtreecommitdiff
path: root/src/tools/lcc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/lcc')
-rw-r--r--src/tools/lcc/src/bytecode.c14
-rw-r--r--src/tools/lcc/src/c.h6
2 files changed, 14 insertions, 6 deletions
diff --git a/src/tools/lcc/src/bytecode.c b/src/tools/lcc/src/bytecode.c
index b267d6fa..e83429fc 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);
@@ -260,7 +261,8 @@ static void LoadSourceFile( const char *filename ) {
length = filelength( f );
sourceFile = malloc( length + 1 );
if ( sourceFile ) {
- fread( sourceFile, length, 1, f );
+ size_t size;
+ size = fread( sourceFile, length, 1, f );
sourceFile[length] = 0;
}
diff --git a/src/tools/lcc/src/c.h b/src/tools/lcc/src/c.h
index e36380ef..68c8f629 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;