cksum does a 32-bit checksum, so it needs to use u_int32_t variables,
not u_long. With this change, cksum stops core dumping on alpha (not a good sign!) and actually computes the same values as it does on i386.
This commit is contained in:
parent
dd2474f300
commit
4933ffaed9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=34447
@ -45,7 +45,7 @@ static const char copyright[] =
|
||||
static char sccsid[] = "@(#)cksum.c 8.2 (Berkeley) 4/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: cksum.c,v 1.7 1997/11/09 05:35:26 obrien Exp $";
|
||||
"$Id: cksum.c,v 1.8 1997/11/09 05:47:55 obrien Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
@ -69,10 +69,10 @@ main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
register int ch, fd, rval;
|
||||
u_long len, val;
|
||||
u_int32_t len, val;
|
||||
char *fn, *p;
|
||||
int (*cfncn) __P((int, unsigned long *, unsigned long *));
|
||||
void (*pfncn) __P((char *, unsigned long, unsigned long));
|
||||
int (*cfncn) __P((int, u_int32_t *, u_int32_t *));
|
||||
void (*pfncn) __P((char *, u_int32_t, u_int32_t));
|
||||
|
||||
if ((p = rindex(argv[0], '/')) == NULL)
|
||||
p = argv[0];
|
||||
|
@ -41,7 +41,7 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 6/17/93";
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static u_long crctab[] = {
|
||||
static const u_int32_t crctab[] = {
|
||||
0x0,
|
||||
0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
|
||||
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
|
||||
@ -102,16 +102,16 @@ static u_long crctab[] = {
|
||||
* locations to store the crc and the number of bytes read. It returns 0 on
|
||||
* success and 1 on failure. Errno is set on failure.
|
||||
*/
|
||||
u_long crc_total = ~0; /* The crc over a number of files. */
|
||||
u_int32_t crc_total = ~0; /* The crc over a number of files. */
|
||||
|
||||
int
|
||||
crc(fd, cval, clen)
|
||||
register int fd;
|
||||
u_long *cval, *clen;
|
||||
u_int32_t *cval, *clen;
|
||||
{
|
||||
register u_char *p;
|
||||
register int nr;
|
||||
register u_long crc, len;
|
||||
register u_int32_t crc, len;
|
||||
u_char buf[16 * 1024];
|
||||
|
||||
#define COMPUTE(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
|
||||
|
@ -11,13 +11,15 @@
|
||||
* Spencer Garrett <srg@quick.com>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define CRC(crc, ch) (crc = (crc >> 8) ^ crctab[(crc ^ (ch)) & 0xff])
|
||||
|
||||
/* generated using the AUTODIN II polynomial
|
||||
* x^32 + x^26 + x^23 + x^22 + x^16 +
|
||||
* x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1
|
||||
*/
|
||||
unsigned long crctab[256] = {
|
||||
static const u_int32_t crctab[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
@ -88,14 +90,14 @@ unsigned long crctab[256] = {
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
u_long crc32_total = 0 ;
|
||||
u_int32_t crc32_total = 0 ;
|
||||
|
||||
int
|
||||
crc32(fd, cval, clen)
|
||||
register int fd;
|
||||
u_long *cval, *clen;
|
||||
u_int32_t *cval, *clen;
|
||||
{
|
||||
u_long crc = ~0;
|
||||
u_int32_t crc = ~0;
|
||||
char buf[BUFSIZ], *p ;
|
||||
int len, nr ;
|
||||
|
||||
|
@ -36,11 +36,11 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
int crc __P((int, unsigned long *, unsigned long *));
|
||||
void pcrc __P((char *, unsigned long, unsigned long));
|
||||
void psum1 __P((char *, unsigned long, unsigned long));
|
||||
void psum2 __P((char *, unsigned long, unsigned long));
|
||||
int csum1 __P((int, unsigned long *, unsigned long *));
|
||||
int csum2 __P((int, unsigned long *, unsigned long *));
|
||||
int crc32 __P((int, unsigned long *, unsigned long *));
|
||||
int crc __P((int, u_int32_t *, u_int32_t *));
|
||||
void pcrc __P((char *, u_int32_t, u_int32_t));
|
||||
void psum1 __P((char *, u_int32_t, u_int32_t));
|
||||
void psum2 __P((char *, u_int32_t, u_int32_t));
|
||||
int csum1 __P((int, u_int32_t *, u_int32_t *));
|
||||
int csum2 __P((int, u_int32_t *, u_int32_t *));
|
||||
int crc32 __P((int, u_int32_t *, u_int32_t *));
|
||||
__END_DECLS
|
||||
|
@ -42,9 +42,9 @@ static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/6/93";
|
||||
void
|
||||
pcrc(fn, val, len)
|
||||
char *fn;
|
||||
u_long val, len;
|
||||
u_int32_t val, len;
|
||||
{
|
||||
(void)printf("%lu %lu", val, len);
|
||||
(void)printf("%lu %lu", (u_long) val, (u_long) len);
|
||||
if (fn)
|
||||
(void)printf(" %s", fn);
|
||||
(void)printf("\n");
|
||||
@ -53,9 +53,9 @@ pcrc(fn, val, len)
|
||||
void
|
||||
psum1(fn, val, len)
|
||||
char *fn;
|
||||
u_long val, len;
|
||||
u_int32_t val, len;
|
||||
{
|
||||
(void)printf("%lu %lu", val, (len + 1023) / 1024);
|
||||
(void)printf("%lu %lu", (u_long) val, (u_long) (len + 1023) / 1024);
|
||||
if (fn)
|
||||
(void)printf(" %s", fn);
|
||||
(void)printf("\n");
|
||||
@ -64,9 +64,9 @@ psum1(fn, val, len)
|
||||
void
|
||||
psum2(fn, val, len)
|
||||
char *fn;
|
||||
u_long val, len;
|
||||
u_int32_t val, len;
|
||||
{
|
||||
(void)printf("%lu %lu", val, (len + 511) / 512);
|
||||
(void)printf("%lu %lu", (u_long) val, (u_long) (len + 511) / 512);
|
||||
if (fn)
|
||||
(void)printf(" %s", fn);
|
||||
(void)printf("\n");
|
||||
|
@ -41,9 +41,9 @@ static char sccsid[] = "@(#)sum1.c 8.1 (Berkeley) 6/6/93";
|
||||
int
|
||||
csum1(fd, cval, clen)
|
||||
register int fd;
|
||||
u_long *cval, *clen;
|
||||
u_int32_t *cval, *clen;
|
||||
{
|
||||
register u_long total;
|
||||
register u_int32_t total;
|
||||
register int nr;
|
||||
register u_int crc;
|
||||
register u_char *p;
|
||||
|
@ -41,9 +41,9 @@ static char sccsid[] = "@(#)sum2.c 8.1 (Berkeley) 6/6/93";
|
||||
int
|
||||
csum2(fd, cval, clen)
|
||||
register int fd;
|
||||
u_long *cval, *clen;
|
||||
u_int32_t *cval, *clen;
|
||||
{
|
||||
register u_long crc, total;
|
||||
register u_int32_t crc, total;
|
||||
register int nr;
|
||||
register u_char *p;
|
||||
u_char buf[8192];
|
||||
|
Loading…
Reference in New Issue
Block a user