From beba37006a1d589975aaf2082e2643ac378d2b22 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Wed, 26 Apr 2017 11:24:25 -0700 Subject: [PATCH] =?UTF-8?q?deprecated=20macros,=20thanks=20Olivier=20Ch?= =?UTF-8?q?=C3=A9ron=20and=20Tomi=20Ollila?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GENERATED/include/decaf/common.h | 12 ++++++++++-- src/GENERATED/include/decaf/point_255.h | 5 +---- src/GENERATED/include/decaf/point_255.hxx | 10 +++------- src/GENERATED/include/decaf/point_448.h | 5 +---- src/GENERATED/include/decaf/point_448.hxx | 10 +++------- src/per_curve/point.tmpl.h | 5 +---- src/per_curve/point.tmpl.hxx | 10 +++------- src/public_include/decaf/common.h | 12 ++++++++++-- 8 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/GENERATED/include/decaf/common.h b/src/GENERATED/include/decaf/common.h index a01e6c6..694bfca 100644 --- a/src/GENERATED/include/decaf/common.h +++ b/src/GENERATED/include/decaf/common.h @@ -30,6 +30,14 @@ extern "C" { #define NONNULL __attribute__((nonnull)) #define INLINE inline __attribute__((always_inline)) #define UNUSED __attribute__((unused)) +// Cribbed from libnotmuch +#if defined (__clang_major__) && __clang_major__ >= 3 \ + || defined (__GNUC__) && __GNUC__ >= 5 \ + || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 +#define DEPRECATED(msg) __attribute__ ((deprecated(msg))) +#else +#define DEPRECATED(msg) __attribute__ ((deprecated)) +#endif /** @endcond */ /* Internal word types. @@ -77,14 +85,14 @@ typedef enum { /** Return success if x is true */ -static __inline__ __attribute__((unused,always_inline)) +static UNUSED INLINE decaf_error_t decaf_succeed_if(decaf_bool_t x) { return (decaf_error_t)x; } /** Return DECAF_TRUE iff x == DECAF_SUCCESS */ -static __inline__ __attribute__((unused,always_inline)) +static UNUSED INLINE decaf_bool_t decaf_successful(decaf_error_t e) { decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS); diff --git a/src/GENERATED/include/decaf/point_255.h b/src/GENERATED/include/decaf/point_255.h index 02602c5..4de6c24 100644 --- a/src/GENERATED/include/decaf/point_255.h +++ b/src/GENERATED/include/decaf/point_255.h @@ -413,10 +413,7 @@ extern const uint8_t decaf_x25519_base_point[DECAF_X25519_PUBLIC_BYTES] API_VIS; void decaf_x25519_generate_key ( uint8_t out[DECAF_X25519_PUBLIC_BYTES], const uint8_t scalar[DECAF_X25519_PRIVATE_BYTES] -) API_VIS NONNULL NOINLINE -__attribute__((deprecated( - "Renamed to decaf_x25519_derive_public_key" -))); +) API_VIS NONNULL NOINLINE DEPRECATED("Renamed to decaf_x25519_derive_public_key"); /** * @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses diff --git a/src/GENERATED/include/decaf/point_255.hxx b/src/GENERATED/include/decaf/point_255.hxx index 3642720..7abf046 100644 --- a/src/GENERATED/include/decaf/point_255.hxx +++ b/src/GENERATED/include/decaf/point_255.hxx @@ -671,9 +671,8 @@ public: * but possibly faster. * @deprecated Renamed to derive_public_key. */ - static inline SecureBuffer __attribute__((deprecated( - "Renamed to derive_public_key" - ))) generate_key( + static inline SecureBuffer DEPRECATED("Renamed to derive_public_key") + generate_key( const FixedBlock &scalar ) throw(std::bad_alloc) { SecureBuffer out(PUBLIC_BYTES); @@ -707,10 +706,7 @@ public: * equivalent to shared_secret(base_point(),scalar) but possibly faster. * @deprecated Renamed to derive_public_key_noexcept. */ - static inline void - __attribute__((deprecated( - "Renamed to derive_public_key_noexcept" - ))) + static inline void DEPRECATED("Renamed to derive_public_key_noexcept") generate_key_noexcept ( FixedBuffer &out, const FixedBlock &scalar diff --git a/src/GENERATED/include/decaf/point_448.h b/src/GENERATED/include/decaf/point_448.h index 8c38195..cf488e8 100644 --- a/src/GENERATED/include/decaf/point_448.h +++ b/src/GENERATED/include/decaf/point_448.h @@ -413,10 +413,7 @@ extern const uint8_t decaf_x448_base_point[DECAF_X448_PUBLIC_BYTES] API_VIS; void decaf_x448_generate_key ( uint8_t out[DECAF_X448_PUBLIC_BYTES], const uint8_t scalar[DECAF_X448_PRIVATE_BYTES] -) API_VIS NONNULL NOINLINE -__attribute__((deprecated( - "Renamed to decaf_x448_derive_public_key" -))); +) API_VIS NONNULL NOINLINE DEPRECATED("Renamed to decaf_x448_derive_public_key"); /** * @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses diff --git a/src/GENERATED/include/decaf/point_448.hxx b/src/GENERATED/include/decaf/point_448.hxx index b8605ac..5a01dea 100644 --- a/src/GENERATED/include/decaf/point_448.hxx +++ b/src/GENERATED/include/decaf/point_448.hxx @@ -671,9 +671,8 @@ public: * but possibly faster. * @deprecated Renamed to derive_public_key. */ - static inline SecureBuffer __attribute__((deprecated( - "Renamed to derive_public_key" - ))) generate_key( + static inline SecureBuffer DEPRECATED("Renamed to derive_public_key") + generate_key( const FixedBlock &scalar ) throw(std::bad_alloc) { SecureBuffer out(PUBLIC_BYTES); @@ -707,10 +706,7 @@ public: * equivalent to shared_secret(base_point(),scalar) but possibly faster. * @deprecated Renamed to derive_public_key_noexcept. */ - static inline void - __attribute__((deprecated( - "Renamed to derive_public_key_noexcept" - ))) + static inline void DEPRECATED("Renamed to derive_public_key_noexcept") generate_key_noexcept ( FixedBuffer &out, const FixedBlock &scalar diff --git a/src/per_curve/point.tmpl.h b/src/per_curve/point.tmpl.h index e6bdf1c..c1709fd 100644 --- a/src/per_curve/point.tmpl.h +++ b/src/per_curve/point.tmpl.h @@ -398,10 +398,7 @@ extern const uint8_t decaf_x$(gf_shortname)_base_point[DECAF_X$(gf_shortname)_PU void decaf_x$(gf_shortname)_generate_key ( uint8_t out[DECAF_X$(gf_shortname)_PUBLIC_BYTES], const uint8_t scalar[DECAF_X$(gf_shortname)_PRIVATE_BYTES] -) API_VIS NONNULL NOINLINE -__attribute__((deprecated( - "Renamed to decaf_x$(gf_shortname)_derive_public_key" -))); +) API_VIS NONNULL NOINLINE DEPRECATED("Renamed to decaf_x$(gf_shortname)_derive_public_key"); /** * @brief RFC 7748 Diffie-Hellman base point scalarmul. This function uses diff --git a/src/per_curve/point.tmpl.hxx b/src/per_curve/point.tmpl.hxx index d5a1ec9..d3243ca 100644 --- a/src/per_curve/point.tmpl.hxx +++ b/src/per_curve/point.tmpl.hxx @@ -658,9 +658,8 @@ public: * but possibly faster. * @deprecated Renamed to derive_public_key. */ - static inline SecureBuffer __attribute__((deprecated( - "Renamed to derive_public_key" - ))) generate_key( + static inline SecureBuffer DEPRECATED("Renamed to derive_public_key") + generate_key( const FixedBlock &scalar ) throw(std::bad_alloc) { SecureBuffer out(PUBLIC_BYTES); @@ -694,10 +693,7 @@ public: * equivalent to shared_secret(base_point(),scalar) but possibly faster. * @deprecated Renamed to derive_public_key_noexcept. */ - static inline void - __attribute__((deprecated( - "Renamed to derive_public_key_noexcept" - ))) + static inline void DEPRECATED("Renamed to derive_public_key_noexcept") generate_key_noexcept ( FixedBuffer &out, const FixedBlock &scalar diff --git a/src/public_include/decaf/common.h b/src/public_include/decaf/common.h index a01e6c6..694bfca 100644 --- a/src/public_include/decaf/common.h +++ b/src/public_include/decaf/common.h @@ -30,6 +30,14 @@ extern "C" { #define NONNULL __attribute__((nonnull)) #define INLINE inline __attribute__((always_inline)) #define UNUSED __attribute__((unused)) +// Cribbed from libnotmuch +#if defined (__clang_major__) && __clang_major__ >= 3 \ + || defined (__GNUC__) && __GNUC__ >= 5 \ + || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 +#define DEPRECATED(msg) __attribute__ ((deprecated(msg))) +#else +#define DEPRECATED(msg) __attribute__ ((deprecated)) +#endif /** @endcond */ /* Internal word types. @@ -77,14 +85,14 @@ typedef enum { /** Return success if x is true */ -static __inline__ __attribute__((unused,always_inline)) +static UNUSED INLINE decaf_error_t decaf_succeed_if(decaf_bool_t x) { return (decaf_error_t)x; } /** Return DECAF_TRUE iff x == DECAF_SUCCESS */ -static __inline__ __attribute__((unused,always_inline)) +static UNUSED INLINE decaf_bool_t decaf_successful(decaf_error_t e) { decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS);