des-support-alpha-bsd-and-fix-test-programs-20020119
authorLove Hörnquist-Åstrand <lha@e.kth.se>
Sun, 20 Jan 2002 05:19:08 +0000 (05:19 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sun, 20 Jan 2002 05:19:08 +0000 (05:19 +0000)
All BSDs are not I386s.

Also include a patch that make sure that data are alligned on alpha. All
bsd's will fix it up in kernel when used, but you'll get a huge performace
penalty

Use afs_int32 in the des programs to make sure they work and make them
build again.

src/des/andrew-conf.h
src/des/conf-alpha-bsd.h [new file with mode: 0644]
src/des/test/Makefile.in
src/des/test/key_test.c
src/des/test/testit.c
src/des/test/verify.c

index f1be8c1..032b713 100644 (file)
 #if defined(sgi)
 #include "conf-sgi.h"
 #else
-#if defined(__alpha) && !defined(AFS_ALPHA_LINUX20_ENV)
+#ifdef AFS_OSF_ENV
+#if defined(__alpha)
 #include "conf-bsd-alpha.h"
 #else
+#error unknown osf
+#endif
+#else
 #if    defined(AFS_X86_ENV)
 #include "conf-bsd-ncr.h"
 #else
 #ifdef AFS_NT40_ENV
 #include "conf-winnt.h"
 #else
+
 #ifdef AFS_XBSD_ENV
+#ifdef AFS_X86_XBSD_ENV
 #include "conf-i386-obsd.h"
+#elif defined(AFS_ALPHA_ENV)
+#include "conf-alpha-bsd.h"
 #else
+#error unknown bsd
+#endif
+#else /* AFS_XBSD_ENV */
+
 #if defined(AFS_LINUX20_ENV) || defined(AFS_DJGPP_ENV)
 #ifdef AFS_PARISC_LINUX20_ENV
 #include "conf-parisc-linux.h"
diff --git a/src/des/conf-alpha-bsd.h b/src/des/conf-alpha-bsd.h
new file mode 100644 (file)
index 0000000..3bbeefe
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 1988 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
+ *
+ * Machine-type definitions: Alpha
+ */
+
+#include <mit-cpyright.h>
+
+#define ALPHA
+
+/* 'course this is a joke, but I am not going to rewrite this mess */
+#define BITS32
+
+#define BIG
+#define LSBFIRST
+#define BSDUNIX
+#define MUSTALIGN
+
index 9fa38ef..15baf72 100644 (file)
@@ -1,15 +1,18 @@
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 
+CFLAGS=-g -I. -I${srcdir} -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCFLAGS}
+
 #  Test programs
 PROGS = \
        key_test \
        testit \
        verify
 
-INCDIRS= -I${TOP_OBJDIR}/src/config -I${DESTDIR}/include -I.. 
-LIBS=-L.. -ldes
-CFLAGS = ${INCDIRS} ${XCFLAGS}
+LDFLAGS = ${XLDFLAGS}
+
+LIBS=\
+       ${TOP_LIBDIR}/libdes.a \
 
 all test: $(PROGS)
 
@@ -22,9 +25,9 @@ kinstall:
        @echo No kernel source here.
 
 testit: testit.o 
-       ${CC} ${CFLAGS} testit.o ${LIBS} -o testit
+       ${CC} ${CFLAGS} testit.o ${LIBS} ${LDFLAGS} -o testit
 verify: verify.o ../libdes.a
-       ${CC} ${CFLAGS} verify.o ${LIBS} -o verify
+       ${CC} ${CFLAGS} verify.o ${LIBS} ${LDFLAGS} -o verify
 key_test: key_test.o ../libdes.a
-       ${CC} ${CFLAGS} key_test.o ${LIBS} -o key_test
+       ${CC} ${CFLAGS} key_test.o ${LIBS} ${LDFLAGS} -o key_test
 
index 3f330f1..ff95903 100644 (file)
@@ -31,7 +31,7 @@ int mflag;
 int pid;
 extern int des_debug;
 
-unsigned long dummy[2];
+afs_int32 dummy[2];
 unsigned char dum_c[8] = { 0x80,1,1,1,1,1,1,1 };
 des_key_schedule KS;
 des_cblock kk;
@@ -45,12 +45,6 @@ main(argc,argv)
     int i;
     progname=argv[0];          /* salt away invoking program */
 
-    /* Assume a long is four bytes */
-    if (sizeof(long) != 4) {
-       fprintf(stderr,"\nERROR,  size of long is %d",sizeof(long));
-       exit(-1);
-    }
-
     while (--argc > 0 && (*++argv)[0] == '-')
        for (i=1; argv[0][i] != '\0'; i++) {
            switch (argv[0][i]) {
@@ -116,10 +110,10 @@ main(argc,argv)
 #endif
            des_key_sched(dummy,KS);
 #ifdef BSDUNIX
-           fprintf(stderr,"\nKS= %x",* (long *)KS);
+           fprintf(stderr,"\nKS= %x",* (afs_int32 *)KS);
 #endif
 #ifdef CROSSMSDOS
-           fprintf(stderr,"\nKS= %X",* (long *)KS);
+           fprintf(stderr,"\nKS= %X",* (afs_int32 *)KS);
 #endif
            dummy[0] = 0x01010101;
            dummy[1] = 0x01010101;
@@ -131,10 +125,10 @@ main(argc,argv)
 #endif
            des_key_sched(dummy,KS);
 #ifdef BSDUNIX
-           fprintf(stderr,"\nKS= %x",  *(long *)KS);
+           fprintf(stderr,"\nKS= %x",  *(afs_int32 *)KS);
 #endif
 #ifdef CROSSMSDOS
-           fprintf(stderr,"\nKS= %X",  *(long *)KS);
+           fprintf(stderr,"\nKS= %X",  *(afs_int32 *)KS);
 #endif
 
            dummy[0] = 0x80808080;
@@ -147,10 +141,10 @@ main(argc,argv)
 #endif
            des_key_sched(dummy,KS);
 #ifdef BSDUNIX
-           fprintf(stderr,"\nKS[0]= %x",* (long * ) KS);
+           fprintf(stderr,"\nKS[0]= %x",* (afs_int32 * ) KS);
 #endif
 #ifdef CROSSMSDOS
-           fprintf(stderr,"\nKS[0]= %X",* (long * ) KS);
+           fprintf(stderr,"\nKS[0]= %X",* (afs_int32 * ) KS);
 #endif
 
            printf("\nstring to key 'a'");
@@ -163,10 +157,10 @@ main(argc,argv)
 #endif
            des_key_sched(dummy,KS);
 #ifdef BSDUNIX
-           fprintf(stderr,"\nKS= %x",* (long *) KS);
+           fprintf(stderr,"\nKS= %x",* (afs_int32 *) KS);
 #endif
 #ifdef CROSSMSDOS
-           fprintf(stderr,"\nKS= %X",* (long *) KS);
+           fprintf(stderr,"\nKS= %X",* (afs_int32 *) KS);
 #endif
 
            printf("\nstring to key 'c'");
@@ -179,10 +173,10 @@ main(argc,argv)
 #endif
            des_key_sched(dummy,KS);
 #ifdef BSDUNIX
-           fprintf(stderr,"\nKS= %x", * (long * ) KS);
+           fprintf(stderr,"\nKS= %x", * (afs_int32 * ) KS);
 #endif
 #ifdef CROSSMSDOS
-           fprintf(stderr,"\nKS= %X", * (long * ) KS);
+           fprintf(stderr,"\nKS= %X", * (afs_int32 * ) KS);
 #endif
        }
 
index 1e4367d..b51df3c 100644 (file)
@@ -62,12 +62,6 @@ main(argc,argv)
 
     progname=argv[0];              /* salt away invoking program */
 
-    /* Assume a long is four bytes */
-    if (sizeof(long) != 4) {
-       fprintf(stdout,"\nERROR,  size of long is %d",sizeof(long));
-       exit(-1);
-    }
-
     while (--argc > 0 && (*++argv)[0] == '-')
        for (i=1; argv[0][i] != '\0'; i++) {
            switch (argv[0][i]) {
index 4c491e6..4afc938 100644 (file)
@@ -68,16 +68,10 @@ main(argc,argv)
     char *argv[];
 {
     /* Local Declarations */
-    long in_length;
+    afs_int32 in_length;
 
     progname=argv[0];          /* salt away invoking program */
 
-    /* Assume a long is four bytes */
-    if (sizeof(long) != 4) {
-       printf("\nERROR,  size of long is %d",sizeof(long));
-       exit(-1);
-    }
-
     while (--argc > 0 && (*++argv)[0] == '-')
        for (i=1; argv[0][i] != '\0'; i++) {
            switch (argv[0][i]) {
@@ -187,7 +181,7 @@ main(argc,argv)
 
     printf("ACTUAL CBC\n\tclear \"%s\"\n",input);
     in_length = strlen(input);
-    des_cbc_encrypt(input,cipher_text,(long) in_length,KS,ivec,1);
+    des_cbc_encrypt(input,cipher_text,(afs_int32) in_length,KS,ivec,1);
     printf("\tciphertext = (low to high bytes)\n");
     for (i = 0; i <= 7; i++) {
        printf("\t\t");
@@ -196,7 +190,7 @@ main(argc,argv)
        }
        printf("\n");
     }
-    des_cbc_encrypt(cipher_text,clear_text,(long) in_length,KS,ivec,0);
+    des_cbc_encrypt(cipher_text,clear_text,(afs_int32) in_length,KS,ivec,0);
     printf("\tdecrypted clear_text = \"%s\"\n",clear_text);
 
     printf("EXAMPLE CBC checksum");
@@ -205,7 +199,7 @@ main(argc,argv)
     printf("\tchecksum\t58 d2 e7 7e 86 06 27 33, ");
     printf("or some part thereof\n");
     input = clear_text2;
-    des_cbc_cksum(input,cipher_text,(long) strlen(input),KS,ivec,1);
+    des_cbc_cksum(input,cipher_text,(afs_int32) strlen(input),KS,ivec,1);
     printf("ACTUAL CBC checksum\n");
     printf("\t\tencrypted cksum = (low to high bytes)\n\t\t");
     for (j = 0; j<=7; j++)