Attachment "64bit.patch" to
ticket [554351ffff]
added by
dkf
2002-07-26 22:04:56.
Index: configure
===================================================================
RCS file: /cvsroot/tcl/sampleextension/configure,v
retrieving revision 1.20
diff -u -r1.20 configure
--- configure 23 Apr 2002 19:54:06 -0000 1.20
+++ configure 26 Jul 2002 15:01:36 -0000
@@ -3424,6 +3424,52 @@
#--------------------------------------------------------------------
# __CHANGE__
+# Check for platform defines as necessary.
+#--------------------------------------------------------------------
+
+for ac_hdr in inttypes.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3435: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3440 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+#--------------------------------------------------------------------
+# __CHANGE__
# Add platform libs to LIBS or SHLIB_LD_LIBS as necessary.
#--------------------------------------------------------------------
@@ -3440,7 +3486,7 @@
echo $ac_n "checking for tclsh""... $ac_c" 1>&6
-echo "configure:3444: checking for tclsh" >&5
+echo "configure:3490: checking for tclsh" >&5
if eval "test \"`echo '$''{'ac_cv_path_tclsh'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
Index: configure.in
===================================================================
RCS file: /cvsroot/tcl/sampleextension/configure.in,v
retrieving revision 1.32
diff -u -r1.32 configure.in
--- configure.in 22 Apr 2002 23:23:30 -0000 1.32
+++ configure.in 26 Jul 2002 15:01:37 -0000
@@ -190,6 +190,13 @@
#--------------------------------------------------------------------
# __CHANGE__
+# Check for platform defines as necessary.
+#--------------------------------------------------------------------
+
+AC_CHECK_HEADERS(inttypes.h)
+
+#--------------------------------------------------------------------
+# __CHANGE__
# Add platform libs to LIBS or SHLIB_LD_LIBS as necessary.
#--------------------------------------------------------------------
Index: generic/sample.c
===================================================================
RCS file: /cvsroot/tcl/sampleextension/generic/sample.c,v
retrieving revision 1.1
diff -u -r1.1 sample.c
--- generic/sample.c 12 Mar 2002 04:41:48 -0000 1.1
+++ generic/sample.c 26 Jul 2002 15:01:37 -0000
@@ -93,18 +93,19 @@
void
SHA1Transform(state, buffer)
- unsigned long state[5]; /* State variable */
+ sha_uint32_t state[5]; /* State variable */
unsigned char buffer[64]; /* Modified buffer */
{
#if (!defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN))
unsigned char *p;
#endif
- unsigned long a, b, c, d, e;
+ sha_uint32_t a, b, c, d, e;
typedef union {
unsigned char c[64];
- unsigned long l[16];
+ sha_uint32_t l[16];
} CHAR64LONG16;
CHAR64LONG16* block;
+
#ifdef SHA1HANDSOFF
static unsigned char workspace[64];
block = (CHAR64LONG16*)workspace;
@@ -113,6 +114,8 @@
block = (CHAR64LONG16*)buffer;
#endif
+ assert(sizeof(block->c) == sizeof(block->l));
+
/*
* Copy context->state[] to working vars
*/
@@ -275,7 +278,7 @@
SHA1_CTX* context; /* Context to pad */
unsigned char digest[20]; /* Returned message digest */
{
- unsigned long i, j;
+ sha_uint32_t i, j;
unsigned char finalcount[8];
for (i = 0; i < 8; i++) {
@@ -298,7 +301,7 @@
SHA1Update(context, finalcount, 8);
for (i = 0; i < 20; i++) {
digest[i] = (unsigned char)
- ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
/*
@@ -306,9 +309,7 @@
*/
i = j = 0;
- memset(context->buffer, 0, 64);
- memset(context->state, 0, 20);
- memset(context->count, 0, 8);
+ memset(context, 0, sizeof(SHA1_CTX));
memset(&finalcount, 0, 8);
/*
Index: generic/sample.h
===================================================================
RCS file: /cvsroot/tcl/sampleextension/generic/sample.h,v
retrieving revision 1.1
diff -u -r1.1 sample.h
--- generic/sample.h 12 Mar 2002 04:41:48 -0000 1.1
+++ generic/sample.h 26 Jul 2002 15:01:37 -0000
@@ -26,9 +26,20 @@
#define TCL_STORAGE_CLASS DLLEXPORT
#endif /* BUILD_sample */
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+typedef uint32_t sha_uint32_t;
+#else
+# if ((1<<31)<0)
+typedef unsigned long sha_uint32_t;
+# else
+typedef unsigned int sha_uint32_t;
+# endif
+#endif
+
typedef struct {
- unsigned long state[5];
- unsigned long count[2];
+ sha_uint32_t state[5];
+ sha_uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;