aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-04-27 13:39:41 +0000
committerthilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-04-27 13:39:41 +0000
commit55a5e9a51345fadf72f9cd2fb955a713bf27ea2f (patch)
treec9973cc5b00f41b12e3d6e313c4dffd3025daf32 /code
parent4b70806fcb6735314cf79557ce84379fa7542cad (diff)
downloadioquake3-aero-55a5e9a51345fadf72f9cd2fb955a713bf27ea2f.tar.gz
ioquake3-aero-55a5e9a51345fadf72f9cd2fb955a713bf27ea2f.zip
- Introduced various new typedefs for windows platform (int32_t, int64_t, etc...)
- Applied md5 64-bit safety patch by Tony White. git-svn-id: svn://svn.icculus.org/quake3/trunk@727 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/client/cl_main.c3
-rw-r--r--code/qcommon/md4.c43
-rw-r--r--code/qcommon/md5.c36
-rw-r--r--code/qcommon/q_shared.h11
4 files changed, 40 insertions, 53 deletions
diff --git a/code/client/cl_main.c b/code/client/cl_main.c
index b502781..8f9cbae 100644
--- a/code/client/cl_main.c
+++ b/code/client/cl_main.c
@@ -2549,8 +2549,7 @@ void CL_Init( void ) {
Cvar_Set( "cl_running", "1" );
CL_GenerateQKey();
-// Uncomment this once md5.c has been made 64 bit-safe.
-// Cvar_Get("cl_guid", Com_MD5File(QKEY_FILE, 0), CVAR_USERINFO | CVAR_ROM);
+ Cvar_Get("cl_guid", Com_MD5File(QKEY_FILE, 0), CVAR_USERINFO | CVAR_ROM);
Com_Printf( "----- Client Initialization Complete -----\n" );
}
diff --git a/code/qcommon/md4.c b/code/qcommon/md4.c
index 1b491be..2501b2b 100644
--- a/code/qcommon/md4.c
+++ b/code/qcommon/md4.c
@@ -30,21 +30,9 @@
#include "q_shared.h"
#include "qcommon.h"
-#ifndef int32
-#define int32 int
-#endif
-
-#if SIZEOF_INT > 4
-#define LARGE_INT32
-#endif
-
-#ifndef uint32
-#define uint32 unsigned int32
-#endif
-
struct mdfour {
- uint32 A, B, C, D;
- uint32 totalN;
+ uint32_t A, B, C, D;
+ uint32_t totalN;
};
@@ -58,23 +46,19 @@ static struct mdfour *m;
#define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
#define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
#define H(X,Y,Z) ((X)^(Y)^(Z))
-#ifdef LARGE_INT32
-#define lshift(x,s) ((((x)<<(s))&0xFFFFFFFF) | (((x)>>(32-(s)))&0xFFFFFFFF))
-#else
#define lshift(x,s) (((x)<<(s)) | ((x)>>(32-(s))))
-#endif
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,s)
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
/* this applies md4 to 64 byte chunks */
-static void mdfour64(uint32 *M)
+static void mdfour64(uint32_t *M)
{
int j;
- uint32 AA, BB, CC, DD;
- uint32 X[16];
- uint32 A,B,C,D;
+ uint32_t AA, BB, CC, DD;
+ uint32_t X[16];
+ uint32_t A,B,C,D;
for (j=0;j<16;j++)
X[j] = M[j];
@@ -111,18 +95,13 @@ static void mdfour64(uint32 *M)
A += AA; B += BB; C += CC; D += DD;
-#ifdef LARGE_INT32
- A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
- C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
-#endif
-
for (j=0;j<16;j++)
X[j] = 0;
m->A = A; m->B = B; m->C = C; m->D = D;
}
-static void copy64(uint32 *M, byte *in)
+static void copy64(uint32_t *M, byte *in)
{
int i;
@@ -131,7 +110,7 @@ static void copy64(uint32 *M, byte *in)
(in[i*4+1]<<8) | (in[i*4+0]<<0);
}
-static void copy4(byte *out,uint32 x)
+static void copy4(byte *out,uint32_t x)
{
out[0] = x&0xFF;
out[1] = (x>>8)&0xFF;
@@ -152,8 +131,8 @@ void mdfour_begin(struct mdfour *md)
static void mdfour_tail(byte *in, int n)
{
byte buf[128];
- uint32 M[16];
- uint32 b;
+ uint32_t M[16];
+ uint32_t b;
m->totalN += n;
@@ -178,7 +157,7 @@ static void mdfour_tail(byte *in, int n)
static void mdfour_update(struct mdfour *md, byte *in, int n)
{
- uint32 M[16];
+ uint32_t M[16];
if (n == 0) mdfour_tail(in, n);
diff --git a/code/qcommon/md5.c b/code/qcommon/md5.c
index 452d4ff..ffe7752 100644
--- a/code/qcommon/md5.c
+++ b/code/qcommon/md5.c
@@ -18,8 +18,8 @@
#include "qcommon.h"
typedef struct MD5Context {
- unsigned long int buf[4];
- unsigned long int bits[2];
+ uint32_t buf[4];
+ uint32_t bits[2];
unsigned char in[64];
} MD5_CTX;
@@ -33,12 +33,12 @@ typedef struct MD5Context {
*/
static void byteReverse(unsigned char *buf, unsigned longs)
{
- unsigned long int t;
+ uint32_t t;
do {
- t = (unsigned long int)
+ t = (uint32_t)
((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
- *(unsigned long int *) buf = t;
+ *(uint32_t *) buf = t;
buf += 4;
} while (--longs);
}
@@ -75,10 +75,10 @@ static void MD5Init(struct MD5Context *ctx)
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
-static void MD5Transform(unsigned long int buf[4],
- unsigned long int const in[16])
+static void MD5Transform(uint32_t buf[4],
+ uint32_t const in[16])
{
- register unsigned long int a, b, c, d;
+ register uint32_t a, b, c, d;
a = buf[0];
b = buf[1];
@@ -166,12 +166,12 @@ static void MD5Transform(unsigned long int buf[4],
static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
unsigned len)
{
- register unsigned long int t;
+ uint32_t t;
/* Update bitcount */
t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((unsigned long int) len << 3)) < t)
+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
@@ -189,7 +189,7 @@ static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += t;
len -= t;
}
@@ -198,7 +198,7 @@ static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
buf += 64;
len -= 64;
}
@@ -215,7 +215,7 @@ static void MD5Update(struct MD5Context *ctx, unsigned char const *buf,
*/
static void MD5Final(struct MD5Context *ctx, unsigned char *digest)
{
- unsigned long int count;
+ unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
@@ -234,7 +234,7 @@ static void MD5Final(struct MD5Context *ctx, unsigned char *digest)
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
@@ -245,15 +245,15 @@ static void MD5Final(struct MD5Context *ctx, unsigned char *digest)
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
- ((unsigned long int *) ctx->in)[14] = ctx->bits[0];
- ((unsigned long int *) ctx->in)[15] = ctx->bits[1];
+ ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+ ((uint32_t *) ctx->in)[15] = ctx->bits[1];
- MD5Transform(ctx->buf, (unsigned long int *) ctx->in);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
if (digest!=NULL)
memcpy(digest, ctx->buf, 16);
- //memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h
index f66ab23..3fc713d 100644
--- a/code/qcommon/q_shared.h
+++ b/code/qcommon/q_shared.h
@@ -109,10 +109,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//=============================================================
#ifdef Q3_VM
-typedef int intptr_t;
+ typedef int intptr_t;
#else
# ifndef _MSC_VER
# include <stdint.h>
+# else
+ typedef __int64 int64_t;
+ typedef __int32 int32_t;
+ typedef __int16 int16_t;
+ typedef __int8 int8_t;
+ typedef unsigned __int64 uint64_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int8 uint8_t;
# endif
#endif