From 9c205d926b3f4040a5bd4d07d0d3164353dd44dd Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Fri, 10 Jun 1994 20:01:10 +0000 Subject: [PATCH] nothing else needed LSBFIRST/MSBFIRST, so fix this too git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3730 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/des425/quad_cksum.c | 70 ++++--------------------------------- 1 file changed, 6 insertions(+), 64 deletions(-) diff --git a/src/lib/des425/quad_cksum.c b/src/lib/des425/quad_cksum.c index 482d7eee8..52ee722a0 100644 --- a/src/lib/des425/quad_cksum.c +++ b/src/lib/des425/quad_cksum.c @@ -96,20 +96,12 @@ static char rcsid_quad_cksum_c[] = #include "des.h" /* Definitions for byte swapping */ -#ifdef LSBFIRST -#ifdef MUSTALIGN -static unsigned long vaxtohl(); -static unsigned short vaxtohs(); -#else /* ! MUSTALIGN */ -#define vaxtohl(x) *((unsigned long *)(x)) -#define vaxtohs(x) *((unsigned short *)(x)) -#endif /* MUSTALIGN */ -#else /* !LSBFIRST */ -static unsigned long four_bytes_vax_to_nets(); -#define vaxtohl(x) four_bytes_vax_to_nets((char *)(x)) -static unsigned short two_bytes_vax_to_nets(); -#define vaxtohs(x) two_bytes_vax_to_nets((char *)(x)) -#endif +/* vax byte order is LSB first. This is not performance critical, and + is far more readable this way. */ +#define four_bytes_vax_to_nets(x) (((x[3]<<8|x[2])<<8|x[1]<<8)|x[0]) +#define vaxtohl(x) four_bytes_vax_to_nets(((char *)(x))) +#define two_bytes_vax_to_nets(x) ((x[1]<<8)|x[0]) +#define vaxtohs(x) two_bytes_vax_to_nets(((char *)(x))) /* Externals */ extern char *errmsg(); @@ -180,53 +172,3 @@ des_quad_cksum(in,out,length,out_count,c_seed) /* return final z value as 32 bit version of checksum */ return z; } -#ifdef MSBFIRST - -static unsigned short two_bytes_vax_to_nets(p) - char *p; -{ - union { - char pieces[2]; - unsigned short result; - } short_conv; - - short_conv.pieces[0] = p[1]; - short_conv.pieces[1] = p[0]; - return(short_conv.result); -} - -static unsigned long four_bytes_vax_to_nets(p) - char *p; -{ - static union { - char pieces[4]; - unsigned long result; - } long_conv; - - long_conv.pieces[0] = p[3]; - long_conv.pieces[1] = p[2]; - long_conv.pieces[2] = p[1]; - long_conv.pieces[3] = p[0]; - return(long_conv.result); -} - -#endif -#ifdef LSBFIRST -#ifdef MUSTALIGN -static unsigned long vaxtohl(x) -char *x; -{ - unsigned long val; - bcopy(x, (char *)&val, sizeof(val)); - return(val); -} - -static unsigned short vaxtohs(x) -char *x; -{ - unsigned short val; - bcopy(x, (char *)&val, sizeof(val)); - return(val); -} -#endif /* MUSTALIGN */ -#endif /* LSBFIRST */ -- 2.26.2