Source-Changes-HG archive

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

[src/trunk]: src/lib/libc The weak alias macros can only work before namespac...



details:   https://anonhg.NetBSD.org/src/rev/be250a52a56c
branches:  trunk
changeset: 584680:be250a52a56c
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Sep 26 03:01:41 2005 +0000

description:
The weak alias macros can only work before namespace.h gets included because
when the strings get expanded we gain an _ from namespace.h. So define a
macro to point to the appropriate include file for the hash function, and
include the hash function later, from the .c file we always include. This
allows us to eliminate the hack of including namespace.h twice as well as
nbtool_config.h.

diffstat:

 lib/libc/hash/hash.c            |  45 ++++++++++++++++++++++------------------
 lib/libc/hash/md2/md2hl.c       |  12 ++--------
 lib/libc/hash/rmd160/rmd160hl.c |  12 ++--------
 lib/libc/hash/sha1/sha1hl.c     |  12 ++--------
 lib/libc/hash/sha2/sha256hl.c   |  12 ++--------
 lib/libc/hash/sha2/sha384hl.c   |  12 ++--------
 lib/libc/hash/sha2/sha512hl.c   |  12 ++--------
 lib/libc/md/md4hl.c             |  14 ++----------
 lib/libc/md/md5hl.c             |  14 ++----------
 lib/libc/md/mdXhl.c             |  25 +++++++++++++++++++---
 10 files changed, 70 insertions(+), 100 deletions(-)

diffs (truncated from 348 to 300 lines):

diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/hash.c
--- a/lib/libc/hash/hash.c      Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/hash.c      Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.c,v 1.4 2005/09/25 22:20:59 elad Exp $ */
+/* $NetBSD: hash.c,v 1.5 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * ----------------------------------------------------------------------------
@@ -16,7 +16,31 @@
 
 #ifdef HASH_ALGORITHM
 
+/*
+ * Do all the name mangling before we include "namespace.h"
+ */
+#define        CONCAT(x,y)     __CONCAT(x,y)
+
+#ifndef HASH_FNPREFIX
+#define        HASH_FNPREFIX   HASH_ALGORITHM
+#endif /* !HASH_FNPREFIX */
+
+#define        FNPREFIX(x)     CONCAT(HASH_FNPREFIX,x)
+#define        HASH_CTX        CONCAT(HASH_ALGORITHM,_CTX)
+#define        HASH_LEN        CONCAT(HASH_ALGORITHM,_DIGEST_LENGTH)
+#define        HASH_STRLEN     CONCAT(HASH_ALGORITHM,_DIGEST_STRING_LENGTH)
+
+#if !defined(_KERNEL) && defined(__weak_alias)
+#define        WA(a,b) __weak_alias(a,b)
+WA(FNPREFIX(End),CONCAT(_,FNPREFIX(End)))
+WA(FNPREFIX(FileChunk),CONCAT(_,FNPREFIX(FileChunk)))
+WA(FNPREFIX(File),CONCAT(_,FNPREFIX(File)))
+WA(FNPREFIX(Data),CONCAT(_,FNPREFIX(Data)))
+#undef WA
+#endif
+
 #include "namespace.h"
+#include HASH_INCLUDE
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -36,25 +60,6 @@
 #define        MIN(x,y)        ((x)<(y)?(x):(y))
 #endif /* !MIN */
 
-#define        CONCAT(x,y)     __CONCAT(x,y)
-
-#ifndef HASH_FNPREFIX
-#define        HASH_FNPREFIX   HASH_ALGORITHM
-#endif /* !HASH_FNPREFIX */
-
-#define        FNPREFIX(x)     CONCAT(HASH_FNPREFIX,x)
-#define        HASH_CTX        CONCAT(HASH_ALGORITHM,_CTX)
-#define        HASH_LEN        CONCAT(HASH_ALGORITHM,_DIGEST_LENGTH)
-#define        HASH_STRLEN     CONCAT(HASH_ALGORITHM,_DIGEST_STRING_LENGTH)
-
-#if !defined(_KERNEL) && defined(__weak_alias)
-#define        WA(a,b) __weak_alias(a,b)
-WA(FNPREFIX(End),CONCAT(_,FNPREFIX(End)))
-WA(FNPREFIX(FileChunk),CONCAT(_,FNPREFIX(FileChunk)))
-WA(FNPREFIX(File),CONCAT(_,FNPREFIX(File)))
-WA(FNPREFIX(Data),CONCAT(_,FNPREFIX(Data)))
-#undef WA
-#endif
 
 char *
 FNPREFIX(End)(HASH_CTX *ctx, char *buf)
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/md2/md2hl.c
--- a/lib/libc/hash/md2/md2hl.c Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/md2/md2hl.c Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md2hl.c,v 1.1 2005/09/24 20:51:14 elad Exp $ */
+/* $NetBSD: md2hl.c,v 1.2 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * Derived from code ritten by Jason R. Thorpe <thorpej%NetBSD.org@localhost>,
@@ -8,16 +8,10 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: md2hl.c,v 1.1 2005/09/24 20:51:14 elad Exp $");
+__RCSID("$NetBSD: md2hl.c,v 1.2 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        HASH_ALGORITHM  MD2
-
-#include "namespace.h"
-#include <md2.h> /* XXX */
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
+#define HASH_INCLUDE   <md2.h>
 
 #include "../hash.c"
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/rmd160/rmd160hl.c
--- a/lib/libc/hash/rmd160/rmd160hl.c   Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/rmd160/rmd160hl.c   Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160hl.c,v 1.2 2005/09/24 19:33:52 elad Exp $ */
+/* $NetBSD: rmd160hl.c,v 1.3 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * Derived from code ritten by Jason R. Thorpe <thorpej%NetBSD.org@localhost>,
@@ -8,16 +8,10 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: rmd160hl.c,v 1.2 2005/09/24 19:33:52 elad Exp $");
+__RCSID("$NetBSD: rmd160hl.c,v 1.3 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        HASH_ALGORITHM  RMD160
-
-#include "namespace.h"
-#include <crypto/rmd160.h>
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
+#define HASH_INCLUDE   <crypto/rmd160.h>
 
 #include "../hash.c"
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/sha1/sha1hl.c
--- a/lib/libc/hash/sha1/sha1hl.c       Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/sha1/sha1hl.c       Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1hl.c,v 1.1 2005/09/24 19:04:52 elad Exp $ */
+/* $NetBSD: sha1hl.c,v 1.2 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * Derived from code ritten by Jason R. Thorpe <thorpej%NetBSD.org@localhost>,
@@ -8,16 +8,10 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha1hl.c,v 1.1 2005/09/24 19:04:52 elad Exp $");
+__RCSID("$NetBSD: sha1hl.c,v 1.2 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        HASH_ALGORITHM  SHA1
-
-#include "namespace.h"
-#include <sha1.h> /* XXX */
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
+#define HASH_INCLUDE   <sha1.h>
 
 #include "../hash.c"
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/sha2/sha256hl.c
--- a/lib/libc/hash/sha2/sha256hl.c     Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/sha2/sha256hl.c     Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sha256hl.c,v 1.4 2005/09/24 18:49:18 elad Exp $ */
+/* $NetBSD: sha256hl.c,v 1.5 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * Derived from code ritten by Jason R. Thorpe <thorpej%NetBSD.org@localhost>,
@@ -8,17 +8,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha256hl.c,v 1.4 2005/09/24 18:49:18 elad Exp $");
+__RCSID("$NetBSD: sha256hl.c,v 1.5 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        HASH_ALGORITHM  SHA256
 #define        HASH_FNPREFIX   SHA256_
-
-#include "namespace.h"
-#include <crypto/sha2.h>
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
+#define HASH_INCLUDE   <crypto/sha2.h>
 
 #include "../hash.c"
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/sha2/sha384hl.c
--- a/lib/libc/hash/sha2/sha384hl.c     Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/sha2/sha384hl.c     Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sha384hl.c,v 1.4 2005/09/24 18:49:18 elad Exp $ */
+/* $NetBSD: sha384hl.c,v 1.5 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * Derived from code ritten by Jason R. Thorpe <thorpej%NetBSD.org@localhost>,
@@ -8,17 +8,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha384hl.c,v 1.4 2005/09/24 18:49:18 elad Exp $");
+__RCSID("$NetBSD: sha384hl.c,v 1.5 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        HASH_ALGORITHM  SHA384
 #define        HASH_FNPREFIX   SHA384_
-
-#include "namespace.h"
-#include <crypto/sha2.h>
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
+#define HASH_INCLUDE   <crypto/sha2.h>
 
 #include "../hash.c"
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/hash/sha2/sha512hl.c
--- a/lib/libc/hash/sha2/sha512hl.c     Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/hash/sha2/sha512hl.c     Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sha512hl.c,v 1.4 2005/09/24 18:49:18 elad Exp $ */
+/* $NetBSD: sha512hl.c,v 1.5 2005/09/26 03:01:41 christos Exp $ */
 
 /*
  * Derived from code ritten by Jason R. Thorpe <thorpej%NetBSD.org@localhost>,
@@ -8,17 +8,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha512hl.c,v 1.4 2005/09/24 18:49:18 elad Exp $");
+__RCSID("$NetBSD: sha512hl.c,v 1.5 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        HASH_ALGORITHM  SHA512
 #define        HASH_FNPREFIX   SHA512_
-
-#include "namespace.h"
-#include <crypto/sha2.h>
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
+#define HASH_INCLUDE   <crypto/sha2.h>
 
 #include "../hash.c"
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/md/md4hl.c
--- a/lib/libc/md/md4hl.c       Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/md/md4hl.c       Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md4hl.c,v 1.6 2005/06/12 05:34:34 lukem Exp $  */
+/*     $NetBSD: md4hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $       */
 
 /*
  * Written by Jason R. Thorpe <thorpej%NetBSD.org@localhost>, April 29, 1997.
@@ -7,18 +7,10 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: md4hl.c,v 1.6 2005/06/12 05:34:34 lukem Exp $");
+__RCSID("$NetBSD: md4hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        MDALGORITHM     MD4
-
-#include "namespace.h"
-#include <md4.h>
+#define MDINCLUDE      <md4.h>
 
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
-
-#if !HAVE_MD4_H
 #include "mdXhl.c"
-#endif
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/md/md5hl.c
--- a/lib/libc/md/md5hl.c       Mon Sep 26 02:59:29 2005 +0000
+++ b/lib/libc/md/md5hl.c       Mon Sep 26 03:01:41 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md5hl.c,v 1.6 2005/06/12 05:34:34 lukem Exp $  */
+/*     $NetBSD: md5hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $       */
 
 /*
  * Written by Jason R. Thorpe <thorpej%NetBSD.org@localhost>, April 29, 1997.
@@ -7,18 +7,10 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: md5hl.c,v 1.6 2005/06/12 05:34:34 lukem Exp $");
+__RCSID("$NetBSD: md5hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #define        MDALGORITHM     MD5
-
-#include "namespace.h"
-#include <md5.h>
+#define MDINCLUDE      <md5.h>
 
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
-
-#if !HAVE_MD5_H
 #include "mdXhl.c"
-#endif
diff -r 9a0d4aa839dd -r be250a52a56c lib/libc/md/mdXhl.c
--- a/lib/libc/md/mdXhl.c       Mon Sep 26 02:59:29 2005 +0000



Home | Main Index | Thread Index | Old Index