]> granicus.if.org Git - php/commitdiff
- use php_hash_* types
authorMichael Wallner <mike@php.net>
Sat, 26 Nov 2005 13:15:06 +0000 (13:15 +0000)
committerMichael Wallner <mike@php.net>
Sat, 26 Nov 2005 13:15:06 +0000 (13:15 +0000)
# ok with everybody?

28 files changed:
ext/hash/config.m4
ext/hash/hash_adler32.c
ext/hash/hash_gost.c
ext/hash/hash_haval.c
ext/hash/hash_md.c
ext/hash/hash_ripemd.c
ext/hash/hash_salsa.c
ext/hash/hash_sha.c
ext/hash/hash_snefru.c
ext/hash/hash_tiger.c
ext/hash/hash_whirlpool.c
ext/hash/package.xml
ext/hash/php_hash.h
ext/hash/php_hash_adler32.h
ext/hash/php_hash_crc32.h
ext/hash/php_hash_crc32_tables.h
ext/hash/php_hash_gost.h
ext/hash/php_hash_gost_tables.h
ext/hash/php_hash_haval.h
ext/hash/php_hash_md.h
ext/hash/php_hash_ripemd.h
ext/hash/php_hash_salsa.h
ext/hash/php_hash_sha.h
ext/hash/php_hash_snefru.h
ext/hash/php_hash_snefru_tables.h
ext/hash/php_hash_tiger.h
ext/hash/php_hash_types.h [new file with mode: 0644]
ext/hash/php_hash_whirlpool.h

index ba67f6ecd8a058a74c1110903f13fdf35665354a..9371ce04b9ee4341dc2974ebd5041a17baf85f03 100644 (file)
@@ -6,13 +6,18 @@ PHP_ARG_ENABLE(hash, whether to enable hash support,
 
 if test "$PHP_HASH" != "no"; then
   AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension])
+
+  AC_CHECK_SIZEOF(short, 2)
+  AC_CHECK_SIZEOF(int, 4)
+  AC_CHECK_SIZEOF(long, 4)
+  AC_CHECK_SIZEOF(long long, 8)
   
   EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
     hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \
     hash_crc32.c"
   EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
     php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
-    php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h"
+    php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h php_hash_types.h"
   
   PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared)
   ifdef([PHP_INSTALL_HEADERS], [
index 368305576ae05ba9f9899b2e37f4b00e372c7f92..48b2c873d91da979d62f8ffd355d5076e1e76648 100644 (file)
@@ -29,7 +29,7 @@ PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context)
 
 PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
 {
-       php_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff };
+       php_hash_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff };
        
        for (i = 0; i < len; ++i) {
                s[0] = (s[0] + input[i]) % 65521;
index 44b1e102556d66e37a72bb3db501b42f5c340a04..e4117d2bcb47524309dc950081773868c04ad509 100644 (file)
                AA(v, l, r); \
        }
 
-static inline void Gost(php_uint32 state[8], php_uint32 data[8])
+static inline void Gost(php_hash_uint32 state[8], php_hash_uint32 data[8])
 {
        int i;
-       php_uint32 l, r, t, key[8], u[8], v[8], w[8], s[8], *h = state, *m = data;
+       php_hash_uint32 l, r, t, key[8], u[8], v[8], w[8], s[8], *h = state, *m = data;
        
        memcpy(u, state, sizeof(u));
        memcpy(v, data, sizeof(v));
@@ -227,11 +227,11 @@ static inline void Gost(php_uint32 state[8], php_uint32 data[8])
 static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32])
 {
        int i, j;
-       php_uint32 data[8], temp = 0, save = 0;
+       php_hash_uint32 data[8], temp = 0, save = 0;
        
        for (i = 0, j = 0; i < 8; ++i, j += 4) {
-               data[i] =       ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) | 
-                                       (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24);
+               data[i] =       ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) | 
+                                       (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
                save = context->state[i + 8];
                context->state[i + 8] += data[i] + temp;
                temp = ((context->state[i + 8] < data[i]) || (context->state[i + 8] < save)) ? 1 : 0;     
@@ -245,7 +245,7 @@ PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context)
        memset(context, 0, sizeof(*context));
 }
 
-static const php_uint32 MAX32 = 0xffffffffLU;
+static const php_hash_uint32 MAX32 = 0xffffffffLU;
 
 PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len)
 {
@@ -281,7 +281,7 @@ PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *inp
 
 PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context)
 {
-       php_uint32 i, j, l[8] = {0};
+       php_hash_uint32 i, j, l[8] = {0};
        
        if (context->length) {
                GostTransform(context, context->buffer);
index e31e27c9b7dc644b478de24f31848882b089685e..0ff42e74e59aa0d943eec8714b338988a9f366ed 100644 (file)
@@ -31,28 +31,28 @@ static unsigned char PADDING[128] ={
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-static php_uint32 D0[8] = {
+static php_hash_uint32 D0[8] = {
        0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89 };
 
-static php_uint32 K2[32] = {
+static php_hash_uint32 K2[32] = {
        0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
        0x9216D5D9, 0x8979FB1B, 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96,
        0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16, 0x636920D8, 0x71574E69,
        0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE, 0x7B54A41D, 0xC25A59B5 };
 
-static php_uint32 K3[32] = {
+static php_hash_uint32 K3[32] = {
        0x9C30D539, 0x2AF26013, 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, 0x8E79DCB0, 0x603A180E,
        0x6C9E0E8B, 0xB01E8A3E, 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60, 0xE65525F3, 0xAA55AB94,
        0x57489862, 0x63E81440, 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE, 0xA15486AF, 0x7C72E993,
        0xB3EE1411, 0x636FBC2A, 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, 0xAFD6BA33, 0x6C24CF5C };
 
-static php_uint32 K4[32] = {
+static php_hash_uint32 K4[32] = {
        0x7A325381, 0x28958677, 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193, 0x61D809CC, 0xFB21A991,
        0x487CAC60, 0x5DEC8032, 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88, 0x23893E81, 0xD396ACC5,
        0x0F6D6FF3, 0x83F44239, 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E, 0x21C66842, 0xF6E96C9A,
        0x670C9C61, 0xABD388F0, 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3, 0x6EEF0B6C, 0x137A3BE4 };
 
-static php_uint32 K5[32] = {
+static php_hash_uint32 K5[32] = {
        0xBA3BF050, 0x7EFB2A98, 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88, 0x8CEE8619, 0x456F9FB4,
        0x7D84A5C3, 0x3B8B5EBE, 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6, 0x4ED3AA62, 0x363F7706,
        0x1BFEDF72, 0x429B023D, 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B, 0x075372C9, 0x80991B7B,
@@ -95,10 +95,10 @@ static short M7[32] = {     7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0,
                                                7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0 };
 
 /* {{{ Encode
-   Encodes input (php_uint32) into output (unsigned char). Assumes len is
+   Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
    a multiple of 4.
  */
-static void Encode(unsigned char *output, php_uint32 *input, unsigned int len)
+static void Encode(unsigned char *output, php_hash_uint32 *input, unsigned int len)
 {
        unsigned int i, j;
 
@@ -112,16 +112,16 @@ static void Encode(unsigned char *output, php_uint32 *input, unsigned int len)
 /* }}} */
 
 /* {{{ Decode
-   Decodes input (unsigned char) into output (php_uint32). Assumes len is
+   Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
    a multiple of 4.
  */
-static void Decode(php_uint32 *output, const unsigned char *input, unsigned int len)
+static void Decode(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
 {
        unsigned int i, j;
 
        for (i = 0, j = 0; j < len; i++, j += 4) {
-               output[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) |
-                       (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24);
+               output[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) |
+                       (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
        }
 }
 /* }}} */
@@ -141,10 +141,10 @@ static void Decode(php_uint32 *output, const unsigned char *input, unsigned int
 
 /* {{{ PHP_3HAVALTransform
  */
-static void PHP_3HAVALTransform(php_uint32 state[8], const unsigned char block[128])
+static void PHP_3HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128])
 {
-       php_uint32 E[8];
-       php_uint32 x[32];
+       php_hash_uint32 E[8];
+       php_hash_uint32 x[32];
        int i;
 
        Decode(x, block, 128);
@@ -175,10 +175,10 @@ static void PHP_3HAVALTransform(php_uint32 state[8], const unsigned char block[1
 
 /* {{{ PHP_4HAVALTransform
  */
-static void PHP_4HAVALTransform(php_uint32 state[8], const unsigned char block[128])
+static void PHP_4HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128])
 {
-       php_uint32 E[8];
-       php_uint32 x[32];
+       php_hash_uint32 E[8];
+       php_hash_uint32 x[32];
        int i;
 
        Decode(x, block, 128);
@@ -212,10 +212,10 @@ static void PHP_4HAVALTransform(php_uint32 state[8], const unsigned char block[1
 
 /* {{{ PHP_5HAVALTransform
  */
-static void PHP_5HAVALTransform(php_uint32 state[8], const unsigned char block[128])
+static void PHP_5HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128])
 {
-       php_uint32 E[8];
-       php_uint32 x[32];
+       php_hash_uint32 E[8];
+       php_hash_uint32 x[32];
        int i;
 
        Decode(x, block, 128);
@@ -288,10 +288,10 @@ PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *context, const unsigned char *i
        /* Compute number of bytes mod 128 */
        index = (unsigned int) ((context->count[0] >> 3) & 0x7F);
        /* Update number of bits */
-       if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) {
+       if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
                context->count[1]++;
        }
-       context->count[1] += ((php_uint32) inputLen >> 29);
+       context->count[1] += ((php_hash_uint32) inputLen >> 29);
 
        partLen = 128 - index;
 
index 2270b3fd2d9af93c99c6a928d77569713e5adade..a4f29d6e8a8f2598fe5d85e1183d62ba35b75d6b 100644 (file)
@@ -162,9 +162,9 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
 #define S43 15
 #define S44 21
 
-static void MD5Transform(php_uint32[4], const unsigned char[64]);
-static void Encode(unsigned char *, php_uint32 *, unsigned int);
-static void Decode(php_uint32 *, const unsigned char *, unsigned int);
+static void MD5Transform(php_hash_uint32[4], const unsigned char[64]);
+static void Encode(unsigned char *, php_hash_uint32 *, unsigned int);
+static void Decode(php_hash_uint32 *, const unsigned char *, unsigned int);
 
 static unsigned char PADDING[64] =
 {
@@ -188,22 +188,22 @@ static unsigned char PADDING[64] =
    Rotation is separate from addition to prevent recomputation.
  */
 #define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (php_uint32)(ac); \
+ (a) += F ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
  (a) = ROTATE_LEFT ((a), (s)); \
  (a) += (b); \
   }
 #define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (php_uint32)(ac); \
+ (a) += G ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
  (a) = ROTATE_LEFT ((a), (s)); \
  (a) += (b); \
   }
 #define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (php_uint32)(ac); \
+ (a) += H ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
  (a) = ROTATE_LEFT ((a), (s)); \
  (a) += (b); \
   }
 #define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (php_uint32)(ac); \
+ (a) += I ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
  (a) = ROTATE_LEFT ((a), (s)); \
  (a) += (b); \
   }
@@ -237,10 +237,10 @@ PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *inpu
        index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
 
        /* Update number of bits */
-       if ((context->count[0] += ((php_uint32) inputLen << 3))
-               < ((php_uint32) inputLen << 3))
+       if ((context->count[0] += ((php_hash_uint32) inputLen << 3))
+               < ((php_hash_uint32) inputLen << 3))
                context->count[1]++;
-       context->count[1] += ((php_uint32) inputLen >> 29);
+       context->count[1] += ((php_hash_uint32) inputLen >> 29);
 
        partLen = 64 - index;
 
@@ -299,10 +299,10 @@ PHP_HASH_API void PHP_MD5Final(unsigned char digest[16], PHP_MD5_CTX * context)
  * MD5 basic transformation. Transforms state based on block.
  */
 static void MD5Transform(state, block)
-php_uint32 state[4];
+php_hash_uint32 state[4];
 const unsigned char block[64];
 {
-       php_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+       php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
 
        Decode(x, block, 64);
 
@@ -389,12 +389,12 @@ const unsigned char block[64];
 /* }}} */
 
 /* {{{ Encode
-   Encodes input (php_uint32) into output (unsigned char). Assumes len is
+   Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
    a multiple of 4.
  */
 static void Encode(output, input, len)
 unsigned char *output;
-php_uint32 *input;
+php_hash_uint32 *input;
 unsigned int len;
 {
        unsigned int i, j;
@@ -409,19 +409,19 @@ unsigned int len;
 /* }}} */
 
 /* {{{ Decode
-   Decodes input (unsigned char) into output (php_uint32). Assumes len is
+   Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
    a multiple of 4.
  */
 static void Decode(output, input, len)
-php_uint32 *output;
+php_hash_uint32 *output;
 const unsigned char *input;
 unsigned int len;
 {
        unsigned int i, j;
 
        for (i = 0, j = 0; j < len; i++, j += 4)
-               output[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) |
-                       (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24);
+               output[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) |
+                       (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
 }
 /* }}} */
 
index 8c9d313cb46b6b5c6ea4009cd5f48ce3496dee41..bccbe1fdd7d8041997efb002a453c5c88aeaeaaf 100644 (file)
@@ -81,9 +81,9 @@ PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX * context)
 #define F3(x,y,z)              (((x) & (z)) | ((y) & (~(z))))
 #define F4(x,y,z)              ((x) ^ ((y) | (~(z))))
 
-static php_uint32 K_values[5]  = { 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E };
-static php_uint32 KK_values[4] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x00000000 };
-static php_uint32 KK160_values[5] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000 };
+static php_hash_uint32 K_values[5]  = { 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E };
+static php_hash_uint32 KK_values[4] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x00000000 };
+static php_hash_uint32 KK160_values[5] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000 };
 
 #define K(n)  K_values[ (n) >> 4]
 #define KK(n) KK_values[(n) >> 4]
@@ -122,27 +122,27 @@ static unsigned char SS[80] = {
 #define ROL(n, x)      (((x) << n) | ((x) >> (32 - n)))
 
 /* {{{ RIPEMDDecode
-   Decodes input (unsigned char) into output (php_uint32). Assumes len is
+   Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
    a multiple of 4.
  */
-static void RIPEMDDecode(php_uint32 *output, const unsigned char *input, unsigned int len)
+static void RIPEMDDecode(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
 {
        unsigned int i, j;
 
        for (i = 0, j = 0; j < len; i++, j += 4)
-               output[i] = ((php_uint32) input[j + 0]) | (((php_uint32) input[j + 1]) << 8) |
-                       (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24);
+               output[i] = ((php_hash_uint32) input[j + 0]) | (((php_hash_uint32) input[j + 1]) << 8) |
+                       (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
 }
 /* }}} */
 
 /* {{{ RIPEMD128Transform
  * ripemd128 basic transformation. Transforms state based on block.
  */
-static void RIPEMD128Transform(php_uint32 state[4], const unsigned char block[64])
+static void RIPEMD128Transform(php_hash_uint32 state[4], const unsigned char block[64])
 {
-       php_uint32 a  = state[0], b  = state[1], c  = state[2], d  = state[3];
-       php_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3];
-       php_uint32 tmp, x[16];
+       php_hash_uint32 a  = state[0], b  = state[1], c  = state[2], d  = state[3];
+       php_hash_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3];
+       php_hash_uint32 tmp, x[16];
        int j;
 
        RIPEMDDecode(x, block, 64);
@@ -199,10 +199,10 @@ PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigne
        index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
 
        /* Update number of bits */
-       if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) {
+       if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
                context->count[1]++;
        }
-       context->count[1] += ((php_uint32) inputLen >> 29);
+       context->count[1] += ((php_hash_uint32) inputLen >> 29);
 
        partLen = 64 - index;
 
@@ -229,11 +229,11 @@ PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigne
 /* {{{ RIPEMD160Transform
  * ripemd160 basic transformation. Transforms state based on block.
  */
-static void RIPEMD160Transform(php_uint32 state[5], const unsigned char block[64])
+static void RIPEMD160Transform(php_hash_uint32 state[5], const unsigned char block[64])
 {
-       php_uint32 a  = state[0], b  = state[1], c  = state[2], d  = state[3], e  = state[4];
-       php_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3], ee = state[4];
-       php_uint32 tmp, x[16];
+       php_hash_uint32 a  = state[0], b  = state[1], c  = state[2], d  = state[3], e  = state[4];
+       php_hash_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3], ee = state[4];
+       php_hash_uint32 tmp, x[16];
        int j;
 
        RIPEMDDecode(x, block, 64);
@@ -298,10 +298,10 @@ PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX * context, const unsigne
        index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
 
        /* Update number of bits */
-       if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) {
+       if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
                context->count[1]++;
        }
-       context->count[1] += ((php_uint32) inputLen >> 29);
+       context->count[1] += ((php_hash_uint32) inputLen >> 29);
 
        partLen = 64 - index;
 
@@ -333,10 +333,10 @@ static unsigned char PADDING[64] =
 };
 
 /* {{{ RIPEMDEncode
-   Encodes input (php_uint32) into output (unsigned char). Assumes len is
+   Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
    a multiple of 4.
  */
-static void RIPEMDEncode(unsigned char *output, php_uint32 *input, unsigned int len)
+static void RIPEMDEncode(unsigned char *output, php_hash_uint32 *input, unsigned int len)
 {
        unsigned int i, j;
 
index 6657fcc6503c1d272cc9e7b9918ec8cca55dca5a..28e94920b1a92d8a7ab48729ff968f49cdac5e07 100644 (file)
@@ -43,7 +43,7 @@
  
  D.J.Bernstein
 */
-static void Salsa10(php_uint32 x[16], php_uint32 in[16])
+static void Salsa10(php_hash_uint32 x[16], php_hash_uint32 in[16])
 {
        int i;
        
@@ -90,7 +90,7 @@ static void Salsa10(php_uint32 x[16], php_uint32 in[16])
  
  D.J.Bernstein
 */
-static void Salsa20(php_uint32 x[16], php_uint32 in[16])
+static void Salsa20(php_hash_uint32 x[16], php_hash_uint32 in[16])
 {
        int i;
        
@@ -120,15 +120,15 @@ static void Salsa20(php_uint32 x[16], php_uint32 in[16])
 
 static inline void SalsaTransform(PHP_SALSA_CTX *context, const unsigned char input[64])
 {
-       php_uint32 i, j, a[16];
+       php_hash_uint32 i, j, a[16];
 
 #if 0
        fprintf(stderr, "> INPUT: %.*s\n", 64, input);
 #endif
        
        for (i = 0, j = 0; j < 64; i++, j += 4) {
-               a[i] = ((php_uint32) input[j + 3]) | (((php_uint32) input[j + 2]) << 8) |
-                       (((php_uint32) input[j + 1]) << 16) | (((php_uint32) input[j]) << 24);
+               a[i] = ((php_hash_uint32) input[j + 3]) | (((php_hash_uint32) input[j + 2]) << 8) |
+                       (((php_hash_uint32) input[j + 1]) << 16) | (((php_hash_uint32) input[j]) << 24);
        }
        
        if (!context->init) {
@@ -178,7 +178,7 @@ PHP_HASH_API void PHP_SALSAUpdate(PHP_SALSA_CTX *context, const unsigned char *i
 
 PHP_HASH_API void PHP_SALSAFinal(unsigned char digest[64], PHP_SALSA_CTX *context)
 {
-       php_uint32 i, j;
+       php_hash_uint32 i, j;
        
        if (context->length) {
                SalsaTransform(context, context->buffer);
index 75d283bb286f22b090f9d8eea654dda2d936b971..b6d9e89bcbe9df3526c68dc0342ee821b62bce4a 100644 (file)
 #include "php_hash.h"
 #include "php_hash_sha.h"
 
-#if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8
-#define L64(n) (n)
-#else
-# ifdef PHP_WIN32
-#define L64(n) (n##i64)
-# else
-#define L64(n) (n##LL)
-# endif
-#endif
-
 static unsigned char PADDING[128] =
 {
        0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -45,10 +35,10 @@ static unsigned char PADDING[128] =
 };
 
 /* {{{ SHAEncode32
-   Encodes input (php_uint32) into output (unsigned char). Assumes len is
+   Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
    a multiple of 4.
  */
-static void SHAEncode32(unsigned char *output, php_uint32 *input, unsigned int len)
+static void SHAEncode32(unsigned char *output, php_hash_uint32 *input, unsigned int len)
 {
        unsigned int i, j;
 
@@ -63,16 +53,16 @@ static void SHAEncode32(unsigned char *output, php_uint32 *input, unsigned int l
 
 
 /* {{{ SHADecode32
-   Decodes input (unsigned char) into output (php_uint32). Assumes len is
+   Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
    a multiple of 4.
  */
-static void SHADecode32(php_uint32 *output, const unsigned char *input, unsigned int len)
+static void SHADecode32(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
 {
        unsigned int i, j;
 
        for (i = 0, j = 0; j < len; i++, j += 4)
-               output[i] = ((php_uint32) input[j + 3]) | (((php_uint32) input[j + 2]) << 8) |
-                       (((php_uint32) input[j + 1]) << 16) | (((php_uint32) input[j]) << 24);
+               output[i] = ((php_hash_uint32) input[j + 3]) | (((php_hash_uint32) input[j + 2]) << 8) |
+                       (((php_hash_uint32) input[j + 1]) << 16) | (((php_hash_uint32) input[j]) << 24);
 }
 /* }}} */
 
@@ -188,22 +178,22 @@ PHP_FUNCTION(sha1_file)
 /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
  */
 #define FF(a, b, c, d, e, w) { \
- (e) += F ((b), (c), (d)) + (w) + (php_uint32)(0x5A827999); \
+ (e) += F ((b), (c), (d)) + (w) + (php_hash_uint32)(0x5A827999); \
  (e) += ROTATE_LEFT ((a), 5); \
  (b) = ROTATE_LEFT((b), 30); \
   }
 #define GG(a, b, c, d, e, w) { \
- (e) += G ((b), (c), (d)) + (w) + (php_uint32)(0x6ED9EBA1); \
+ (e) += G ((b), (c), (d)) + (w) + (php_hash_uint32)(0x6ED9EBA1); \
  (e) += ROTATE_LEFT ((a), 5); \
  (b) = ROTATE_LEFT((b), 30); \
   }
 #define HH(a, b, c, d, e, w) { \
- (e) += H ((b), (c), (d)) + (w) + (php_uint32)(0x8F1BBCDC); \
+ (e) += H ((b), (c), (d)) + (w) + (php_hash_uint32)(0x8F1BBCDC); \
  (e) += ROTATE_LEFT ((a), 5); \
  (b) = ROTATE_LEFT((b), 30); \
   }
 #define II(a, b, c, d, e, w) { \
- (e) += I ((b), (c), (d)) + (w) + (php_uint32)(0xCA62C1D6); \
+ (e) += I ((b), (c), (d)) + (w) + (php_hash_uint32)(0xCA62C1D6); \
  (e) += ROTATE_LEFT ((a), 5); \
  (b) = ROTATE_LEFT((b), 30); \
   }
@@ -228,10 +218,10 @@ PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX * context)
 /* {{{ SHA1Transform
  * SHA1 basic transformation. Transforms state based on block.
  */
-static void SHA1Transform(php_uint32 state[5], const unsigned char block[64])
+static void SHA1Transform(php_hash_uint32 state[5], const unsigned char block[64])
 {
-       php_uint32 a = state[0], b = state[1], c = state[2];
-       php_uint32 d = state[3], e = state[4], x[16], tmp;
+       php_hash_uint32 a = state[0], b = state[1], c = state[2];
+       php_hash_uint32 d = state[3], e = state[4], x[16], tmp;
 
        SHADecode32(x, block, 64);
 
@@ -348,10 +338,10 @@ PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *in
        index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
 
        /* Update number of bits */
-       if ((context->count[0] += ((php_uint32) inputLen << 3))
-               < ((php_uint32) inputLen << 3))
+       if ((context->count[0] += ((php_hash_uint32) inputLen << 3))
+               < ((php_hash_uint32) inputLen << 3))
                context->count[1]++;
-       context->count[1] += ((php_uint32) inputLen >> 29);
+       context->count[1] += ((php_hash_uint32) inputLen >> 29);
 
        partLen = 64 - index;
 
@@ -443,7 +433,7 @@ php_hash_ops php_hash_sha256_ops = {
 /* OM1 */
 #define SHA256_F5(x)           (ROTR32(17,(x)) ^ ROTR32(19,(x)) ^ SHR(10,(x)))
 
-static php_uint32 SHA256_K[64] = {
+static php_hash_uint32 SHA256_K[64] = {
        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
        0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
        0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
@@ -475,11 +465,11 @@ PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX * context)
 /* {{{ SHA256Transform
  * SHA256 basic transformation. Transforms state based on block.
  */
-static void SHA256Transform(php_uint32 state[8], const unsigned char block[64])
+static void SHA256Transform(php_hash_uint32 state[8], const unsigned char block[64])
 {
-       php_uint32 a = state[0], b = state[1], c = state[2], d = state[3];
-       php_uint32 e = state[4], f = state[5], g = state[6], h = state[7];
-       php_uint32 x[16], T1, T2, W[64];
+       php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3];
+       php_hash_uint32 e = state[4], f = state[5], g = state[6], h = state[7];
+       php_hash_uint32 x[16], T1, T2, W[64];
        int i;
 
        SHADecode32(x, block, 64);
@@ -526,10 +516,10 @@ PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX * context, const unsigned char
        index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
 
        /* Update number of bits */
-       if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) {
+       if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
                context->count[1]++;
        }
-       context->count[1] += ((php_uint32) inputLen >> 29);
+       context->count[1] += ((php_hash_uint32) inputLen >> 29);
 
        partLen = 64 - index;
 
index edc8d04161963f704f312bbf5a0b5e75865bbe84..6b1b57b5385ec15c7675da41490e520f7e547fe0 100644 (file)
@@ -33,7 +33,7 @@
 #endif
 
 #if DBG_SNEFRU
-void ph(php_uint32 h[16])
+void ph(php_hash_uint32 h[16])
 {
        int i;
        for (i = 0; i < 16; i++)
@@ -41,12 +41,12 @@ void ph(php_uint32 h[16])
 }
 #endif
 
-static inline void Snefru(php_uint32 input[16])
+static inline void Snefru(php_hash_uint32 input[16])
 {
        static int shifts[4] = {16, 8, 16, 24};
        int b, index, rshift, lshift;
-       const php_uint32 *t0,*t1;
-       php_uint32 SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15;
+       const php_hash_uint32 *t0,*t1;
+       php_hash_uint32 SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15;
 
        B00 = input[0];
        B01 = input[1];
@@ -129,7 +129,7 @@ static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char
                                                                ((input[i+2] & 0xff) << 8) | (input[i+3] & 0xff);
        }
        Snefru(context->state);
-       memset(&context->state[8], 0, sizeof(php_uint32) * 8);
+       memset(&context->state[8], 0, sizeof(php_hash_uint32) * 8);
 }
 
 PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context)
@@ -137,7 +137,7 @@ PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context)
        memset(context, 0, sizeof(*context));
 }
 
-static const php_uint32 MAX32 = 0xffffffffLU;
+static const php_hash_uint32 MAX32 = 0xffffffffLU;
 
 PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char *input, size_t len)
 {
@@ -173,7 +173,7 @@ PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char
 
 PHP_HASH_API void PHP_SNEFRUFinal(unsigned char digest[32], PHP_SNEFRU_CTX *context)
 {
-       php_uint32 i, j;
+       php_hash_uint32 i, j;
        
        if (context->length) {
                SnefruTransform(context, context->buffer);
index 57edac3cc5fe8de5a4b9e859c89a1785ac263d62..aa0f12f896a425e536431e2e54ab71c6057090f7 100644 (file)
 #define round(a,b,c,x,mul) \
        c ^= x; \
        a -= t1[(unsigned char)(c)] ^ \
-               t2[(unsigned char)(((php_uint32)(c))>>(2*8))] ^ \
+               t2[(unsigned char)(((php_hash_uint32)(c))>>(2*8))] ^ \
                t3[(unsigned char)((c)>>(4*8))] ^ \
-               t4[(unsigned char)(((php_uint32)((c)>>(4*8)))>>(2*8))] ; \
-       b += t4[(unsigned char)(((php_uint32)(c))>>(1*8))] ^ \
-               t3[(unsigned char)(((php_uint32)(c))>>(3*8))] ^ \
-               t2[(unsigned char)(((php_uint32)((c)>>(4*8)))>>(1*8))] ^ \
-               t1[(unsigned char)(((php_uint32)((c)>>(4*8)))>>(3*8))]; \
+               t4[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(2*8))] ; \
+       b += t4[(unsigned char)(((php_hash_uint32)(c))>>(1*8))] ^ \
+               t3[(unsigned char)(((php_hash_uint32)(c))>>(3*8))] ^ \
+               t2[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(1*8))] ^ \
+               t1[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(3*8))]; \
        b *= mul;
 
 #define pass(a,b,c,mul) \
index db53b289b1c57b786106ccc589f61bda7c8fa093..2646560715ae1aa6bf593736d76afa525e83e001 100644 (file)
@@ -283,7 +283,7 @@ PHP_HASH_API void PHP_WHIRLPOOLUpdate(PHP_WHIRLPOOL_CTX *context, const unsigned
     unsigned char *bitLength    = context->bitlength;
     int bufferBits   = context->buffer.bits;
     int bufferPos    = context->buffer.pos;
-    php_uint32 b, carry;
+    php_hash_uint32 b, carry;
     int i;
 
     /*
@@ -291,7 +291,7 @@ PHP_HASH_API void PHP_WHIRLPOOLUpdate(PHP_WHIRLPOOL_CTX *context, const unsigned
      */
     php_hash_uint64 value = sourceBits;
     for (i = 31, carry = 0; i >= 0 && (carry != 0 || value != L64(0)); i--) {
-        carry += bitLength[i] + ((php_uint32)value & 0xff);
+        carry += bitLength[i] + ((php_hash_uint32)value & 0xff);
         bitLength[i] = (unsigned char)carry;
         carry >>= 8;
         value >>= 8;
index e410a934cf9aae7f70d5a57a7373e07a841cffe6..f646d18c54fa0de1663f8b291448f58ebd87c63b 100644 (file)
@@ -40,6 +40,7 @@ Initial Release
    <file role="src" name="config.w32"/>
    <file role="src" name="hash.c"/>
    <file role="src" name="php_hash.h"/>
+   <file role="src" name="php_hash_types.h"/>
    <file role="src" name="hash_md.c"/>
    <file role="src" name="php_hash_md.h"/>
    <file role="src" name="hash_sha.c"/>
index 17cae45fc9b24af35afcc2f33e325f475560a98d..9e9a27ffafb28856c3a220ac86c4c1662964e89c 100644 (file)
@@ -22,6 +22,7 @@
 #define PHP_HASH_H
 
 #include "php.h"
+#include "php_hash_types.h"
 
 #define PHP_HASH_EXTNAME       "hash"
 #define PHP_HASH_EXTVER                "0.1"
index 297a86a4100ac710f3e082f40c78ec7ffa9d7a37..154d3ebdad2cfd20e2c86ce918cf43a77e2ab973 100644 (file)
@@ -24,7 +24,7 @@
 #include "ext/standard/basic_functions.h"
 
 typedef struct {
-       php_uint32 state;
+       php_hash_uint32 state;
 } PHP_ADLER32_CTX;
 
 PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context);
index cb2e1e5f79dedefdc5816a5b0c669059352b2384..cfb83d3986af46515a3c8a7d87fdf8c939b3e7e2 100644 (file)
@@ -24,7 +24,7 @@
 #include "ext/standard/basic_functions.h"
 
 typedef struct {
-       php_uint32 state;
+       php_hash_uint32 state;
 } PHP_CRC32_CTX;
 
 PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context);
index 1f023aff8f9569fd2c4f7ded3f32c3b68e8f9fec..a9cb87ab54c1e17b7770c5b9a13e4f78e0e9c28a 100644 (file)
@@ -18,7 +18,7 @@
 
 /* $Id$ */
 
-static const php_uint32 crc32_table[] = {  0x0,
+static const php_hash_uint32 crc32_table[] = {  0x0,
        0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
        0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
        0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
@@ -72,7 +72,7 @@ static const php_uint32 crc32_table[] = {  0x0,
        0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
 };
 
-static const php_uint32 crc32b_table[] = {
+static const php_hash_uint32 crc32b_table[] = {
        0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
        0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
        0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
index eea91fcf84cc6af8ed28f31813d1008f4bc609fc..ba9f63dab1b209d311211c3f0a0a96191cc48bb2 100644 (file)
@@ -25,8 +25,8 @@
 
 /* GOST context */
 typedef struct {
-       php_uint32 state[16];
-       php_uint32 count[2];
+       php_hash_uint32 state[16];
+       php_hash_uint32 count[2];
        unsigned char length;
        unsigned char buffer[32];
 } PHP_GOST_CTX;
index 51d85fa828fcccaddd9c489be841bbe63000e94e..5d05e593cb13a2d4e4f8f5344179f1c3e4686b24 100644 (file)
@@ -1,4 +1,4 @@
-static const php_uint32 tables[4][256] = {
+static const php_hash_uint32 tables[4][256] = {
        { /* table 1 */
                0x00072000LU, 0x00075000LU, 0x00074800LU, 0x00071000LU, 0x00076800LU, 0x00074000LU, 0x00070000LU, 0x00077000LU, 
                0x00073000LU, 0x00075800LU, 0x00070800LU, 0x00076000LU, 0x00073800LU, 0x00077800LU, 0x00072800LU, 0x00071800LU, 
index 67b640cf1af9529ee914412f99b0b19a2a8d3406..bf0749ea997978506cc95a004b62640a7cde951a 100644 (file)
 #include "ext/standard/basic_functions.h"
 /* HAVAL context. */
 typedef struct {
-       php_uint32 state[8];
-       php_uint32 count[2];
+       php_hash_uint32 state[8];
+       php_hash_uint32 count[2];
        unsigned char buffer[128];
 
        char passes;
        short output;
-       void (*Transform)(php_uint32 state[8], const unsigned char block[128]);
+       void (*Transform)(php_hash_uint32 state[8], const unsigned char block[128]);
 } PHP_HAVAL_CTX;
 
 #define PHP_HASH_HAVAL_INIT_DECL(p,b)  PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *); \
index 9dea33033a1a8fa3c0d119edfb7ea2931419c430..d0229d7a9e8d34a003a4dda16c1fb3c3c3529258 100644 (file)
@@ -61,8 +61,8 @@
 #include "ext/standard/basic_functions.h"
 /* MD5 context. */
 typedef struct {
-       php_uint32 state[4];                            /* state (ABCD) */
-       php_uint32 count[2];                            /* number of bits, modulo 2^64 (lsb first) */
+       php_hash_uint32 state[4];                               /* state (ABCD) */
+       php_hash_uint32 count[2];                               /* number of bits, modulo 2^64 (lsb first) */
        unsigned char buffer[64];       /* input buffer */
 } PHP_MD5_CTX;
 
index f6880b93f6ae80e8da4ae7605b298c298c934e39..2dfb21cd535039aaeeb81fd750961fba47eb8b43 100644 (file)
 
 /* RIPEMD context. */
 typedef struct {
-       php_uint32 state[4];            /* state (ABCD) */
-       php_uint32 count[2];            /* number of bits, modulo 2^64 (lsb first) */
+       php_hash_uint32 state[4];               /* state (ABCD) */
+       php_hash_uint32 count[2];               /* number of bits, modulo 2^64 (lsb first) */
        unsigned char buffer[64];       /* input buffer */
 } PHP_RIPEMD128_CTX;
 
 typedef struct {
-       php_uint32 state[5];            /* state (ABCD) */
-       php_uint32 count[2];            /* number of bits, modulo 2^64 (lsb first) */
+       php_hash_uint32 state[5];               /* state (ABCD) */
+       php_hash_uint32 count[2];               /* number of bits, modulo 2^64 (lsb first) */
        unsigned char buffer[64];       /* input buffer */
 } PHP_RIPEMD160_CTX;
 
index 3b23148f4d4f5b98b627ec407c4dc91e803e1222..f6297711c0eba0bd2eee2a8acbbfb75d7e4fab87 100644 (file)
 
 /* SALSA context */
 typedef struct {
-       php_uint32 state[16];
+       php_hash_uint32 state[16];
        unsigned char init:1;
        unsigned char length:7;
        unsigned char buffer[64];
-       void (*Transform)(php_uint32 state[16], php_uint32 data[16]);
+       void (*Transform)(php_hash_uint32 state[16], php_hash_uint32 data[16]);
 } PHP_SALSA_CTX;
 
 #define PHP_SALSAInit PHP_SALSA20Init
index 7ff2094125c84bf766b1c43fedf45a6fa1e874bd..480392c82acb52d075f8b31f52a2a52ff29a2d86 100644 (file)
@@ -36,8 +36,8 @@
 
 /* SHA1 context. */
 typedef struct {
-       php_uint32 state[5];            /* state (ABCD) */
-       php_uint32 count[2];            /* number of bits, modulo 2^64 */
+       php_hash_uint32 state[5];               /* state (ABCD) */
+       php_hash_uint32 count[2];               /* number of bits, modulo 2^64 */
        unsigned char buffer[64];       /* input buffer */
 } PHP_SHA1_CTX;
 
@@ -52,8 +52,8 @@ PHP_FUNCTION(sha1_file);
 
 /* SHA256 context. */
 typedef struct {
-       php_uint32 state[8];            /* state */
-       php_uint32 count[2];            /* number of bits, modulo 2^64 */
+       php_hash_uint32 state[8];               /* state */
+       php_hash_uint32 count[2];               /* number of bits, modulo 2^64 */
        unsigned char buffer[64];       /* input buffer */
 } PHP_SHA256_CTX;
 
@@ -61,16 +61,6 @@ PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX *);
 PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, unsigned int);
 PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *);
 
-#if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8
-typedef unsigned long php_hash_uint64;
-#else
-# ifdef PHP_WIN32
-typedef unsigned __int64 php_hash_uint64;
-# else
-typedef unsigned long long php_hash_uint64;
-# endif
-#endif
-
 /* SHA384 context */
 typedef struct {
        php_hash_uint64 state[8];       /* state */
index b5c76f7865b5f549ddb2db9df90baa8879c78a87..f8c71ba66da86d696c2c9b369cdc3cd0c9ab9bca 100644 (file)
@@ -29,8 +29,8 @@
 
 /* SNEFRU context */
 typedef struct {
-       php_uint32 state[16];
-       php_uint32 count[2];
+       php_hash_uint32 state[16];
+       php_hash_uint32 count[2];
        unsigned char length;
        unsigned char buffer[32];
 } PHP_SNEFRU_CTX;
index 3d5ed4e10b3eb866a2a8cc0f9acee904fc89742b..a2e572be57444df67a50c7a2c48d4e1acd7e09c9 100644 (file)
@@ -18,7 +18,7 @@
 
 /* $Id$ */
 
-static const php_uint32 tables[16][256]= {
+static const php_hash_uint32 tables[16][256]= {
 
  {  /* Start of S Box 0  */
 
index e3291c3ce1f9f259da889e4c50f5d4cbf781ba6d..5e909cb7fc05e73a337e61f0b3643a6fbc570c27 100644 (file)
 #ifndef PHP_HASH_TIGER_H
 #define PHP_HASH_TIGER_H
 
-#include "ext/standard/basic_functions.h"
-
-#if defined(SIZEOF_LONG) && (SIZEOF_LONG >= 8)
-#      define L64(n)   (n##L)
-typedef unsigned long php_hash_uint64;
-#else
-#      ifdef PHP_WIN32
-#              define L64(n)   (n##i64)
-typedef unsigned __int64 php_hash_uint64;
-#      else
-#              define L64(n)   (n##LL)
-typedef unsigned long long php_hash_uint64;
-#      endif
-#endif
-
 /* TIGER context */
 typedef struct {
        php_hash_uint64 state[3];
diff --git a/ext/hash/php_hash_types.h b/ext/hash/php_hash_types.h
new file mode 100644 (file)
index 0000000..869a121
--- /dev/null
@@ -0,0 +1,40 @@
+
+/* $Id$ */
+
+#ifndef PHP_HASH_TYPES_H
+#define PHP_HASH_TYPES_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef _MSC_VER
+#if SIZEOF_LONG == 8
+#define L64(x) x
+typedef unsigned long php_hash_uint64;
+#if SIZEOF_INT == 4
+typedef unsigned int php_hash_uint32;
+#elif SIZEOF_SHORT == 4
+typedef unsigned short php_hash_uint32;
+#else
+#error "Need a 32bit integer type"
+#endif
+#elif SIZEOF_LONG_LONG == 8
+#define L64(x) x##LL
+typedef unsigned long long php_hash_uint64;
+#if SIZEOF_INT == 4
+typedef unsigned int php_hash_uint32;
+#elif SIZEOF_LONG == 4
+typedef unsigned long php_hash_uint32;
+#else
+#error "Need a 32bit integer type"
+#endif
+#endif
+#else
+#define L64(x) x##i64
+typedef unsigned __int64 php_hash_uint64;
+typedef unsigned __int32 php_hash_uint32;
+#endif
+
+#endif
+
index 42e5793e1449843b71c63473fcf256bf877b17f1..56be370778e46e1eaed8eb0343b630ac4c355195 100644 (file)
 #ifndef PHP_HASH_WHIRLPOOL_H
 #define PHP_HASH_WHIRLPOOL_H
 
-#include "ext/standard/basic_functions.h"
-
-#if defined(SIZEOF_LONG) && (SIZEOF_LONG >= 8)
-#      define L64(n)   (n##L)
-typedef unsigned long php_hash_uint64;
-#else
-#      ifdef PHP_WIN32
-#              define L64(n)   (n##i64)
-typedef unsigned __int64 php_hash_uint64;
-#      else
-#              define L64(n)   (n##LL)
-typedef unsigned long long php_hash_uint64;
-#      endif
-#endif
-
 /* WHIRLPOOL context */
 typedef struct {
        php_hash_uint64 state[8];