summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2018-08-09 21:09:11 +0200
committerNiels Möller <nisse@lysator.liu.se>2018-08-09 21:25:27 +0200
commit9d7cd5301922afebc6e0458158365001a8185c30 (patch)
treeb6e0750a0dbfd83ee406af1b4adbb34b5a764f8c
parent71f68cc45a269b206fc996309ef026f39d5af3df (diff)
downloadnettle-9d7cd5301922afebc6e0458158365001a8185c30.tar.gz
New macro _NETTLE_ATTRIBUTE_PURE.
-rw-r--r--ChangeLog7
-rw-r--r--ecc-curve.h20
-rw-r--r--nettle-meta.h20
-rw-r--r--nettle-types.h7
4 files changed, 25 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index c37eff0c..16895dff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2018-08-09 Niels Möller <nisse@lysator.liu.se>
+ * nettle-types.h (_NETTLE_ATTRIBUTE_PURE): Define
+ _NETTLE_ATTRIBUTE_PURE for gcc and lookalikes.
+ * ecc-curve.h: Include nettle-types.h, and use
+ _NETTLE_ATTRIBUTE_PURE instead of local definition.
+ * nettle-meta.h: Use _NETTLE_ATTRIBUTE_PURE, instead of explicit
+ #ifdefs.
+
* nettle-internal.c (des_set_key_wrapper, des3_set_key_wrapper)
(blowfish128_set_key_wrapper): Wrapper functions, to avoid cast
between incompatible function types (which gcc-8 warns about).
diff --git a/ecc-curve.h b/ecc-curve.h
index 8af75fdd..76024a19 100644
--- a/ecc-curve.h
+++ b/ecc-curve.h
@@ -34,6 +34,8 @@
#ifndef NETTLE_ECC_CURVE_H_INCLUDED
#define NETTLE_ECC_CURVE_H_INCLUDED
+#include "nettle-types.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -41,19 +43,11 @@ extern "C" {
/* The contents of this struct is internal. */
struct ecc_curve;
-#ifdef __GNUC__
-#define NETTLE_PURE __attribute__((pure))
-#else
-#define NETTLE_PURE
-#endif
-
-const struct ecc_curve * NETTLE_PURE nettle_get_secp_192r1(void);
-const struct ecc_curve * NETTLE_PURE nettle_get_secp_224r1(void);
-const struct ecc_curve * NETTLE_PURE nettle_get_secp_256r1(void);
-const struct ecc_curve * NETTLE_PURE nettle_get_secp_384r1(void);
-const struct ecc_curve * NETTLE_PURE nettle_get_secp_521r1(void);
-
-#undef NETTLE_PURE
+const struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_192r1(void);
+const struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_224r1(void);
+const struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_256r1(void);
+const struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_384r1(void);
+const struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_521r1(void);
#ifdef __cplusplus
}
diff --git a/nettle-meta.h b/nettle-meta.h
index 8fe1cf84..74e50e59 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -61,10 +61,7 @@ struct nettle_cipher
};
/* null-terminated list of ciphers implemented by this version of nettle */
-const struct nettle_cipher * const *
-#ifdef __GNUC__
-__attribute__((pure))
-#endif
+const struct nettle_cipher * const * _NETTLE_ATTRIBUTE_PURE
nettle_get_ciphers (void);
#define nettle_ciphers (nettle_get_ciphers())
@@ -121,10 +118,7 @@ struct nettle_hash
}
/* null-terminated list of digests implemented by this version of nettle */
-const struct nettle_hash * const *
-#ifdef __GNUC__
-__attribute__((pure))
-#endif
+const struct nettle_hash * const * _NETTLE_ATTRIBUTE_PURE
nettle_get_hashes (void);
#define nettle_hashes (nettle_get_hashes())
@@ -172,10 +166,7 @@ struct nettle_aead
/* null-terminated list of aead constructions implemented by this
version of nettle */
-const struct nettle_aead * const *
-#ifdef __GNUC__
-__attribute__((pure))
-#endif
+const struct nettle_aead * const * _NETTLE_ATTRIBUTE_PURE
nettle_get_aeads (void);
#define nettle_aeads (nettle_get_aeads())
@@ -238,10 +229,7 @@ struct nettle_armor
}
/* null-terminated list of armor schemes implemented by this version of nettle */
-const struct nettle_armor * const *
-#ifdef __GNUC__
-__attribute__((pure))
-#endif
+const struct nettle_armor * const * _NETTLE_ATTRIBUTE_PURE
nettle_get_armors (void);
#define nettle_armors (nettle_get_armors())
diff --git a/nettle-types.h b/nettle-types.h
index f04655d6..63eae421 100644
--- a/nettle-types.h
+++ b/nettle-types.h
@@ -39,6 +39,13 @@
#define _STDINT_HAVE_INT_FAST32_T 1
#include "nettle-stdint.h"
+/* Attributes we want to use in installed header files, and hence
+ can't rely on config.h. */
+#ifdef __GNUC__
+#define _NETTLE_ATTRIBUTE_PURE __attribute__((pure))
+#else /* !__GNUC__ */
+#define _NETTLE_ATTRIBUTE_PURE
+#endif /* !__GNUC__ */
#ifdef __cplusplus
extern "C" {
#endif