bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] lib/sha1.h: wrap declarations in extern "C" scope when inclu


From: Jim Meyering
Subject: Re: [PATCH] lib/sha1.h: wrap declarations in extern "C" scope when included from C++
Date: Wed, 22 Jul 2009 15:36:55 +0200

Peter Simons wrote:
> Hi Jim,
>
>  > Would you please adjust that patch to do the same for all lib/sha*.h
>  > files as well as lib/md5.h, and (if Simon agrees) lib/md[24].h?
>
> sure, the updated patch is attached below.

Thanks.
I've pushed them, after adding a ChangeLog entry to each.

>From abc4e3f768914ecc82270adfccef5f3f7777ea98 Mon Sep 17 00:00:00 2001
From: Peter Simons <address@hidden>
Date: Tue, 21 Jul 2009 15:23:55 +0200
Subject: [PATCH 1/2] tests-sha1: don't assign literal string to 'char *' 
variable

* tests/test-sha1.c (main): Declare locals with "const" to match
attributes of the right hand side.
---
 ChangeLog         |    6 ++++++
 tests/test-sha1.c |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2bb96cf..718af87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-07-22  Peter Simons  <address@hidden>
+
+       tests-sha1: don't assign literal string to 'char *' variable
+       * tests/test-sha1.c (main): Declare locals with "const" to match
+       attributes of the right hand side.
+
 2009-07-21  Eric Blake  <address@hidden>

        dup2: fix more mingw problems
diff --git a/tests/test-sha1.c b/tests/test-sha1.c
index 0cfb309..4742138 100644
--- a/tests/test-sha1.c
+++ b/tests/test-sha1.c
@@ -25,8 +25,8 @@
 int
 main (int argc, char *argv[])
 {
-  char *in1 = "abcdefgh";
-  char *out1 = "\x42\x5a\xf1\x2a\x07\x43\x50\x2b"
+  const char *in1 = "abcdefgh";
+  const char *out1 = "\x42\x5a\xf1\x2a\x07\x43\x50\x2b"
     "\x32\x2e\x93\xa0\x15\xbc\xf8\x68\xe3\x24\xd5\x6a";
   char buf[SHA1_DIGEST_SIZE];

--
1.6.4.rc1.189.g9f628


>From e89d33fe93612a3e0024c5d2d3751c3f722de939 Mon Sep 17 00:00:00 2001
From: Peter Simons <address@hidden>
Date: Tue, 21 Jul 2009 15:22:24 +0200
Subject: [PATCH 2/2] C++: wrap md2,md5,sha1,etc. function declarations in 
extern "C" scope

* lib/md2.h [__cplusplus]: Wrap declarations in extern "C" scope.
* lib/md4.h: Likewise.
* lib/md5.h: Likewise.
* lib/sha1.h: Likewise.
* lib/sha256.h: Likewise.
* lib/sha512.h: Likewise.
---
 ChangeLog    |    8 ++++++++
 lib/md2.h    |    8 ++++++++
 lib/md4.h    |    8 ++++++++
 lib/md5.h    |    8 ++++++++
 lib/sha1.h   |    8 ++++++++
 lib/sha256.h |    8 ++++++++
 lib/sha512.h |    8 ++++++++
 7 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 718af87..cca4ce9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-07-22  Peter Simons  <address@hidden>

+       C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
+       * lib/md2.h [__cplusplus]: Wrap declarations in extern "C" scope.
+       * lib/md4.h: Likewise.
+       * lib/md5.h: Likewise.
+       * lib/sha1.h: Likewise.
+       * lib/sha256.h: Likewise.
+       * lib/sha512.h: Likewise.
+
        tests-sha1: don't assign literal string to 'char *' variable
        * tests/test-sha1.c (main): Declare locals with "const" to match
        attributes of the right hand side.
diff --git a/lib/md2.h b/lib/md2.h
index 401604e..3535e29 100644
--- a/lib/md2.h
+++ b/lib/md2.h
@@ -22,6 +22,10 @@
 # include <stdio.h>
 # include <stddef.h>

+# ifdef __cplusplus
+extern "C" {
+# endif
+
 # define MD2_DIGEST_SIZE 16

 /* Structure to save state of computation between the single steps.  */
@@ -73,4 +77,8 @@ extern int md2_stream (FILE *stream, void *resblock);
    digest.  */
 extern void *md2_buffer (const char *buffer, size_t len, void *resblock);

+# ifdef __cplusplus
+}
+# endif
+
 #endif
diff --git a/lib/md4.h b/lib/md4.h
index 937794c..6b49da5 100644
--- a/lib/md4.h
+++ b/lib/md4.h
@@ -22,6 +22,10 @@
 # include <stdio.h>
 # include <stdint.h>

+# ifdef __cplusplus
+extern "C" {
+# endif
+
 # define MD4_DIGEST_SIZE 16

 /* Structure to save state of computation between the single steps.  */
@@ -79,4 +83,8 @@ extern int md4_stream (FILE * stream, void *resblock);
    digest.  */
 extern void *md4_buffer (const char *buffer, size_t len, void *resblock);

+# ifdef __cplusplus
+}
+# endif
+
 #endif
diff --git a/lib/md5.h b/lib/md5.h
index 3ae657b..0769edb 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -54,6 +54,10 @@
 # define __md5_stream md5_stream
 #endif

+# ifdef __cplusplus
+extern "C" {
+# endif
+
 /* Structure to save state of computation between the single steps.  */
 struct md5_ctx
 {
@@ -115,4 +119,8 @@ extern int __md5_stream (FILE *stream, void *resblock) 
__THROW;
 extern void *__md5_buffer (const char *buffer, size_t len,
                           void *resblock) __THROW;

+# ifdef __cplusplus
+}
+# endif
+
 #endif /* md5.h */
diff --git a/lib/sha1.h b/lib/sha1.h
index 4ffda7a..93babd2 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -23,6 +23,10 @@
 # include <stdio.h>
 # include <stdint.h>

+# ifdef __cplusplus
+extern "C" {
+# endif
+
 #define SHA1_DIGEST_SIZE 20

 /* Structure to save state of computation between the single steps.  */
@@ -81,4 +85,8 @@ extern int sha1_stream (FILE *stream, void *resblock);
    digest.  */
 extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);

+# ifdef __cplusplus
+}
+# endif
+
 #endif
diff --git a/lib/sha256.h b/lib/sha256.h
index a63b201..3dfcb26 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -21,6 +21,10 @@
 # include <stdio.h>
 # include <stdint.h>

+# ifdef __cplusplus
+extern "C" {
+# endif
+
 /* Structure to save state of computation between the single steps.  */
 struct sha256_ctx
 {
@@ -80,4 +84,8 @@ extern int sha224_stream (FILE *stream, void *resblock);
 extern void *sha256_buffer (const char *buffer, size_t len, void *resblock);
 extern void *sha224_buffer (const char *buffer, size_t len, void *resblock);

+# ifdef __cplusplus
+}
+# endif
+
 #endif
diff --git a/lib/sha512.h b/lib/sha512.h
index ed12d54..20bb09b 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -22,6 +22,10 @@

 # include "u64.h"

+# ifdef __cplusplus
+extern "C" {
+# endif
+
 /* Structure to save state of computation between the single steps.  */
 struct sha512_ctx
 {
@@ -84,4 +88,8 @@ extern int sha384_stream (FILE *stream, void *resblock);
 extern void *sha512_buffer (const char *buffer, size_t len, void *resblock);
 extern void *sha384_buffer (const char *buffer, size_t len, void *resblock);

+# ifdef __cplusplus
+}
+# endif
+
 #endif
--
1.6.4.rc1.189.g9f628




reply via email to

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