Skip to content

Commit 96b5552

Browse files
authored
Merge pull request #267 from libtom/private_mp_word
make mp_word private
2 parents e9c4590 + 0b840b7 commit 96b5552

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

demo/shared.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
#endif
2020

2121
#define MP_WUR /* TODO: result checks disabled for now */
22-
#include "tommath.h"
22+
#include "tommath_private.h"
2323

2424
extern void ndraw(mp_int* a, const char* name);

demo/test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "shared.h"
2-
#include "tommath_private.h"
32

43
static long rand_long(void)
54
{

tommath.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,29 @@ extern "C" {
5555
*/
5656
#ifdef MP_8BIT
5757
typedef uint8_t mp_digit;
58-
typedef uint16_t mp_word;
58+
typedef uint16_t private_mp_word;
5959
# define MP_SIZEOF_MP_DIGIT 1
6060
# ifdef MP_DIGIT_BIT
6161
# error You must not define MP_DIGIT_BIT when using MP_8BIT
6262
# endif
6363
#elif defined(MP_16BIT)
6464
typedef uint16_t mp_digit;
65-
typedef uint32_t mp_word;
65+
typedef uint32_t private_mp_word;
6666
# define MP_SIZEOF_MP_DIGIT 2
6767
# ifdef MP_DIGIT_BIT
6868
# error You must not define MP_DIGIT_BIT when using MP_16BIT
6969
# endif
7070
#elif defined(MP_64BIT)
7171
/* for GCC only on supported platforms */
7272
typedef uint64_t mp_digit;
73-
typedef unsigned long mp_word __attribute__((mode(TI)));
73+
typedef unsigned long private_mp_word __attribute__((mode(TI)));
7474
# define MP_DIGIT_BIT 60
7575
#else
7676
/* this is the default case, 28-bit digits */
7777

7878
/* this is to make porting into LibTomCrypt easier :-) */
7979
typedef uint32_t mp_digit;
80-
typedef uint64_t mp_word;
80+
typedef uint64_t private_mp_word;
8181

8282
# ifdef MP_31BIT
8383
/* this is an extension that uses 31-bit digits */
@@ -89,6 +89,9 @@ typedef uint64_t mp_word;
8989
# endif
9090
#endif
9191

92+
/* mp_word is a private type */
93+
#define mp_word MP_DEPRECATED_PRAGMA("mp_word has been made private") private_mp_word
94+
9295
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
9396
#ifndef MP_DIGIT_BIT
9497
# define MP_DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
@@ -172,7 +175,7 @@ TOOM_SQR_CUTOFF;
172175
#endif
173176

174177
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
175-
#define PRIVATE_MP_WARRAY (1uLL << (((CHAR_BIT * sizeof(mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
178+
#define PRIVATE_MP_WARRAY (1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
176179
#define MP_WARRAY (MP_DEPRECATED_PRAGMA("MP_WARRAY is an internal macro") PRIVATE_MP_WARRAY)
177180

178181
#if defined(__GNUC__) && __GNUC__ >= 4

tommath_private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ extern void MP_FREE(void *mem, size_t size);
131131
#undef MP_WARRAY
132132
#define MP_WARRAY PRIVATE_MP_WARRAY
133133

134+
/* TODO: Remove private_mp_word as soon as deprecated mp_word is removed from tommath. */
135+
#undef mp_word
136+
typedef private_mp_word mp_word;
137+
134138
#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
135139
#define MP_MAX(x, y) (((x) > (y)) ? (x) : (y))
136140

0 commit comments

Comments
 (0)