ref: 87f457bc54dc3686f61b02d9d12c2576caf09a13
parent: d9e95d51727004924d5c5cd495a53fd286543377
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Dec 16 19:04:23 EST 2023
remove the need for preprocessor; move platform-specific stuff into designated plan9/ and unix/
--- a/Makefile
+++ b/Makefile
@@ -127,8 +127,7 @@
server.h\
softfloat.h\
spritegn.h\
- unix/libc.h\
- unix/u.h\
+ unix/platform.h\
vid.h\
view.h\
wad.h\
--- a/chase.c
+++ b/chase.c
@@ -53,7 +53,7 @@
dist = DotProduct (stop, forward);
if (dist < 1)
dist = 1;
- r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180;
+ r_refdef.viewangles[PITCH] = -atanf(stop[2] / dist) / M_PI * 180;
// move towards destination
VectorCopy (chase_dest, r_refdef.vieworg);
--- a/cl_tent.c
+++ b/cl_tent.c
@@ -275,12 +275,12 @@
}
else
{
- yaw = (int) (atan2(dist[1], dist[0]) * 180 / M_PI);
+ yaw = (int) (atan2f(dist[1], dist[0]) * 180 / M_PI);
if (yaw < 0)
yaw += 360;
- forward = sqrt (dist[0]*dist[0] + dist[1]*dist[1]);
- pitch = (int) (atan2(dist[2], forward) * 180 / M_PI);
+ forward = sqrtf(dist[0]*dist[0] + dist[1]*dist[1]);
+ pitch = (int) (atan2f(dist[2], forward) * 180 / M_PI);
if (pitch < 0)
pitch += 360;
}
--- a/mathlib.c
+++ b/mathlib.c
@@ -82,14 +82,14 @@
double sr, sp, sy, cr, cp, cy;
angle = angles[YAW] * (M_PI*2 / 360.0);
- sy = sin(angle);
- cy = cos(angle);
+ sy = sinf(angle);
+ cy = cosf(angle);
angle = angles[PITCH] * (M_PI*2 / 360.0);
- sp = sin(angle);
- cp = cos(angle);
+ sp = sinf(angle);
+ cp = cosf(angle);
angle = angles[ROLL] * (M_PI*2 / 360.0);
- sr = sin(angle);
- cr = cos(angle);
+ sr = sinf(angle);
+ cr = cosf(angle);
forward[0] = cp*cy;
forward[1] = cp*sy;
@@ -118,7 +118,7 @@
vec_t Length(vec3_t v)
{
- return sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+ return sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
}
float VectorNormalize (vec3_t v)
@@ -125,7 +125,7 @@
{
float length, ilength;
- length = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+ length = sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
if(length != 0){
ilength = 1/length;
v[0] *= ilength;
--- a/mkfile
+++ b/mkfile
@@ -2,7 +2,7 @@
BIN=/$objtype/bin/games
TARG=quake
-CFLAGS=$CFLAGS -D__plan9__
+CFLAGS=$CFLAGS -D__plan9__ -D__${objtype}__ -Iplan9
OFILES=\
span`{test -f span_$objtype.s && echo -n _$objtype}.$O\
@@ -87,8 +87,6 @@
zone.$O\
HFILES=\
- dat.h\
- fns.h\
adivtab.h\
anorms.h\
bspfile.h\
@@ -99,22 +97,25 @@
cvar.h\
d_iface.h\
d_local.h\
+ dat.h\
draw.h\
+ fns.h\
input.h\
keys.h\
mathlib.h\
menu.h\
- modelgen.h\
model.h\
+ modelgen.h\
net.h\
+ plan9/platform.h\
pr_comp.h\
progdefs.h\
progs.h\
protocol.h\
quakedef.h\
- render.h\
r_local.h\
r_shared.h\
+ render.h\
sbar.h\
screen.h\
server.h\
@@ -127,9 +128,3 @@
zone.h\
</sys/src/cmd/mkone
-
-dotadd.$O: dotadd.c
- $CC $CFLAGS -p dotadd.c
-
-softfloat.$O: softfloat.c
- $CC $CFLAGS -p softfloat.c
--- /dev/null
+++ b/plan9/platform.h
@@ -1,0 +1,40 @@
+#include <u.h>
+#include <libc.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#define RAND_MAX ((2<<15)-1)
+#define acosf acos
+#define asinf asin
+#define atan2f atan2
+#define atanf atan
+#define cosf cos
+#define sinf sin
+#define sqrtf sqrt
+#define tanf tan
+
+#ifdef __mips__
+#define QUAKE_BIG_ENDIAN
+#else
+# ifdef __power__
+# define QUAKE_BIG_ENDIAN
+# else
+# ifdef __power64__
+# define QUAKE_BIG_ENDIAN
+# else
+# ifdef __sparc__
+# define QUAKE_BIG_ENDIAN
+# else
+# ifdef __sparc64__
+# else
+# define QUAKE_LITTLE_ENDIAN
+# endif
+# endif
+# endif
+# endif
+#endif
+
+typedef enum {false, true} bool;
+
+static double ln2c;
+#define exp2(x) (exp((x) * (ln2c ? ln2c : (ln2c = log(2.0)))))
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -140,10 +140,10 @@
a = angles[1]/180 * M_PI;
- xvector[0] = cos(a);
- xvector[1] = sin(a);
- yvector[0] = -sin(a);
- yvector[1] = cos(a);
+ xvector[0] = cosf(a);
+ xvector[1] = sinf(a);
+ yvector[0] = -sinf(a);
+ yvector[1] = cosf(a);
VectorCopy (min, bounds[0]);
VectorCopy (max, bounds[1]);
@@ -343,7 +343,7 @@
a = v[0];
b = v[1];
c = v[2];
- ln = sqrt(a*a + b*b + c*c);
+ ln = sqrtf(a*a + b*b + c*c);
if(ln == 0)
newvalue[0] = newvalue[1] = newvalue[2] = 0;
@@ -373,7 +373,7 @@
a = v[0];
b = v[1];
c = v[2];
- G_FLOAT(pr, OFS_RETURN) = sqrt(a*a + b*b + c*c);
+ G_FLOAT(pr, OFS_RETURN) = sqrtf(a*a + b*b + c*c);
}
/*
@@ -395,7 +395,7 @@
yaw = 0;
else
{
- yaw = atan2(value1[1], value1[0]) * 180.0 / M_PI;
+ yaw = atan2f(value1[1], value1[0]) * 180.0 / M_PI;
if (yaw < 0)
yaw += 360;
}
@@ -430,12 +430,12 @@
}
else
{
- yaw = atan2(value1[1], value1[0]) * 180.0 / M_PI;
+ yaw = atan2f(value1[1], value1[0]) * 180.0 / M_PI;
if (yaw < 0)
yaw += 360;
- forward = sqrt (value1[0]*value1[0] + value1[1]*value1[1]);
- pitch = atan2(value1[2], forward) * 180 / M_PI;
+ forward = sqrtf(value1[0]*value1[0] + value1[1]*value1[1]);
+ pitch = atan2f(value1[2], forward) * 180 / M_PI;
if (pitch < 0)
pitch += 360;
}
@@ -1140,8 +1140,8 @@
yaw = yaw*M_PI*2 / 360;
- move[0] = cos(yaw)*dist;
- move[1] = sin(yaw)*dist;
+ move[0] = cosf(yaw)*dist;
+ move[1] = sinf(yaw)*dist;
move[2] = 0;
// save program state, because SV_movestep may call other progs
@@ -1643,21 +1643,21 @@
};
static void
-PF_sin(pr_t *pr)
+PF_sinf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = sin(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = sinf(G_FLOAT(pr, OFS_PARM0));
}
static void
-PF_cos(pr_t *pr)
+PF_cosf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = cos(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = cosf(G_FLOAT(pr, OFS_PARM0));
}
static void
-PF_sqrt(pr_t *pr)
+PF_sqrtf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = sqrt(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = sqrtf(G_FLOAT(pr, OFS_PARM0));
}
static void
@@ -1753,33 +1753,33 @@
}
static void
-PF_asin(pr_t *pr)
+PF_asinf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = asin(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = asinf(G_FLOAT(pr, OFS_PARM0));
}
static void
-PF_acos(pr_t *pr)
+PF_acosf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = acos(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = acosf(G_FLOAT(pr, OFS_PARM0));
}
static void
-PF_atan(pr_t *pr)
+PF_atanf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = atan(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = atanf(G_FLOAT(pr, OFS_PARM0));
}
static void
-PF_atan2(pr_t *pr)
+PF_atan2f(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = atan2(G_FLOAT(pr, OFS_PARM0), G_FLOAT(pr, OFS_PARM1));
+ G_FLOAT(pr, OFS_RETURN) = atan2f(G_FLOAT(pr, OFS_PARM0), G_FLOAT(pr, OFS_PARM1));
}
static void
-PF_tan(pr_t *pr)
+PF_tanf(pr_t *pr)
{
- G_FLOAT(pr, OFS_RETURN) = tan(G_FLOAT(pr, OFS_PARM0));
+ G_FLOAT(pr, OFS_RETURN) = tanf(G_FLOAT(pr, OFS_PARM0));
}
static void
@@ -1874,9 +1874,9 @@
PF_WriteString,
PF_WriteEntity,
-[60] = PF_sin,
-[61] = PF_cos,
-[62] = PF_sqrt,
+[60] = PF_sinf,
+[61] = PF_cosf,
+[62] = PF_sqrtf,
PF_Fixme,
PF_Fixme,
PF_Fixme,
@@ -1909,11 +1909,11 @@
[440] = PF_clientcommand,
[441] = PF_tokenize,
[442] = PF_argv,
-[471] = PF_asin,
-[472] = PF_acos,
-[473] = PF_atan,
-[474] = PF_atan2,
-[475] = PF_tan,
+[471] = PF_asinf,
+[472] = PF_acosf,
+[473] = PF_atanf,
+[474] = PF_atan2f,
+[475] = PF_tanf,
[514] = PF_tokenize, /* FIXME(sigrid): strictly speaking, this is supposed to be "tokenize_console" */
};
--- a/quakedef.h
+++ b/quakedef.h
@@ -1,14 +1,6 @@
#pragma once
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#ifdef __plan9__
-typedef enum {false, true} bool;
-#define RAND_MAX ((2<<15)-1)
-#endif
+#include "platform.h"
#define QUAKE_GAME // as opposed to utilities
#define VERSION 1.09
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -76,8 +76,8 @@
// yaw
angle = currententity->angles[YAW];
angle = angle * M_PI*2 / 360;
- s = sin(angle);
- c = cos(angle);
+ s = sinf(angle);
+ c = cosf(angle);
temp1[0][0] = c;
temp1[0][1] = s;
@@ -93,8 +93,8 @@
// pitch
angle = currententity->angles[PITCH];
angle = angle * M_PI*2 / 360;
- s = sin(angle);
- c = cos(angle);
+ s = sinf(angle);
+ c = cosf(angle);
temp2[0][0] = c;
temp2[0][1] = 0;
@@ -111,8 +111,8 @@
// roll
angle = currententity->angles[ROLL];
angle = angle * M_PI*2 / 360;
- s = sin(angle);
- c = cos(angle);
+ s = sinf(angle);
+ c = cosf(angle);
temp1[0][0] = 1;
temp1[0][1] = 0;
--- a/r_fog.c
+++ b/r_fog.c
@@ -7,11 +7,6 @@
pixel_t color;
}r_fog;
-#ifdef __plan9__
-static double ln2c;
-#define exp2(x) (exp((x) * (ln2c ? ln2c : (ln2c = log(2.0)))))
-#endif
-
static void
fog(void)
{
--- a/r_main.c
+++ b/r_main.c
@@ -267,7 +267,7 @@
if(ow != r_refdef.vrect.width || oh != r_refdef.vrect.height)
vid.recalc_refdef = true;
- r_refdef.horizontalFieldOfView = 2.0 * tan (r_refdef.fov_x/360*M_PI);
+ r_refdef.horizontalFieldOfView = 2.0 * tanf(r_refdef.fov_x/360*M_PI);
r_refdef.fvrectx = (float)r_refdef.vrect.x;
r_refdef.fvrectx_adj = (float)r_refdef.vrect.x - 0.5;
r_refdef.vrect_x_adj_shift20 = (r_refdef.vrect.x<<20) + (1<<19) - 1;
@@ -353,7 +353,7 @@
for (i=0 ; i<4 ; i++)
VectorNormalize (screenedge[i].normal);
- res_scale = sqrt ((double)(r_refdef.vrect.width * r_refdef.vrect.height) /
+ res_scale = sqrtf((float)(r_refdef.vrect.width * r_refdef.vrect.height) /
(320.0 * 152.0)) *
(2.0 / r_refdef.horizontalFieldOfView);
r_aliastransition = r_aliastransbase.value * res_scale;
@@ -756,8 +756,8 @@
int i;
for(i = 0; i < SIN_BUFFER_SIZE; i++){
- sintable[i] = AMP + sin(i*M_PI*2/CYCLE)*AMP;
- intsintable[i] = AMP2 + sin(i*M_PI*2/CYCLE)*AMP2; // AMP2, not 20
+ sintable[i] = AMP + sinf(i*M_PI*2/CYCLE)*AMP;
+ intsintable[i] = AMP2 + sinf(i*M_PI*2/CYCLE)*AMP2; // AMP2, not 20
}
}
--- a/r_part.c
+++ b/r_part.c
@@ -55,11 +55,11 @@
for (i=0 ; i<NUMVERTEXNORMALS ; i++)
{
angle = cl.time * avelocities[i][0];
- sy = sin(angle);
- cy = cos(angle);
+ sy = sinf(angle);
+ cy = cosf(angle);
angle = cl.time * avelocities[i][1];
- sp = sin(angle);
- cp = cos(angle);
+ sp = sinf(angle);
+ cp = cosf(angle);
forward[0] = cp*cy;
forward[1] = cp*sy;
--- a/r_sprite.c
+++ b/r_sprite.c
@@ -290,7 +290,7 @@
VectorNormalize (tvec);
dot = tvec[2]; // same as DotProduct (tvec, r_spritedesc.vup) because
// r_spritedesc.vup is 0, 0, 1
- if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree) = 0.999848
+ if ((dot > 0.999848) || (dot < -0.999848)) // cosf(1 degree) = 0.999848
return;
r_spritedesc.vup[0] = 0;
r_spritedesc.vup[1] = 0;
@@ -329,7 +329,7 @@
// the two vectors are less than 1 degree apart
dot = vpn[2]; // same as DotProduct (vpn, r_spritedesc.vup) because
// r_spritedesc.vup is 0, 0, 1
- if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree) = 0.999848
+ if ((dot > 0.999848) || (dot < -0.999848)) // cosf(1 degree) = 0.999848
return;
r_spritedesc.vup[0] = 0;
r_spritedesc.vup[1] = 0;
@@ -357,8 +357,8 @@
// that plane around the center according to the sprite entity's roll
// angle. So vpn stays the same, but vright and vup rotate
angle = currententity->angles[ROLL] * (M_PI*2 / 360);
- sr = sin(angle);
- cr = cos(angle);
+ sr = sinf(angle);
+ cr = cosf(angle);
for (i=0 ; i<3 ; i++)
{
--- a/screen.c
+++ b/screen.c
@@ -159,9 +159,9 @@
float v;
fov = clamp(fov, 1, 179);
- v = a / tan(fov / 360 * M_PI);
+ v = a / tanf(fov / 360 * M_PI);
- return atan(b / v) * 360.0 / M_PI;
+ return atanf(b / v) * 360.0 / M_PI;
}
/*
--- a/softfloat.c
+++ b/softfloat.c
@@ -36,11 +36,7 @@
#include "quakedef.h"
#include "softfloat.h"
-#ifndef UINT64_C
-#define UINT64_C(x) x##ULL
-#endif
-
-#if BYTE_ORDER == LITTLE_ENDIAN
+#ifdef QUAKE_LITTLE_ENDIAN
struct uint128 { u64int v0, v64; };
struct uint64_extra { u64int extra, v; };
#define wordIncr 1
@@ -77,7 +73,7 @@
*----------------------------------------------------------------------------*/
struct commonNaN {
bool sign;
-#if BYTE_ORDER == LITTLE_ENDIAN
+#ifdef QUAKE_LITTLE_ENDIAN
u64int v0, v64;
#else
u64int v64, v0;
@@ -135,7 +131,7 @@
| The bit pattern for a default generated 80-bit extended floating-point NaN.
*----------------------------------------------------------------------------*/
#define defaultNaNExtF80UI64 0xFFFF
-#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
+#define defaultNaNExtF80UI0 0xC000000000000000ULL
/*----------------------------------------------------------------------------
| Returns true when the 80-bit unsigned integer formed from concatenating
@@ -143,7 +139,7 @@
| floating-point signaling NaN.
| Note: This macro evaluates its arguments more than once.
*----------------------------------------------------------------------------*/
-#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
+#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & 0x4000000000000000ULL ) && ((uiA0) & 0x3FFFFFFFFFFFFFFFULL ))
#define signF32UI( a ) ((bool) ((u32int) (a)>>31))
#define expF32UI( a ) ((s16int) ((a)>>23) & 0xFF)
@@ -161,16 +157,16 @@
#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
#define packToExtF80UI64( sign, exp ) ((u16int) (sign)<<15 | (exp))
-#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
+#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & 0x7FFFFFFFFFFFFFFFULL ))
struct exp32_sig64 { s32int exp; u64int sig; };
#define signF128UI64( a64 ) ((bool) ((u64int) (a64)>>63))
#define expF128UI64( a64 ) ((s32int) ((a64)>>48) & 0x7FFF)
-#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
+#define fracF128UI64( a64 ) ((a64) & 0x0000FFFFFFFFFFFFULL )
#define packToF128UI64( sign, exp, sig64 ) (((u64int) (sign)<<63) + ((u64int) (exp)<<48) + (sig64))
-#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
+#define isNaNF128UI( a64, a0 ) (((~(a64) & 0x7FFF000000000000ULL ) == 0) && (a0 || ((a64) & 0x0000FFFFFFFFFFFFULL )))
struct exp32_sig128 { s32int exp; struct uint128 sig; };
@@ -194,8 +190,8 @@
if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
uiA0 = aSPtr->signif;
return
- ! (uiA0 & UINT64_C( 0x4000000000000000 ))
- && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
+ ! (uiA0 & 0x4000000000000000ULL )
+ && (uiA0 & 0x3FFFFFFFFFFFFFFFULL );
}
@@ -209,7 +205,7 @@
{
zSPtr->signExp = packToExtF80UI64( aPtr->sign, 0x7FFF );
- zSPtr->signif = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
+ zSPtr->signif = 0xC000000000000000ULL | aPtr->v64>>1;
}
@@ -323,7 +319,7 @@
sPtr = bSPtr;
copy:
zSPtr->signExp = sPtr->signExp;
- zSPtr->signif = sPtr->signif | UINT64_C( 0xC000000000000000 );
+ zSPtr->signif = sPtr->signif | 0xC000000000000000ULL;
}
@@ -356,8 +352,8 @@
/*------------------------------------------------------------------------
| Make NaNs non-signaling.
*------------------------------------------------------------------------*/
- uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
- uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
+ uiNonsigA0 = uiA0 | 0xC000000000000000ULL;
+ uiNonsigB0 = uiB0 | 0xC000000000000000ULL;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( isSigNaNA | isSigNaNB ) {
@@ -698,11 +694,11 @@
roundNearEven = (roundingMode == softfloat_round_near_even);
if ( roundingPrecision == 80 ) goto precision80;
if ( roundingPrecision == 64 ) {
- roundIncrement = UINT64_C( 0x0000000000000400 );
- roundMask = UINT64_C( 0x00000000000007FF );
+ roundIncrement = 0x0000000000000400ULL;
+ roundMask = 0x00000000000007FFULL;
} else if ( roundingPrecision == 32 ) {
- roundIncrement = UINT64_C( 0x0000008000000000 );
- roundMask = UINT64_C( 0x000000FFFFFFFFFF );
+ roundIncrement = 0x0000008000000000ULL;
+ roundMask = 0x000000FFFFFFFFFFULL;
} else {
goto precision80;
}
@@ -733,7 +729,7 @@
softfloat_exceptionFlags |= softfloat_flag_inexact;
}
sig += roundIncrement;
- exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
+ exp = ((sig & 0x8000000000000000ULL) != 0);
roundIncrement = roundMask + 1;
if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
roundMask |= roundIncrement;
@@ -756,7 +752,7 @@
sig = (u64int) (sig + roundIncrement);
if ( sig < roundIncrement ) {
++exp;
- sig = UINT64_C( 0x8000000000000000 );
+ sig = 0x8000000000000000ULL;
}
roundIncrement = roundMask + 1;
if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
@@ -767,7 +763,7 @@
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
precision80:
- doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
+ doIncrement = (0x8000000000000000ULL <= sigExtra);
if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
doIncrement =
(roundingMode
@@ -785,7 +781,7 @@
== softfloat_tininess_beforeRounding)
|| (exp < 0)
|| ! doIncrement
- || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
+ || (sig < 0xFFFFFFFFFFFFFFFFULL);
sig64Extra =
softfloat_shiftRightJam64Extra( sig, sigExtra, 1 - exp );
exp = 0;
@@ -795,7 +791,7 @@
if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
softfloat_exceptionFlags |= softfloat_flag_inexact;
}
- doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
+ doIncrement = (0x8000000000000000ULL <= sigExtra);
if (
! roundNearEven
&& (roundingMode != softfloat_round_near_maxMag)
@@ -809,15 +805,15 @@
++sig;
sig &=
~(u64int)
- (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ (! (sigExtra & 0x7FFFFFFFFFFFFFFFULL)
& roundNearEven);
- exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
+ exp = ((sig & 0x8000000000000000ULL) != 0);
}
goto packReturn;
}
if (
(0x7FFE < exp)
- || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
+ || ((exp == 0x7FFE) && (sig == 0xFFFFFFFFFFFFFFFFULL)
&& doIncrement)
) {
/*----------------------------------------------------------------
@@ -833,7 +829,7 @@
== (sign ? softfloat_round_min : softfloat_round_max))
) {
exp = 0x7FFF;
- sig = UINT64_C( 0x8000000000000000 );
+ sig = 0x8000000000000000ULL;
} else {
exp = 0x7FFE;
sig = ~roundMask;
@@ -850,11 +846,11 @@
++sig;
if ( ! sig ) {
++exp;
- sig = UINT64_C( 0x8000000000000000 );
+ sig = 0x8000000000000000ULL;
} else {
sig &=
~(u64int)
- (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ (! (sigExtra & 0x7FFFFFFFFFFFFFFFULL)
& roundNearEven);
}
}
@@ -930,7 +926,7 @@
if ( 0 < expDiff ) goto expABigger;
if ( expDiff < 0 ) goto expBBigger;
if ( expA == 0x7FFF ) {
- if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ if ( (sigA | sigB) & 0x7FFFFFFFFFFFFFFFULL ) {
goto propagateNaN;
}
softfloat_raiseFlags( softfloat_flag_invalid );
@@ -953,9 +949,9 @@
*------------------------------------------------------------------------*/
expBBigger:
if ( expB == 0x7FFF ) {
- if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ if ( sigB & 0x7FFFFFFFFFFFFFFFULL ) goto propagateNaN;
uiZ64 = packToExtF80UI64( signZ ^ 1, 0x7FFF );
- uiZ0 = UINT64_C( 0x8000000000000000 );
+ uiZ0 = 0x8000000000000000ULL;
goto uiZ;
}
if ( ! expA ) {
@@ -976,7 +972,7 @@
*------------------------------------------------------------------------*/
expABigger:
if ( expA == 0x7FFF ) {
- if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ if ( sigA & 0x7FFFFFFFFFFFFFFFULL ) goto propagateNaN;
uiZ64 = uiA64;
uiZ0 = uiA0;
goto uiZ;
@@ -1045,7 +1041,7 @@
expDiff = expA - expB;
if ( ! expDiff ) {
if ( expA == 0x7FFF ) {
- if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ if ( (sigA | sigB) & 0x7FFFFFFFFFFFFFFFULL ) {
goto propagateNaN;
}
uiZ64 = uiA64;
@@ -1067,7 +1063,7 @@
*------------------------------------------------------------------------*/
if ( expDiff < 0 ) {
if ( expB == 0x7FFF ) {
- if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ if ( sigB & 0x7FFFFFFFFFFFFFFFULL ) goto propagateNaN;
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
uiZ0 = uiB0;
goto uiZ;
@@ -1083,7 +1079,7 @@
sigZExtra = sig64Extra.extra;
} else {
if ( expA == 0x7FFF ) {
- if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ if ( sigA & 0x7FFFFFFFFFFFFFFFULL ) goto propagateNaN;
uiZ64 = uiA64;
uiZ0 = uiA0;
goto uiZ;
@@ -1100,12 +1096,12 @@
}
newlyAligned:
sigZ = sigA + sigB;
- if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto roundAndPack;
+ if ( sigZ & 0x8000000000000000ULL ) goto roundAndPack;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
shiftRight1:
sig64Extra = softfloat_shortShiftRightJam64Extra( sigZ, sigZExtra, 1 );
- sigZ = sig64Extra.v | UINT64_C( 0x8000000000000000 );
+ sigZ = sig64Extra.v | 0x8000000000000000ULL;
sigZExtra = sig64Extra.extra;
++expZ;
roundAndPack:
@@ -1330,11 +1326,11 @@
| extSigPtr[indexWord( 3, 1 )];
if ( roundingPrecision == 80 ) goto precision80;
if ( roundingPrecision == 64 ) {
- roundIncrement = UINT64_C( 0x0000000000000400 );
- roundMask = UINT64_C( 0x00000000000007FF );
+ roundIncrement = 0x0000000000000400ULL;
+ roundMask = 0x00000000000007FFULL;
} else if ( roundingPrecision == 32 ) {
- roundIncrement = UINT64_C( 0x0000008000000000 );
- roundMask = UINT64_C( 0x000000FFFFFFFFFF );
+ roundIncrement = 0x0000008000000000ULL;
+ roundMask = 0x000000FFFFFFFFFFULL;
} else {
goto precision80;
}
@@ -1367,7 +1363,7 @@
softfloat_exceptionFlags |= softfloat_flag_inexact;
}
sig += roundIncrement;
- exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
+ exp = ((sig & 0x8000000000000000ULL) != 0);
roundIncrement = roundMask + 1;
if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
roundMask |= roundIncrement;
@@ -1390,7 +1386,7 @@
sig += roundIncrement;
if ( sig < roundIncrement ) {
++exp;
- sig = UINT64_C( 0x8000000000000000 );
+ sig = 0x8000000000000000ULL;
}
roundIncrement = roundMask + 1;
if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
@@ -1420,7 +1416,7 @@
== softfloat_tininess_beforeRounding)
|| (exp < 0)
|| ! doIncrement
- || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
+ || (sig < 0xFFFFFFFFFFFFFFFFULL);
softfloat_shiftRightJam96M( extSigPtr, 1 - exp, extSigPtr );
exp = 0;
sig =
@@ -1444,13 +1440,13 @@
if ( doIncrement ) {
++sig;
sig &= ~(u64int) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
- exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
+ exp = ((sig & 0x8000000000000000ULL) != 0);
}
goto packReturn;
}
if (
(0x7FFE < exp)
- || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
+ || ((exp == 0x7FFE) && (sig == 0xFFFFFFFFFFFFFFFFULL)
&& doIncrement)
) {
/*----------------------------------------------------------------
@@ -1466,7 +1462,7 @@
== (sign ? softfloat_round_min : softfloat_round_max))
) {
exp = 0x7FFF;
- sig = UINT64_C( 0x8000000000000000 );
+ sig = 0x8000000000000000ULL;
} else {
exp = 0x7FFE;
sig = ~roundMask;
@@ -1483,7 +1479,7 @@
++sig;
if ( ! sig ) {
++exp;
- sig = UINT64_C( 0x8000000000000000 );
+ sig = 0x8000000000000000ULL;
} else {
sig &= ~(u64int) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
}
@@ -1576,7 +1572,7 @@
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
- if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ if ( sig & 0x7FFFFFFFFFFFFFFFULL ) {
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
} else {
@@ -1586,7 +1582,7 @@
}
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
+ if ( ! (sig & 0x8000000000000000ULL ) ) {
if ( ! sig ) {
uiZ = packToF32UI( sign, 0, 0 );
goto uiZ;
@@ -1676,7 +1672,7 @@
return;
}
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
- uiZ0 = UINT64_C( 0x8000000000000000 );
+ uiZ0 = 0x8000000000000000ULL;
goto uiZ;
}
/*------------------------------------------------------------------------
@@ -1683,13 +1679,13 @@
*------------------------------------------------------------------------*/
if ( ! expA ) expA = 1;
sigA = aSPtr->signif;
- if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
+ if ( ! (sigA & 0x8000000000000000ULL ) ) {
if ( ! sigA ) goto zero;
expA += softfloat_normExtF80SigM( &sigA );
}
if ( ! expB ) expB = 1;
sigB = bSPtr->signif;
- if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
+ if ( ! (sigB & 0x8000000000000000ULL ) ) {
if ( ! sigB ) goto zero;
expB += softfloat_normExtF80SigM( &sigB );
}
--- a/softfloat.h
+++ b/softfloat.h
@@ -38,26 +38,7 @@
typedef struct extFloat80M extFloat80_t;
typedef float float32_t;
-#ifdef __plan9__
-#define LITTLE_ENDIAN 1234
-#define BIG_ENDIAN 4321
-#if defined(__mips__) || \
- defined(__power__) || defined(__power64__) || \
- defined(__sparc__) || defined(__sparc64__)
-#define BYTE_ORDER BIG_ENDIAN
-#else
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#else
-#include <endian.h>
-#ifndef BYTE_ORDER
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-#endif
-#endif
-
-#if BYTE_ORDER == LITTLE_ENDIAN
+#ifdef QUAKE_LITTLE_ENDIAN
struct extFloat80M { u64int signif; u16int signExp; };
#else
struct extFloat80M { u16int signExp; u64int signif; };
--- a/sv_move.c
+++ b/sv_move.c
@@ -212,8 +212,8 @@
PF_changeyaw(sv.pr);
yaw = yaw*M_PI*2 / 360;
- move[0] = cos(yaw)*dist;
- move[1] = sin(yaw)*dist;
+ move[0] = cosf(yaw)*dist;
+ move[1] = sinf(yaw)*dist;
move[2] = 0;
VectorCopy (ent->v.origin, oldorigin);
--- a/sv_user.c
+++ b/sv_user.c
@@ -44,8 +44,8 @@
return;
angleval = sv_player->v.angles[YAW] * M_PI*2 / 360;
- sinval = sin(angleval);
- cosval = cos(angleval);
+ sinval = sinf(angleval);
+ cosval = cosf(angleval);
for (i=0 ; i<MAX_FORWARD ; i++)
{
@@ -110,7 +110,7 @@
vel = velocity;
- speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1]);
+ speed = sqrtf(vel[0]*vel[0] +vel[1]*vel[1]);
if (!speed)
return;
--- /dev/null
+++ b/unix/platform.h
@@ -1,0 +1,61 @@
+#include <assert.h>
+#include <ctype.h>
+#include <endian.h>
+#include <fcntl.h>
+#include <math.h>
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+typedef unsigned char uchar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef int8_t s8int;
+typedef uint8_t u8int;
+typedef int16_t s16int;
+typedef uint16_t u16int;
+typedef int32_t s32int;
+typedef uint32_t u32int;
+typedef int64_t s64int;
+typedef uint64_t u64int;
+typedef intptr_t intptr;
+typedef uintptr_t uintptr;
+
+#define nil NULL
+#define USED(x) (void)(x)
+#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
+
+#define sprint sprintf
+#define snprint snprintf
+#define vsnprint vsnprintf
+#define cistrcmp strcasecmp
+#define cistrncmp strncasecmp
+#define getcallerpc(x) nil
+#define getmalloctag(p) (USED(p), 0)
+#define setmalloctag(p, t) do{USED(p); USED(t);}while(0)
+#define setrealloctag(p, t) do{USED(p); USED(t);}while(0)
+
+#ifndef BYTE_ORDER
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+#endif
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define QUAKE_LITTLE_ENDIAN
+#else
+#define QUAKE_BIG_ENDIAN
+#endif
+
+extern char lasterr[256];
+#define werrstr(fmt...) do{snprint(lasterr, sizeof(lasterr), fmt); }while(0)
+
+char *seprint(char *, char *, char *, ...);
+int nrand(int);
--- a/unix/u.h
+++ /dev/null
@@ -1,49 +1,0 @@
-#pragma once
-
-#include <assert.h>
-#include <fcntl.h>
-#include <math.h>
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-typedef unsigned char uchar;
-typedef long long vlong;
-typedef unsigned long long uvlong;
-typedef int8_t s8int;
-typedef uint8_t u8int;
-typedef int16_t s16int;
-typedef uint16_t u16int;
-typedef int32_t s32int;
-typedef uint32_t u32int;
-typedef int64_t s64int;
-typedef uint64_t u64int;
-typedef intptr_t intptr;
-typedef uintptr_t uintptr;
-
-#define nil NULL
-#define USED(x) (void)(x)
-#define nelem(x) (int)(sizeof(x)/sizeof((x)[0]))
-
-#define sprint sprintf
-#define snprint snprintf
-#define vsnprint vsnprintf
-#define cistrcmp strcasecmp
-#define cistrncmp strncasecmp
-#define getcallerpc(x) nil
-#define getmalloctag(p) (USED(p), 0)
-#define setmalloctag(p, t) do{USED(p); USED(t);}while(0)
-#define setrealloctag(p, t) do{USED(p); USED(t);}while(0)
-
-extern char lasterr[256];
-#define werrstr(fmt...) do{snprint(lasterr, sizeof(lasterr), fmt); }while(0)
-
-char *seprint(char *, char *, char *, ...);
-int nrand(int);
--- a/view.c
+++ b/view.c
@@ -104,9 +104,9 @@
// bob is proportional to velocity in the xy plane
// (don't count Z, or jumping messes it up)
- bob = sqrt(cl.velocity[0]*cl.velocity[0] + cl.velocity[1]*cl.velocity[1]) * cl_bob.value;
+ bob = sqrtf(cl.velocity[0]*cl.velocity[0] + cl.velocity[1]*cl.velocity[1]) * cl_bob.value;
//Con_Printf ("speed: %5.1f\n", Length(cl.velocity));
- bob = bob*0.3 + bob*0.7*sin(cycle);
+ bob = bob*0.3 + bob*0.7*sinf(cycle);
if (bob > 4)
bob = 4;
else if (bob < -7)
@@ -584,9 +584,9 @@
cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw;
cl.viewent.angles[PITCH] = - (r_refdef.viewangles[PITCH] + pitch);
- cl.viewent.angles[ROLL] -= v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
- cl.viewent.angles[PITCH] -= v_idlescale.value * sin(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
- cl.viewent.angles[YAW] -= v_idlescale.value * sin(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
+ cl.viewent.angles[ROLL] -= v_idlescale.value * sinf(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
+ cl.viewent.angles[PITCH] -= v_idlescale.value * sinf(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
+ cl.viewent.angles[YAW] -= v_idlescale.value * sinf(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
}
/*
@@ -626,9 +626,9 @@
*/
void V_AddIdle (void)
{
- r_refdef.viewangles[ROLL] += v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
- r_refdef.viewangles[PITCH] += v_idlescale.value * sin(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
- r_refdef.viewangles[YAW] += v_idlescale.value * sin(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
+ r_refdef.viewangles[ROLL] += v_idlescale.value * sinf(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
+ r_refdef.viewangles[PITCH] += v_idlescale.value * sinf(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
+ r_refdef.viewangles[YAW] += v_idlescale.value * sinf(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
}