This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: WIN-09.: shs.h, shs.cc, natSimpleSHSStream.cc: use uint<n>_t instead of LONG and BYTE



Is this kosher? uint<n>_t should be more portable than simply assuming
that a "unsigned int" is 32 bits. Win32 typedef's LONG to something
obscure anyways.


2002-01-31  Adam Megacz <adam@xwt.org>
 
        * shs.h, shs.cc, natSimpleSHSStream.cc: use uint<n>_t instead
          of LONG and BYTE


Index: shs.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/io/shs.h,v
retrieving revision 1.1
diff -u -r1.1 shs.h
--- shs.h	2000/05/19 17:55:27	1.1
+++ shs.h	2002/02/01 08:41:00
@@ -14,8 +14,7 @@
 #ifndef SHS_H
 #define SHS_H
 
-typedef unsigned char BYTE;
-typedef unsigned int LONG; /* A 32-bit type */
+#include <stdint.h>
 
 /* The SHS block size and message digest sizes, in bytes */
 
@@ -25,9 +24,9 @@
 /* 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 +44,7 @@
 #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
Index: shs.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/io/shs.cc,v
retrieving revision 1.2
diff -u -r1.2 shs.cc
--- shs.cc	2001/05/18 06:29:11	1.2
+++ shs.cc	2002/02/01 08:41:01
@@ -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 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 @@
 	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 @@
 	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 @@
  * 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 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 @@
 	 * 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 @@
 		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 */
Index: natSimpleSHSStream.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/io/natSimpleSHSStream.cc,v
retrieving revision 1.1
diff -u -r1.1 natSimpleSHSStream.cc
--- natSimpleSHSStream.cc	2000/05/19 17:55:27	1.1
+++ natSimpleSHSStream.cc	2002/02/01 08:41:01
@@ -37,7 +37,7 @@
 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);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]