ioquake3 porting

This commit is contained in:
OM 2023-05-24 19:03:05 +02:00
parent 2704b798e2
commit ca3340b158
449 changed files with 104109 additions and 77701 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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
@ -402,7 +401,7 @@ Tree addrof(Tree p) {
Symbol t1 = q->u.sym;
q->u.sym = 0;
q = idtree(t1);
/* fall thru */
/* fall through */
}
case INDIR:
if (p == q)

View file

@ -80,7 +80,7 @@ int fatal(const char *name, const char *fmt, int n) {
return 0;
}
/* printtoken - print current token preceeded by a space */
/* printtoken - print current token preceded by a space */
static void printtoken(void) {
switch (t) {
case ID: fprint(stderr, " `%s'", token); break;

View file

@ -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)

View file

@ -292,7 +292,7 @@ static void dumptree(Node p) {
dumptree(p->kids[0]);
break;
}
/* else fall thru */
/* else fall through */
case EQ: case NE: case GT: case GE: case LE: case LT:
case ASGN: case BOR: case BAND: case BXOR: case RSH: case LSH:
case ADD: case SUB: case DIV: case MUL: case MOD:

View file

@ -40,7 +40,7 @@ static int genconst(Tree e, int def) {
if (isarith(e->type))
error("cast from `%t' to `%t' is illegal in constant expressions\n",
e->kids[0]->type, e->type);
/* fall thru */
/* fall through */
case CVI: case CVU: case CVF:
e = e->kids[0];
continue;

View file

@ -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);

View file

@ -86,7 +86,7 @@ static Tree root1(Tree p) {
warning("reference to `%t' elided\n", p->type);
if (isptr(p->kids[0]->type) && isvolatile(p->kids[0]->type->type))
warning("reference to `volatile %t' elided\n", p->type);
/* fall thru */
/* fall through */
case CVI: case CVF: case CVU: case CVP:
case NEG: case BCOM: case FIELD:
if (warn++ == 0)