From: Adam Megacz Date: Thu, 7 Feb 2002 05:01:29 +0000 (+0000) Subject: shs.h, [...]: use uint_t instead of LONG and BYTE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=df79080e5f5fb9339dbeaa8b51416b25a055d122;p=gcc.git shs.h, [...]: use uint_t instead of LONG and BYTE 2002-02-06 Adam Megacz * shs.h, shs.cc, natSimpleSHSStream.cc: use uint_t instead of LONG and BYTE From-SVN: r49565 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 8213a0fcf5c..71bfac61f96 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2002-02-06 Adam Megacz + + * shs.h, shs.cc, natSimpleSHSStream.cc: use uint_t instead + of LONG and BYTE + 2002-02-06 Adam Megacz * name-finder.h: don't #include sys/wait.h unless HAVE_SYS_WAIT_H diff --git a/libjava/gnu/gcj/io/natSimpleSHSStream.cc b/libjava/gnu/gcj/io/natSimpleSHSStream.cc index 2cd213b809b..5e7b8460012 100644 --- a/libjava/gnu/gcj/io/natSimpleSHSStream.cc +++ b/libjava/gnu/gcj/io/natSimpleSHSStream.cc @@ -37,7 +37,7 @@ void gnu::gcj::io::SimpleSHSStream::shsUpdate (jbyteArray shs_info, jbyteArray buf, jint count) { SHS_INFO *info = (SHS_INFO *)elements(shs_info); - BYTE *buffer = (BYTE *)elements(buf); + uint8_t *buffer = (uint8_t *)elements(buf); ::shsUpdate (info, buffer, count); } diff --git a/libjava/gnu/gcj/io/shs.cc b/libjava/gnu/gcj/io/shs.cc index b9a563c544c..ca82661dfc7 100644 --- a/libjava/gnu/gcj/io/shs.cc +++ b/libjava/gnu/gcj/io/shs.cc @@ -91,10 +91,10 @@ /* The two buffers of 5 32-bit words */ -LONG h0, h1, h2, h3, h4; -LONG A, B, C, D, E; +uint32_t h0, h1, h2, h3, h4; +uint32_t A, B, C, D, E; -local void byteReverse OF((LONG *buffer, int byteCount)); +local void byteReverse OF((uint32_t *buffer, int byteCount)); void shsTransform OF((SHS_INFO *shsInfo)); /* Initialize the SHS values */ @@ -120,7 +120,7 @@ void shsInit (SHS_INFO *shsInfo) void shsTransform (SHS_INFO *shsInfo) { - LONG W [80], temp; + uint32_t W [80], temp; int i; /* Step A. Copy the data buffer into the local work buffer */ @@ -182,9 +182,9 @@ void shsTransform (SHS_INFO *shsInfo) shsInfo->digest [4] += E; } -local void byteReverse (LONG *buffer, int byteCount) +local void byteReverse (uint32_t *buffer, int byteCount) { - LONG value; + uint32_t value; int count; /* @@ -209,7 +209,7 @@ local void byteReverse (LONG *buffer, int byteCount) if ((*(unsigned short *) ("@P") >> 8) == '@') return; - byteCount /= sizeof (LONG); + byteCount /= sizeof (uint32_t); for (count = 0; count < byteCount; count++) { value = (buffer [count] << 16) | (buffer [count] >> 16); buffer [count] = ((value & 0xFF00FF00L) >> 8) | ((value & 0x00FF00FFL) << 8); @@ -223,13 +223,13 @@ local void byteReverse (LONG *buffer, int byteCount) * between calls to shsUpdate() */ -void shsUpdate (SHS_INFO *shsInfo, BYTE *buffer, int count) +void shsUpdate (SHS_INFO *shsInfo, uint8_t *buffer, int count) { /* Update bitcount */ - if ((shsInfo->countLo + ((LONG) count << 3)) < shsInfo->countLo) + if ((shsInfo->countLo + ((uint32_t) count << 3)) < shsInfo->countLo) shsInfo->countHi++; /* Carry from low to high bitCount */ - shsInfo->countLo += ((LONG) count << 3); - shsInfo->countHi += ((LONG) count >> 29); + shsInfo->countLo += ((uint32_t) count << 3); + shsInfo->countHi += ((uint32_t) count >> 29); /* Process data in SHS_BLOCKSIZE chunks */ while (count >= SHS_BLOCKSIZE) { @@ -250,7 +250,7 @@ void shsUpdate (SHS_INFO *shsInfo, BYTE *buffer, int count) void shsFinal (SHS_INFO *shsInfo) { int count; - LONG lowBitcount = shsInfo->countLo, highBitcount = shsInfo->countHi; + uint32_t lowBitcount = shsInfo->countLo, highBitcount = shsInfo->countHi; /* Compute number of bytes mod 64 */ count = (int) ((shsInfo->countLo >> 3) & 0x3F); @@ -259,12 +259,12 @@ void shsFinal (SHS_INFO *shsInfo) * Set the first char of padding to 0x80. * This is safe since there is always at least one byte free */ - ((BYTE *) shsInfo->data) [count++] = 0x80; + ((uint8_t *) shsInfo->data) [count++] = 0x80; /* Pad out to 56 mod 64 */ if (count > 56) { /* Two lots of padding: Pad the first block to 64 bytes */ - memset ((BYTE *) shsInfo->data + count, 0, 64 - count); + memset ((uint8_t *) shsInfo->data + count, 0, 64 - count); byteReverse (shsInfo->data, SHS_BLOCKSIZE); shsTransform (shsInfo); @@ -272,7 +272,7 @@ void shsFinal (SHS_INFO *shsInfo) memset (shsInfo->data, 0, 56); } else /* Pad block to 56 bytes */ - memset ((BYTE *) shsInfo->data + count, 0, 56 - count); + memset ((uint8_t *) shsInfo->data + count, 0, 56 - count); byteReverse (shsInfo->data, SHS_BLOCKSIZE); /* Append length in bits and transform */ diff --git a/libjava/gnu/gcj/io/shs.h b/libjava/gnu/gcj/io/shs.h index 8c91ff3dfea..9b7bb2462c5 100644 --- a/libjava/gnu/gcj/io/shs.h +++ b/libjava/gnu/gcj/io/shs.h @@ -14,8 +14,14 @@ #ifndef SHS_H #define SHS_H -typedef unsigned char BYTE; -typedef unsigned int LONG; /* A 32-bit type */ +#include +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif /* The SHS block size and message digest sizes, in bytes */ @@ -25,9 +31,9 @@ typedef unsigned int LONG; /* A 32-bit type */ /* The structure for storing SHS info */ typedef struct { - LONG digest [5]; /* Message digest */ - LONG countLo, countHi; /* 64-bit bit count */ - LONG data [16]; /* SHS data buffer */ + uint32_t digest [5]; /* Message digest */ + uint32_t countLo, countHi; /* 64-bit bit count */ + uint32_t data [16]; /* SHS data buffer */ } SHS_INFO; /* Turn off prototypes if requested */ @@ -45,7 +51,7 @@ typedef struct { #define local static void shsInit OF((SHS_INFO *shsInfo)); -void shsUpdate OF((SHS_INFO *shsInfo, BYTE *buffer, int count)); +void shsUpdate OF((SHS_INFO *shsInfo, uint8_t *buffer, int count)); void shsFinal OF((SHS_INFO *shsInfo)); #endif