pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/digest/files Don't use u_char when uint8_t ar...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8dc33b1aa114
branches:  trunk
changeset: 533292:8dc33b1aa114
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Fri Sep 14 08:12:29 2007 +0000

description:
Don't use u_char when uint8_t are meant. Don't mess with __attribute__,
conditionally use it in the only place it is used. This should fix
problems on QNX reported by Sean Boudreau.

diffstat:

 pkgtools/digest/files/config.h.in  |  14 ++++++++------
 pkgtools/digest/files/configure.ac |  16 +++++++++-------
 pkgtools/digest/files/digest.c     |   6 +++---
 pkgtools/digest/files/rmd160.c     |  10 +++++-----
 pkgtools/digest/files/rmd160.h     |  10 +++++-----
 pkgtools/digest/files/rmd160hl.c   |  10 +++++-----
 pkgtools/digest/files/sha1.c       |  20 ++++++++++----------
 pkgtools/digest/files/sha1.h       |  12 ++++++------
 pkgtools/digest/files/sha1hl.c     |  10 +++++-----
 pkgtools/digest/files/sha2.h       |   2 +-
 pkgtools/digest/files/sha2hl.c     |  26 +++++++++++++-------------
 11 files changed, 70 insertions(+), 66 deletions(-)

diffs (truncated from 465 to 300 lines):

diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/config.h.in
--- a/pkgtools/digest/files/config.h.in Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/config.h.in Fri Sep 14 08:12:29 2007 +0000
@@ -130,18 +130,20 @@
 #undef uint8_t
 
 
-
-#ifndef HAVE___ATTRIBUTE__
-# define __attribute__(x)
-#endif
-
 #ifdef HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
 
+#if defined(__GNUC__) && !defined(__IDSTRING)
+#if (__GNUC__ == 2 && __GNUC_MINOR >= 7) || (__GNUC__ > 2)
+# define __IDSTRING(name,string) \
+       static const char name[] __attribute__((__unused__)) = string
+#endif
+#endif
+
 #ifndef __IDSTRING
 # define __IDSTRING(name,string) \
-       static const char name[] __attribute__((__unused__)) = string
+       static const char name[] = string
 #endif
 
 #ifndef  __RCSID
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/configure.ac
--- a/pkgtools/digest/files/configure.ac        Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/configure.ac        Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-dnl $Id: configure.ac,v 1.11 2007/08/03 21:42:04 tnn Exp $
+dnl $Id: configure.ac,v 1.12 2007/09/14 08:12:29 joerg Exp $
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.57)
 AC_INIT([nbsd-digest],[20070803],[agc%netbsd.org@localhost])
@@ -40,18 +40,20 @@
 AC_CHECK_FUNCS([bcopy bzero memset memcpy setlocale])
 #
 AH_BOTTOM([
-
-#ifndef HAVE___ATTRIBUTE__
-# define __attribute__(x)
-#endif
-
 #ifdef HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
 
+#if defined(__GNUC__) && !defined(__IDSTRING)
+#if (__GNUC__ == 2 && __GNUC_MINOR >= 7) || (__GNUC__ > 2)
+# define __IDSTRING(name,string) \
+       static const char name[] __attribute__((__unused__)) = string
+#endif
+#endif
+
 #ifndef __IDSTRING
 # define __IDSTRING(name,string) \
-       static const char name[] __attribute__((__unused__)) = string
+       static const char name[] = string
 #endif
 
 #ifndef  __RCSID
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/digest.c
--- a/pkgtools/digest/files/digest.c    Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/digest.c    Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: digest.c,v 1.13 2007/08/03 17:10:07 tnn Exp $ */
+/*     $NetBSD: digest.c,v 1.14 2007/09/14 08:12:29 joerg Exp $ */
 
 /*
  * Copyright (c) 2001-2005 Alistair G. Crooks.  All rights reserved.
@@ -37,7 +37,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2001-2005 \
                The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: digest.c,v 1.13 2007/08/03 17:10:07 tnn Exp $");
+__RCSID("$NetBSD: digest.c,v 1.14 2007/09/14 08:12:29 joerg Exp $");
 #endif
 
 
@@ -138,7 +138,7 @@
         if (fn == NULL) {
                (*alg->hash_init)(&alg->hash_ctx);
                 while ((cc = read(STDIN_FILENO, in, sizeof(in))) > 0) {
-                       (*alg->hash_update)(&alg->hash_ctx, (u_char *)in,
+                       (*alg->hash_update)(&alg->hash_ctx, (uint8_t *)in,
                                            (unsigned) cc);
                }
                (void) printf("%s\n", (*alg->hash_end)(&alg->hash_ctx, digest));
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/rmd160.c
--- a/pkgtools/digest/files/rmd160.c    Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/rmd160.c    Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rmd160.c,v 1.5 2007/07/27 17:08:27 joerg Exp $ */
+/*     $NetBSD: rmd160.c,v 1.6 2007/09/14 08:12:29 joerg Exp $ */
 
 /********************************************************************\
  *
@@ -23,7 +23,7 @@
 #endif
 
 #ifndef lint
-__RCSID("$NetBSD: rmd160.c,v 1.5 2007/07/27 17:08:27 joerg Exp $");
+__RCSID("$NetBSD: rmd160.c,v 1.6 2007/09/14 08:12:29 joerg Exp $");
 #endif /* not lint */
 
 /* header files */
@@ -360,7 +360,7 @@
 /********************************************************************/
 
 void
-RMD160Update(RMD160_CTX *context, const u_char *data, uint32_t nbytes)
+RMD160Update(RMD160_CTX *context, const uint8_t *data, uint32_t nbytes)
 {
        uint32_t X[16];
        uint32_t ofs = 0;
@@ -420,7 +420,7 @@
 /********************************************************************/
 
 void
-RMD160Final(u_char digest[20], RMD160_CTX *context)
+RMD160Final(uint8_t digest[20], RMD160_CTX *context)
 {
        uint32_t i;
        uint32_t X[16];
@@ -432,7 +432,7 @@
        _DIAGASSERT(context != NULL);
 
        /* append the bit m_n == 1 */
-       context->bbuffer[context->buflen] = (u_char)'\200';
+       context->bbuffer[context->buflen] = (uint8_t)'\200';
 
        ZEROIZE(context->bbuffer + context->buflen + 1,
                63 - context->buflen);
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/rmd160.h
--- a/pkgtools/digest/files/rmd160.h    Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/rmd160.h    Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rmd160.h,v 1.5 2007/08/02 13:54:34 joerg Exp $ */
+/*     $NetBSD: rmd160.h,v 1.6 2007/09/14 08:12:29 joerg Exp $ */
 
 /********************************************************************\
  *
@@ -35,19 +35,19 @@
 typedef struct {
        uint32_t        state[5];       /* state (ABCDE) */
        uint32_t        length[2];      /* number of bits */
-       u_char          bbuffer[64];    /* overflow buffer */
+       uint8_t         bbuffer[64];    /* overflow buffer */
        uint32_t        buflen;         /* number of chars in bbuffer */
 } RMD160_CTX;
 
 __BEGIN_DECLS
 void   RMD160Init(RMD160_CTX *);
 void   RMD160Transform(uint32_t[5], const uint32_t[16]);
-void   RMD160Update(RMD160_CTX *, const u_char *, uint32_t);
-void   RMD160Final(u_char[20], RMD160_CTX *);
+void   RMD160Update(RMD160_CTX *, const uint8_t *, uint32_t);
+void   RMD160Final(uint8_t[20], RMD160_CTX *);
 #ifndef        _KERNEL
 char   *RMD160End(RMD160_CTX *, char *);
 char   *RMD160File(char *, char *);
-char   *RMD160Data(const u_char *, size_t, char *);
+char   *RMD160Data(const uint8_t *, size_t, char *);
 #endif /* _KERNEL */
 __END_DECLS
 
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/rmd160hl.c
--- a/pkgtools/digest/files/rmd160hl.c  Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/rmd160hl.c  Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rmd160hl.c,v 1.4 2007/07/03 18:54:04 joerg Exp $       */
+/*     $NetBSD: rmd160hl.c,v 1.5 2007/09/14 08:12:29 joerg Exp $       */
 
 /* rmd160hl.c
  * ----------------------------------------------------------------------------
@@ -16,7 +16,7 @@
 #endif
 
 #ifndef lint
-__RCSID("$NetBSD: rmd160hl.c,v 1.4 2007/07/03 18:54:04 joerg Exp $");
+__RCSID("$NetBSD: rmd160hl.c,v 1.5 2007/09/14 08:12:29 joerg Exp $");
 #endif /* not lint */
 
 
@@ -53,7 +53,7 @@
 {
     int i;
     char *p = buf;
-    u_char digest[20];
+    uint8_t digest[20];
     static const char hex[]="0123456789abcdef";
 
     _DIAGASSERT(ctx != NULL);
@@ -74,7 +74,7 @@
 char *
 RMD160File(char *filename, char *buf)
 {
-    u_char buffer[BUFSIZ];
+    uint8_t buffer[BUFSIZ];
     RMD160_CTX ctx;
     int fd, num, oerrno;
 
@@ -96,7 +96,7 @@
 }
 
 char *
-RMD160Data(const u_char *data, size_t len, char *buf)
+RMD160Data(const uint8_t *data, size_t len, char *buf)
 {
     RMD160_CTX ctx;
 
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/sha1.c
--- a/pkgtools/digest/files/sha1.c      Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/sha1.c      Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sha1.c,v 1.7 2007/07/27 17:08:27 joerg Exp $   */
+/*     $NetBSD: sha1.c,v 1.8 2007/09/14 08:12:29 joerg Exp $   */
 /*     $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $       */
 
 /*
@@ -78,7 +78,7 @@
 #endif
 
 typedef union {
-    u_char c[64];
+    uint8_t c[64];
     u_int l[16];
 } CHAR64LONG16;
 
@@ -138,7 +138,7 @@
 /*
  * Hash a single 512-bit block. This is the core of the algorithm.
  */
-void SHA1Transform(uint32_t state[5], const u_char buffer[64])
+void SHA1Transform(uint32_t state[5], const uint8_t buffer[64])
 {
     uint32_t a, b, c, d, e;
     CHAR64LONG16 *block;
@@ -229,7 +229,7 @@
  */
 void SHA1Update(context, data, len)
     SHA1_CTX *context;
-    const u_char *data;
+    const uint8_t *data;
     u_int len;
 {
     u_int i, j;
@@ -258,27 +258,27 @@
  * Add padding and return the message digest.
  */
 void SHA1Final(digest, context)
-    u_char digest[20];
+    uint8_t digest[20];
     SHA1_CTX* context;
 {
     u_int i;
-    u_char finalcount[8];
+    uint8_t finalcount[8];
 
     _DIAGASSERT(digest != 0);
     _DIAGASSERT(context != 0);
 
     for (i = 0; i < 8; i++) {
-       finalcount[i] = (u_char)((context->count[(i >= 4 ? 0 : 1)]
+       finalcount[i] = (uint8_t)((context->count[(i >= 4 ? 0 : 1)]
         >> ((3-(i & 3)) * 8) ) & 255);  /* Endian independent */
     }
-    SHA1Update(context, (const u_char *)"\200", 1);
+    SHA1Update(context, (const uint8_t *)"\200", 1);
     while ((context->count[0] & 504) != 448)
-       SHA1Update(context, (const u_char *)"\0", 1);
+       SHA1Update(context, (const uint8_t *)"\0", 1);
     SHA1Update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
 
     if (digest) {
        for (i = 0; i < 20; i++)
-           digest[i] = (u_char)
+           digest[i] = (uint8_t)
                ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
     }
 }
diff -r 6123db87345e -r 8dc33b1aa114 pkgtools/digest/files/sha1.h
--- a/pkgtools/digest/files/sha1.h      Fri Sep 14 07:39:31 2007 +0000
+++ b/pkgtools/digest/files/sha1.h      Fri Sep 14 08:12:29 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sha1.h,v 1.5 2007/08/02 13:54:34 joerg Exp $   */
+/*     $NetBSD: sha1.h,v 1.6 2007/09/14 08:12:29 joerg Exp $   */
 
 /*
  * SHA-1 in C
@@ -20,17 +20,17 @@
 typedef struct {
        uint32_t state[5];
        uint32_t count[2];  
-       u_char buffer[64];



Home | Main Index | Thread Index | Old Index