Skip to content

Commit e87527f

Browse files
committed
deprecate macros in tommath.h
* move MP_DEPRECATED to tommath.h since we need it later * add MP_DEPRECATED_PRAGMA
1 parent a752242 commit e87527f

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

tommath.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,21 @@ typedef struct {
148148
/* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */
149149
typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
150150

151+
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
152+
# define MP_DEPRECATED(x) __attribute__((deprecated("replaced by " #x)))
153+
# define _MP_DEPRECATED_PRAGMA(s) _Pragma(#s)
154+
# define MP_DEPRECATED_PRAGMA(s) _MP_DEPRECATED_PRAGMA(GCC warning s)
155+
#elif defined(_MSC_VER) && _MSC_VER >= 1500
156+
# define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
157+
# define MP_DEPRECATED_PRAGMA(s) __pragma(message(s))
158+
#else
159+
# define MP_DEPRECATED
160+
# define MP_DEPRECATED_PRAGMA(s)
161+
#endif
151162

152-
#define USED(m) ((m)->used)
153-
#define DIGIT(m, k) ((m)->dp[(k)])
154-
#define SIGN(m) ((m)->sign)
163+
#define USED(m) (MP_DEPRECATED_PRAGMA("USED macro is deprecated, use z->used instead") (m)->used)
164+
#define DIGIT(m, k) (MP_DEPRECATED_PRAGMA("DIGIT macro is deprecated, use z->dp instead") (m)->dp[(k)])
165+
#define SIGN(m) (MP_DEPRECATED_PRAGMA("SIGN macro is deprecated, use z->sign instead") (m)->sign)
155166

156167
/* error code to char* string */
157168
const char *mp_error_to_string(int code);

tommath_private.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
extern "C" {
1111
#endif
1212

13-
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 301)
14-
# define MP_DEPRECATED(x) __attribute__((deprecated("replaced by " #x)))
15-
#elif defined(_MSC_VER) && _MSC_VER >= 1500
16-
# define MP_DEPRECATED(x) __declspec(deprecated("replaced by " #x))
17-
#else
18-
# define MP_DEPRECATED
19-
#endif
20-
2113
/* define heap macros */
2214
#ifndef MP_MALLOC
2315
/* default to libc stuff */

0 commit comments

Comments
 (0)