Commit bb131b2e87b43023655995f5c5d8d4191686f6e3

Michael Haubenwallner 2017-04-10T13:10:38

Stop using non-portable <sys/cdefs.h> For portability, we should not rely on the __BEGIN_DECLS, __END_DECLS and __P to be predefined somewhere. For __P, we just remove its usage as we do not support pre-ANSI-C compilers. [guillem@hadrons.org: - Separate extern declarations with newlines. - Slightly reword commit message. ] Signed-off-by: Guillem Jover <guillem@hadrons.org>

diff --git a/include/md2.h b/include/md2.h
index 7832905..d4ca22a 100644
--- a/include/md2.h
+++ b/include/md2.h
@@ -3,7 +3,6 @@
 #ifndef _MD2_H_
 #define _MD2_H_
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <stdint.h>
@@ -18,7 +17,10 @@ typedef struct MD2Context {
 	unsigned char X[48];		/* input buffer */
 } MD2_CTX;
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void	MD2Init(MD2_CTX *);
 void	MD2Update(MD2_CTX *, const unsigned char *, unsigned int);
 void	MD2Final(unsigned char[16], MD2_CTX *);
@@ -26,6 +28,9 @@ char	*MD2End(MD2_CTX *, char *);
 char	*MD2File(const char *, char *);
 char	*MD2FileChunk(const char *, char *, off_t, off_t);
 char	*MD2Data(const unsigned char *, size_t, char *);
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _MD2_H_ */
diff --git a/include/md4.h b/include/md4.h
index ccd524f..c4942b8 100644
--- a/include/md4.h
+++ b/include/md4.h
@@ -16,7 +16,6 @@
 #ifndef _MD4_H_
 #define _MD4_H_
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <stdint.h>
@@ -31,7 +30,10 @@ typedef struct MD4Context {
 	uint8_t buffer[MD4_BLOCK_LENGTH];	/* input buffer */
 } MD4_CTX;
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void	 MD4Init(MD4_CTX *);
 void	 MD4Update(MD4_CTX *, const uint8_t *, size_t);
 void	 MD4Pad(MD4_CTX *);
@@ -41,6 +43,9 @@ char	*MD4End(MD4_CTX *, char *);
 char	*MD4File(const char *, char *);
 char	*MD4FileChunk(const char *, char *, off_t, off_t);
 char	*MD4Data(const uint8_t *, size_t, char *);
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _MD4_H_ */
diff --git a/include/md5.h b/include/md5.h
index 0a0a4ff..dee2bf4 100644
--- a/include/md5.h
+++ b/include/md5.h
@@ -15,7 +15,6 @@
 #ifndef _MD5_H_
 #define _MD5_H_
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <stdint.h>
@@ -30,7 +29,10 @@ typedef struct MD5Context {
 	uint8_t buffer[MD5_BLOCK_LENGTH];	/* input buffer */
 } MD5_CTX;
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void	 MD5Init(MD5_CTX *);
 void	 MD5Update(MD5_CTX *, const uint8_t *, size_t);
 void	 MD5Pad(MD5_CTX *);
@@ -40,6 +42,9 @@ char	*MD5End(MD5_CTX *, char *);
 char	*MD5File(const char *, char *);
 char	*MD5FileChunk(const char *, char *, off_t, off_t);
 char	*MD5Data(const uint8_t *, size_t, char *);
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _MD5_H_ */
diff --git a/include/rmd160.h b/include/rmd160.h
index b9fef11..f8a7afa 100644
--- a/include/rmd160.h
+++ b/include/rmd160.h
@@ -25,7 +25,6 @@
 #ifndef  _RMD160_H
 #define  _RMD160_H
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <stdint.h>
@@ -41,7 +40,10 @@ typedef struct RMD160Context {
 	uint8_t buffer[RMD160_BLOCK_LENGTH];	/* input buffer */
 } RMD160_CTX;
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void	 RMD160Init(RMD160_CTX *);
 void	 RMD160Transform(uint32_t [5], const uint8_t [RMD160_BLOCK_LENGTH]);
 void	 RMD160Update(RMD160_CTX *, const uint8_t *, size_t);
@@ -51,6 +53,9 @@ char	*RMD160End(RMD160_CTX *, char *);
 char	*RMD160File(const char *, char *);
 char	*RMD160FileChunk(const char *, char *, off_t, off_t);
 char	*RMD160Data(const uint8_t *, size_t, char *);
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif  /* _RMD160_H */
diff --git a/include/sha1.h b/include/sha1.h
index bf21e58..40a53a1 100644
--- a/include/sha1.h
+++ b/include/sha1.h
@@ -9,7 +9,6 @@
 #ifndef _SHA1_H
 #define _SHA1_H
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <stdint.h>
@@ -24,7 +23,10 @@ typedef struct {
     uint8_t buffer[SHA1_BLOCK_LENGTH];
 } SHA1_CTX;
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void SHA1Init(SHA1_CTX *);
 void SHA1Pad(SHA1_CTX *);
 void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]);
@@ -34,7 +36,10 @@ char *SHA1End(SHA1_CTX *, char *);
 char *SHA1File(const char *, char *);
 char *SHA1FileChunk(const char *, char *, off_t, off_t);
 char *SHA1Data(const uint8_t *, size_t, char *);
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
 
 #define HTONDIGEST(x) do {                                              \
         x[0] = htonl(x[0]);                                             \
diff --git a/include/sha2.h b/include/sha2.h
index 9cfd273..0387ea3 100644
--- a/include/sha2.h
+++ b/include/sha2.h
@@ -37,7 +37,6 @@
 #ifndef _SHA2_H
 #define _SHA2_H
 
-#include <sys/cdefs.h>
 #include <sys/types.h>
 
 #include <stdint.h>
@@ -64,7 +63,10 @@ typedef struct _SHA2_CTX {
 	uint8_t		buffer[SHA512_BLOCK_LENGTH];
 } SHA2_CTX;
 
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void SHA256Init(SHA2_CTX *);
 void SHA256Transform(uint32_t state[8], const uint8_t [SHA256_BLOCK_LENGTH]);
 void SHA256Update(SHA2_CTX *, const uint8_t *, size_t);
@@ -94,6 +96,9 @@ char *SHA512End(SHA2_CTX *, char *);
 char *SHA512File(const char *, char *);
 char *SHA512FileChunk(const char *, char *, off_t, off_t);
 char *SHA512Data(const uint8_t *, size_t, char *);
-__END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _SHA2_H */
diff --git a/src/md2.c b/src/md2.c
index b01fe60..20487f0 100644
--- a/src/md2.c
+++ b/src/md2.c
@@ -29,7 +29,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 __RCSID("$NetBSD: md2.c,v 1.7 2012/06/25 22:32:44 abs Exp $");
 #endif /* LIBC_SCCS and not lint */
@@ -96,7 +95,7 @@ static const unsigned char *pad[] = {
  * XXX This should not be visible, but due to an accident, it is
  * XXX so it must remain so.
  */
-/*static*/ void MD2Transform __P((MD2_CTX *));
+/*static*/ void MD2Transform(MD2_CTX *);
 
 #ifdef __weak_alias
 __weak_alias(MD2Init,_MD2Init)