bug-gnulib
[Top][All Lists]
Advanced

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

gc split


From: Simon Josefsson
Subject: gc split
Date: Wed, 12 Oct 2005 03:16:15 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

This make it possible to use only parts of gc, without requiring all
sub-modules.  This will be more important later on, when there will be
many gc-* sub-modules.

I have installed the patch below.

There is a problem (not introduce by this patch though), in that the
gc modules does not use "depends:" to handle dependencies.  I.e.,
gc-md5 should ideally depend on md5.  The problem is that we don't
want gc_MD5 to be called unconditionally, since it uses AC_LIBOBJ
which causes potentially unwanted objects to be built.  This is
particularly ugly in gc-hmac-md5, because it has to duplicate the
hmac-md5 module AND its dependencies (memxor).

I think a better solution would be to modify md5.m4 and hmac-md5.m4 to
make them aware of GC, and only call AC_LIBOBJ if either GC isn't used
or GC didn't use libgcrypt.

This could be another manifestation of problems caused by using
AC_LIBOBJ in *.m4's, or rather, deciding and naming which files should
be built in *.m4's rather than Makefile.am's.  If we used the
pre-AC_LIBOBJ style, we could simply have used an automake conditional
in the md5 module a'la:

if !GC_USE_MD5
libgl_la_SOURCES = md5.h md5.c
endif

and the gc-md5 could define that automake conditional.  gc-md5 could
depend on the md5 module without trouble.

Thoughts?

Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/ChangeLog,v
retrieving revision 1.412
diff -u -p -r1.412 ChangeLog
--- ChangeLog   11 Oct 2005 18:50:37 -0000      1.412
+++ ChangeLog   12 Oct 2005 01:08:03 -0000
@@ -1,3 +1,9 @@
+2005-10-12  Simon Josefsson  <address@hidden>
+
+       * modules/gc-md5, modules/gc-hmac-md5: New files.
+
+       * modules/gc (Files): Remove md5, memxor and hmac files.
+
 2005-10-11  Bruno Haible  <address@hidden>
 
        * modules/c-strcasestr: New file.
Index: m4/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/ChangeLog,v
retrieving revision 1.735
diff -u -p -r1.735 ChangeLog
--- m4/ChangeLog        11 Oct 2005 18:25:51 -0000      1.735
+++ m4/ChangeLog        12 Oct 2005 01:08:03 -0000
@@ -1,3 +1,9 @@
+2005-10-12  Simon Josefsson  <address@hidden>
+
+       * gc-md5.m4, gc-hmac-md5: New files.
+
+       * gc.m4: Don't call gl_MD5, gl_MEMXOR or gl_HMAC_MD5.
+
 2005-10-11  Simon Josefsson  <address@hidden>
 
        * crc.m4: New file.
Index: m4/gc.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/gc.m4,v
retrieving revision 1.1
diff -u -p -r1.1 gc.m4
--- m4/gc.m4    8 Oct 2005 08:33:08 -0000       1.1
+++ m4/gc.m4    12 Oct 2005 01:08:03 -0000
@@ -18,9 +18,6 @@ AC_DEFUN([gl_GC],
     AC_LIBOBJ([gc-libgcrypt])
   else
     AC_LIBOBJ([gc-gnulib])
-    gl_MD5
-    gl_MEMXOR
-    gl_HMAC_MD5
 
     # Devices with randomness.
     # FIXME: Are these the best defaults?
Index: m4/gc-md5.m4
===================================================================
RCS file: m4/gc-md5.m4
diff -N m4/gc-md5.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/gc-md5.m4        12 Oct 2005 01:08:03 -0000
@@ -0,0 +1,14 @@
+# gc-md5.m4 serial 1
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_GC_MD5],
+[
+  AC_REQUIRE([gl_GC])
+  AC_DEFINE(GC_USE_MD5, 1, [Define to if you want to support MD5 through GC.])
+  if test "$ac_cv_libgcrypt" != yes; then
+    gl_MD5
+  fi
+])
Index: m4/gc-hmac-md5.m4
===================================================================
RCS file: m4/gc-hmac-md5.m4
diff -N m4/gc-hmac-md5.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/gc-hmac-md5.m4   12 Oct 2005 01:08:03 -0000
@@ -0,0 +1,17 @@
+# gc-hmac-md5.m4 serial 1
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_GC_HMAC_MD5],
+[
+  AC_REQUIRE([gl_GC])
+  AC_DEFINE(GC_USE_HMAC_MD5, 1,
+    [Define to if you want to support HMAC-MD5 through GC.])
+  if test "$ac_cv_libgcrypt" != yes; then
+    gl_MD5
+    gl_HMAC_MD5
+    gl_MEMXOR
+  fi
+])
Index: lib/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.1005
diff -u -p -r1.1005 ChangeLog
--- lib/ChangeLog       12 Oct 2005 00:23:38 -0000      1.1005
+++ lib/ChangeLog       12 Oct 2005 01:08:03 -0000
@@ -1,5 +1,8 @@
 2005-10-12  Simon Josefsson  <address@hidden>
 
+       * gc-gnulib.c: Condition MD5 and HMAC-MD5 use on GC_USE_MD5 and
+       GC_USE_HMAC_MD5, respectively.
+
        * gc-libgcrypt.c (gc_md5): Fix assert call.
        (gc_md5): Fix typo.
 
Index: lib/gc-gnulib.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/gc-gnulib.c,v
retrieving revision 1.3
diff -u -p -r1.3 gc-gnulib.c
--- lib/gc-gnulib.c     12 Oct 2005 00:23:38 -0000      1.3
+++ lib/gc-gnulib.c     12 Oct 2005 01:08:03 -0000
@@ -37,8 +37,12 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#include "md5.h"
-#include "hmac.h"
+#ifdef GC_USE_MD5
+# include "md5.h"
+#endif
+#ifdef GC_USE_HMAC_MD5
+# include "hmac.h"
+#endif
 
 int
 gc_init (void)
@@ -142,9 +146,11 @@ gc_hash_buffer (Gc_hash hash, const void
 {
   switch (hash)
     {
+#ifdef GC_USE_MD5
     case GC_MD5:
       md5_buffer (in, inlen, resbuf);
       break;
+#endif
 
     default:
       return GC_INVALID_HASH;
@@ -153,13 +159,16 @@ gc_hash_buffer (Gc_hash hash, const void
   return GC_OK;
 }
 
+#ifdef GC_USE_MD5
 int
 gc_md5 (const void *in, size_t inlen, void *resbuf)
 {
   md5_buffer (in, inlen, resbuf);
   return 0;
 }
+#endif
 
+#ifdef GC_USE_HMAC_MD5
 int
 gc_hmac_md5 (const void *key, size_t keylen,
             const void *in, size_t inlen, char *resbuf)
@@ -167,3 +176,4 @@ gc_hmac_md5 (const void *key, size_t key
   hmac_md5 (key, keylen, in, inlen, resbuf);
   return 0;
 }
+#endif
Index: lib/gc-libgcrypt.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/gc-libgcrypt.c,v
retrieving revision 1.3
diff -u -p -r1.3 gc-libgcrypt.c
--- lib/gc-libgcrypt.c  12 Oct 2005 00:23:38 -0000      1.3
+++ lib/gc-libgcrypt.c  12 Oct 2005 01:08:03 -0000
@@ -103,9 +103,11 @@ gc_hash_buffer (Gc_hash hash, const void
 
   switch (hash)
     {
+#ifdef GC_USE_MD5
     case GC_MD5:
       gcryalg = GCRY_MD_MD5;
       break;
+#endif
 
     default:
       return GC_INVALID_HASH;
@@ -118,6 +120,7 @@ gc_hash_buffer (Gc_hash hash, const void
 
 /* One-call interface. */
 
+#ifdef GC_USE_MD5
 int
 gc_md5 (const void *in, size_t inlen, void *resbuf)
 {
@@ -147,7 +150,9 @@ gc_md5 (const void *in, size_t inlen, vo
 
   return GC_OK;
 }
+#endif
 
+#ifdef GC_USE_HMAC_MD5
 int
 gc_hmac_md5 (const void *key, size_t keylen,
             const void *in, size_t inlen, char *resbuf)
@@ -185,3 +190,4 @@ gc_hmac_md5 (const void *key, size_t key
 
   return GC_OK;
 }
+#endif
Index: modules/gc
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/gc,v
retrieving revision 1.1
diff -u -p -r1.1 gc
--- modules/gc  8 Oct 2005 08:33:08 -0000       1.1
+++ modules/gc  12 Oct 2005 01:08:03 -0000
@@ -6,16 +6,6 @@ lib/gc.h
 lib/gc-libgcrypt.c
 lib/gc-gnulib.c
 m4/gc.m4
-lib/md5.h
-lib/md5.c
-m4/md5.m4
-m4/uint32_t.m4
-lib/hmac.h
-lib/hmac-md5.c
-m4/hmac-md5.m4
-lib/memxor.h
-lib/memxor.c
-m4/memxor.m4
 
 Depends-on:
 havelib
Index: modules/gc-md5
===================================================================
RCS file: modules/gc-md5
diff -N modules/gc-md5
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/gc-md5      12 Oct 2005 01:08:03 -0000
@@ -0,0 +1,26 @@
+Description:
+Generic crypto wrappers for MD5 functions.
+
+Files:
+m4/gc-md5.m4
+lib/md5.h
+lib/md5.c
+m4/md5.m4
+
+Depends-on:
+stdint
+gc
+
+configure.ac:
+gl_GC_MD5
+
+Makefile.am:
+
+Include:
+"gc.h"
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson
Index: modules/gc-hmac-md5
===================================================================
RCS file: modules/gc-hmac-md5
diff -N modules/gc-hmac-md5
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/gc-hmac-md5 12 Oct 2005 01:08:03 -0000
@@ -0,0 +1,32 @@
+Description:
+Generic crypto wrappers for HMAC-MD5 functions.
+
+Files:
+m4/gc-hmac-md5.m4
+lib/md5.h
+lib/md5.c
+m4/md5.m4
+lib/hmac.h
+lib/hmac-md5.c
+m4/hmac-md5.m4
+lib/memxor.h
+lib/memxor.c
+m4/memxor.m4
+
+Depends-on:
+stdint
+gc
+
+configure.ac:
+gl_GC_HMAC_MD5
+
+Makefile.am:
+
+Include:
+"gc.h"
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson




reply via email to

[Prev in Thread] Current Thread [Next in Thread]