diff --git a/Jamfile b/Jamfile index 120dabf8a..7e3b10714 100755 --- a/Jamfile +++ b/Jamfile @@ -688,6 +688,7 @@ local usage-requirements = # disable some warnings for gcc gcc:-fno-strict-aliasing gcc:-Wno-missing-braces + gcc:-Wno-unused-local-typedefs # suppress warnings caused by boost using c++11 features even when not # in c++11 mode darwin:-Wno-c++11-extensions diff --git a/ed25519/src/fe.cpp b/ed25519/src/fe.cpp index b5889daef..1704f3893 100644 --- a/ed25519/src/fe.cpp +++ b/ed25519/src/fe.cpp @@ -10,23 +10,23 @@ /* helper functions */ -static uint64_t load_3(const unsigned char *in) { - uint64_t result; +static u64 load_3(const unsigned char *in) { + u64 result; - result = (uint64_t) in[0]; - result |= ((uint64_t) in[1]) << 8; - result |= ((uint64_t) in[2]) << 16; + result = (u64) in[0]; + result |= ((u64) in[1]) << 8; + result |= ((u64) in[2]) << 16; return result; } -static uint64_t load_4(const unsigned char *in) { - uint64_t result; +static u64 load_4(const unsigned char *in) { + u64 result; - result = (uint64_t) in[0]; - result |= ((uint64_t) in[1]) << 8; - result |= ((uint64_t) in[2]) << 16; - result |= ((uint64_t) in[3]) << 24; + result = (u64) in[0]; + result |= ((u64) in[1]) << 8; + result |= ((u64) in[2]) << 16; + result |= ((u64) in[3]) << 24; return result; } @@ -84,36 +84,36 @@ void fe_1(fe h) { */ void fe_add(fe h, const fe f, const fe g) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t h0 = f0 + g0; - int32_t h1 = f1 + g1; - int32_t h2 = f2 + g2; - int32_t h3 = f3 + g3; - int32_t h4 = f4 + g4; - int32_t h5 = f5 + g5; - int32_t h6 = f6 + g6; - int32_t h7 = f7 + g7; - int32_t h8 = f8 + g8; - int32_t h9 = f9 + g9; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 g0 = g[0]; + i32 g1 = g[1]; + i32 g2 = g[2]; + i32 g3 = g[3]; + i32 g4 = g[4]; + i32 g5 = g[5]; + i32 g6 = g[6]; + i32 g7 = g[7]; + i32 g8 = g[8]; + i32 g9 = g[9]; + i32 h0 = f0 + g0; + i32 h1 = f1 + g1; + i32 h2 = f2 + g2; + i32 h3 = f3 + g3; + i32 h4 = f4 + g4; + i32 h5 = f5 + g5; + i32 h6 = f6 + g6; + i32 h7 = f7 + g7; + i32 h8 = f8 + g8; + i32 h9 = f9 + g9; h[0] = h0; h[1] = h1; @@ -137,36 +137,36 @@ void fe_add(fe h, const fe f, const fe g) { */ void fe_cmov(fe f, const fe g, unsigned int b) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t x0 = f0 ^ g0; - int32_t x1 = f1 ^ g1; - int32_t x2 = f2 ^ g2; - int32_t x3 = f3 ^ g3; - int32_t x4 = f4 ^ g4; - int32_t x5 = f5 ^ g5; - int32_t x6 = f6 ^ g6; - int32_t x7 = f7 ^ g7; - int32_t x8 = f8 ^ g8; - int32_t x9 = f9 ^ g9; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 g0 = g[0]; + i32 g1 = g[1]; + i32 g2 = g[2]; + i32 g3 = g[3]; + i32 g4 = g[4]; + i32 g5 = g[5]; + i32 g6 = g[6]; + i32 g7 = g[7]; + i32 g8 = g[8]; + i32 g9 = g[9]; + i32 x0 = f0 ^ g0; + i32 x1 = f1 ^ g1; + i32 x2 = f2 ^ g2; + i32 x3 = f3 ^ g3; + i32 x4 = f4 ^ g4; + i32 x5 = f5 ^ g5; + i32 x6 = f6 ^ g6; + i32 x7 = f7 ^ g7; + i32 x8 = f8 ^ g8; + i32 x9 = f9 ^ g9; b = (unsigned int) (- (int) b); /* silence warning */ x0 &= b; @@ -200,36 +200,36 @@ void fe_cmov(fe f, const fe g, unsigned int b) { */ void fe_cswap(fe f,fe g,unsigned int b) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t x0 = f0 ^ g0; - int32_t x1 = f1 ^ g1; - int32_t x2 = f2 ^ g2; - int32_t x3 = f3 ^ g3; - int32_t x4 = f4 ^ g4; - int32_t x5 = f5 ^ g5; - int32_t x6 = f6 ^ g6; - int32_t x7 = f7 ^ g7; - int32_t x8 = f8 ^ g8; - int32_t x9 = f9 ^ g9; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 g0 = g[0]; + i32 g1 = g[1]; + i32 g2 = g[2]; + i32 g3 = g[3]; + i32 g4 = g[4]; + i32 g5 = g[5]; + i32 g6 = g[6]; + i32 g7 = g[7]; + i32 g8 = g[8]; + i32 g9 = g[9]; + i32 x0 = f0 ^ g0; + i32 x1 = f1 ^ g1; + i32 x2 = f2 ^ g2; + i32 x3 = f3 ^ g3; + i32 x4 = f4 ^ g4; + i32 x5 = f5 ^ g5; + i32 x6 = f6 ^ g6; + i32 x7 = f7 ^ g7; + i32 x8 = f8 ^ g8; + i32 x9 = f9 ^ g9; b = -b; // warning C4146: unary minus operator applied to unsigned type, result still unsigned x0 &= b; x1 &= b; @@ -270,16 +270,16 @@ void fe_cswap(fe f,fe g,unsigned int b) { */ void fe_copy(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; h[0] = f0; h[1] = f1; @@ -352,16 +352,16 @@ void fe_frombytes(fe h, const unsigned char *s) { h9 += carry8; h8 -= carry8 << 26; - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; + h[0] = (i32) h0; + h[1] = (i32) h1; + h[2] = (i32) h2; + h[3] = (i32) h3; + h[4] = (i32) h4; + h[5] = (i32) h5; + h[6] = (i32) h6; + h[7] = (i32) h7; + h[8] = (i32) h8; + h[9] = (i32) h9; } @@ -559,40 +559,40 @@ int fe_isnonzero(const fe f) { */ void fe_mul(fe h, const fe f, const fe g) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t g1_19 = 19 * g1; /* 1.959375*2^29 */ - int32_t g2_19 = 19 * g2; /* 1.959375*2^30; still ok */ - int32_t g3_19 = 19 * g3; - int32_t g4_19 = 19 * g4; - int32_t g5_19 = 19 * g5; - int32_t g6_19 = 19 * g6; - int32_t g7_19 = 19 * g7; - int32_t g8_19 = 19 * g8; - int32_t g9_19 = 19 * g9; - int32_t f1_2 = 2 * f1; - int32_t f3_2 = 2 * f3; - int32_t f5_2 = 2 * f5; - int32_t f7_2 = 2 * f7; - int32_t f9_2 = 2 * f9; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 g0 = g[0]; + i32 g1 = g[1]; + i32 g2 = g[2]; + i32 g3 = g[3]; + i32 g4 = g[4]; + i32 g5 = g[5]; + i32 g6 = g[6]; + i32 g7 = g[7]; + i32 g8 = g[8]; + i32 g9 = g[9]; + i32 g1_19 = 19 * g1; /* 1.959375*2^29 */ + i32 g2_19 = 19 * g2; /* 1.959375*2^30; still ok */ + i32 g3_19 = 19 * g3; + i32 g4_19 = 19 * g4; + i32 g5_19 = 19 * g5; + i32 g6_19 = 19 * g6; + i32 g7_19 = 19 * g7; + i32 g8_19 = 19 * g8; + i32 g9_19 = 19 * g9; + i32 f1_2 = 2 * f1; + i32 f3_2 = 2 * f3; + i32 f5_2 = 2 * f5; + i32 f7_2 = 2 * f7; + i32 f9_2 = 2 * f9; int64_t f0g0 = f0 * (int64_t) g0; int64_t f0g1 = f0 * (int64_t) g1; int64_t f0g2 = f0 * (int64_t) g2; @@ -757,16 +757,16 @@ void fe_mul(fe h, const fe f, const fe g) { h1 += carry0; h0 -= carry0 << 26; - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; + h[0] = (i32) h0; + h[1] = (i32) h1; + h[2] = (i32) h2; + h[3] = (i32) h3; + h[4] = (i32) h4; + h[5] = (i32) h5; + h[6] = (i32) h6; + h[7] = (i32) h7; + h[8] = (i32) h8; + h[9] = (i32) h9; } @@ -782,16 +782,16 @@ Postconditions: */ void fe_mul121666(fe h, fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; int64_t h0 = f0 * (int64_t) 121666; int64_t h1 = f1 * (int64_t) 121666; int64_t h2 = f2 * (int64_t) 121666; @@ -849,26 +849,26 @@ Postconditions: */ void fe_neg(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t h0 = -f0; - int32_t h1 = -f1; - int32_t h2 = -f2; - int32_t h3 = -f3; - int32_t h4 = -f4; - int32_t h5 = -f5; - int32_t h6 = -f6; - int32_t h7 = -f7; - int32_t h8 = -f8; - int32_t h9 = -f9; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 h0 = -f0; + i32 h1 = -f1; + i32 h2 = -f2; + i32 h3 = -f3; + i32 h4 = -f4; + i32 h5 = -f5; + i32 h6 = -f6; + i32 h7 = -f7; + i32 h8 = -f8; + i32 h9 = -f9; h[0] = h0; h[1] = h1; @@ -985,29 +985,29 @@ See fe_mul.c for discussion of implementation strategy. */ void fe_sq(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t f0_2 = 2 * f0; - int32_t f1_2 = 2 * f1; - int32_t f2_2 = 2 * f2; - int32_t f3_2 = 2 * f3; - int32_t f4_2 = 2 * f4; - int32_t f5_2 = 2 * f5; - int32_t f6_2 = 2 * f6; - int32_t f7_2 = 2 * f7; - int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */ - int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */ - int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */ - int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */ - int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */ + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 f0_2 = 2 * f0; + i32 f1_2 = 2 * f1; + i32 f2_2 = 2 * f2; + i32 f3_2 = 2 * f3; + i32 f4_2 = 2 * f4; + i32 f5_2 = 2 * f5; + i32 f6_2 = 2 * f6; + i32 f7_2 = 2 * f7; + i32 f5_38 = 38 * f5; /* 1.959375*2^30 */ + i32 f6_19 = 19 * f6; /* 1.959375*2^30 */ + i32 f7_38 = 38 * f7; /* 1.959375*2^30 */ + i32 f8_19 = 19 * f8; /* 1.959375*2^30 */ + i32 f9_38 = 38 * f9; /* 1.959375*2^30 */ int64_t f0f0 = f0 * (int64_t) f0; int64_t f0f1_2 = f0_2 * (int64_t) f1; int64_t f0f2_2 = f0_2 * (int64_t) f2; @@ -1119,16 +1119,16 @@ void fe_sq(fe h, const fe f) { carry0 = (h0 + (int64_t) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; + h[0] = (i32) h0; + h[1] = (i32) h1; + h[2] = (i32) h2; + h[3] = (i32) h3; + h[4] = (i32) h4; + h[5] = (i32) h5; + h[6] = (i32) h6; + h[7] = (i32) h7; + h[8] = (i32) h8; + h[9] = (i32) h9; } @@ -1148,29 +1148,29 @@ See fe_mul.c for discussion of implementation strategy. */ void fe_sq2(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t f0_2 = 2 * f0; - int32_t f1_2 = 2 * f1; - int32_t f2_2 = 2 * f2; - int32_t f3_2 = 2 * f3; - int32_t f4_2 = 2 * f4; - int32_t f5_2 = 2 * f5; - int32_t f6_2 = 2 * f6; - int32_t f7_2 = 2 * f7; - int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */ - int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */ - int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */ - int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */ - int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */ + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 f0_2 = 2 * f0; + i32 f1_2 = 2 * f1; + i32 f2_2 = 2 * f2; + i32 f3_2 = 2 * f3; + i32 f4_2 = 2 * f4; + i32 f5_2 = 2 * f5; + i32 f6_2 = 2 * f6; + i32 f7_2 = 2 * f7; + i32 f5_38 = 38 * f5; /* 1.959375*2^30 */ + i32 f6_19 = 19 * f6; /* 1.959375*2^30 */ + i32 f7_38 = 38 * f7; /* 1.959375*2^30 */ + i32 f8_19 = 19 * f8; /* 1.959375*2^30 */ + i32 f9_38 = 38 * f9; /* 1.959375*2^30 */ int64_t f0f0 = f0 * (int64_t) f0; int64_t f0f1_2 = f0_2 * (int64_t) f1; int64_t f0f2_2 = f0_2 * (int64_t) f2; @@ -1292,16 +1292,16 @@ void fe_sq2(fe h, const fe f) { carry0 = (h0 + (int64_t) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; + h[0] = (i32) h0; + h[1] = (i32) h1; + h[2] = (i32) h2; + h[3] = (i32) h3; + h[4] = (i32) h4; + h[5] = (i32) h5; + h[6] = (i32) h6; + h[7] = (i32) h7; + h[8] = (i32) h8; + h[9] = (i32) h9; } @@ -1318,36 +1318,36 @@ Postconditions: */ void fe_sub(fe h, const fe f, const fe g) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t h0 = f0 - g0; - int32_t h1 = f1 - g1; - int32_t h2 = f2 - g2; - int32_t h3 = f3 - g3; - int32_t h4 = f4 - g4; - int32_t h5 = f5 - g5; - int32_t h6 = f6 - g6; - int32_t h7 = f7 - g7; - int32_t h8 = f8 - g8; - int32_t h9 = f9 - g9; + i32 f0 = f[0]; + i32 f1 = f[1]; + i32 f2 = f[2]; + i32 f3 = f[3]; + i32 f4 = f[4]; + i32 f5 = f[5]; + i32 f6 = f[6]; + i32 f7 = f[7]; + i32 f8 = f[8]; + i32 f9 = f[9]; + i32 g0 = g[0]; + i32 g1 = g[1]; + i32 g2 = g[2]; + i32 g3 = g[3]; + i32 g4 = g[4]; + i32 g5 = g[5]; + i32 g6 = g[6]; + i32 g7 = g[7]; + i32 g8 = g[8]; + i32 g9 = g[9]; + i32 h0 = f0 - g0; + i32 h1 = f1 - g1; + i32 h2 = f2 - g2; + i32 h3 = f3 - g3; + i32 h4 = f4 - g4; + i32 h5 = f5 - g5; + i32 h6 = f6 - g6; + i32 h7 = f7 - g7; + i32 h8 = f8 - g8; + i32 h9 = f9 - g9; h[0] = h0; h[1] = h1; @@ -1389,28 +1389,28 @@ Proof: */ void fe_tobytes(unsigned char *s, const fe h) { - int32_t h0 = h[0]; - int32_t h1 = h[1]; - int32_t h2 = h[2]; - int32_t h3 = h[3]; - int32_t h4 = h[4]; - int32_t h5 = h[5]; - int32_t h6 = h[6]; - int32_t h7 = h[7]; - int32_t h8 = h[8]; - int32_t h9 = h[9]; - int32_t q; - int32_t carry0; - int32_t carry1; - int32_t carry2; - int32_t carry3; - int32_t carry4; - int32_t carry5; - int32_t carry6; - int32_t carry7; - int32_t carry8; - int32_t carry9; - q = (19 * h9 + (((int32_t) 1) << 24)) >> 25; + i32 h0 = h[0]; + i32 h1 = h[1]; + i32 h2 = h[2]; + i32 h3 = h[3]; + i32 h4 = h[4]; + i32 h5 = h[5]; + i32 h6 = h[6]; + i32 h7 = h[7]; + i32 h8 = h[8]; + i32 h9 = h[9]; + i32 q; + i32 carry0; + i32 carry1; + i32 carry2; + i32 carry3; + i32 carry4; + i32 carry5; + i32 carry6; + i32 carry7; + i32 carry8; + i32 carry9; + q = (19 * h9 + (((i32) 1) << 24)) >> 25; q = (h0 + q) >> 26; q = (h1 + q) >> 25; q = (h2 + q) >> 26; diff --git a/ed25519/src/fe.h b/ed25519/src/fe.h index b4b62d282..fbe47dcd1 100644 --- a/ed25519/src/fe.h +++ b/ed25519/src/fe.h @@ -13,7 +13,7 @@ */ -typedef int32_t fe[10]; +typedef i32 fe[10]; void fe_0(fe h); diff --git a/ed25519/src/fixedint.h b/ed25519/src/fixedint.h index c7f608c4b..3032a9582 100644 --- a/ed25519/src/fixedint.h +++ b/ed25519/src/fixedint.h @@ -1,6 +1,6 @@ #include -using boost::uint64_t; -using boost::int64_t; -using boost::int32_t; +typedef boost::uint64_t u64; +typedef boost::int64_t i64; +typedef boost::int32_t i32; diff --git a/ed25519/src/ge.cpp b/ed25519/src/ge.cpp index 3c342b1d2..107039e3b 100644 --- a/ed25519/src/ge.cpp +++ b/ed25519/src/ge.cpp @@ -334,14 +334,14 @@ static unsigned char equal(signed char b, signed char c) { unsigned char ub = b; unsigned char uc = c; unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */ - uint64_t y = x; /* 0: yes; 1..255: no */ + u64 y = x; /* 0: yes; 1..255: no */ y -= 1; /* large: yes; 0..254: no */ y >>= 63; /* 1: yes; 0: no */ return (unsigned char) y; } static unsigned char negative(signed char b) { - uint64_t x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ + u64 x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ x >>= 63; /* 1: yes; 0: no */ return (unsigned char) x; } diff --git a/ed25519/src/sc.cpp b/ed25519/src/sc.cpp index d04c92d52..4fc2f001b 100644 --- a/ed25519/src/sc.cpp +++ b/ed25519/src/sc.cpp @@ -1,23 +1,23 @@ #include "fixedint.h" #include "sc.h" -static uint64_t load_3(const unsigned char *in) { - uint64_t result; +static u64 load_3(const unsigned char *in) { + u64 result; - result = (uint64_t) in[0]; - result |= ((uint64_t) in[1]) << 8; - result |= ((uint64_t) in[2]) << 16; + result = (u64) in[0]; + result |= ((u64) in[1]) << 8; + result |= ((u64) in[2]) << 16; return result; } -static uint64_t load_4(const unsigned char *in) { - uint64_t result; +static u64 load_4(const unsigned char *in) { + u64 result; - result = (uint64_t) in[0]; - result |= ((uint64_t) in[1]) << 8; - result |= ((uint64_t) in[2]) << 16; - result |= ((uint64_t) in[3]) << 24; + result = (u64) in[0]; + result |= ((u64) in[1]) << 8; + result |= ((u64) in[2]) << 16; + result |= ((u64) in[3]) << 24; return result; } diff --git a/ed25519/src/sha512.cpp b/ed25519/src/sha512.cpp index 3d659030d..add156243 100644 --- a/ed25519/src/sha512.cpp +++ b/ed25519/src/sha512.cpp @@ -17,7 +17,7 @@ #endif /* the K array */ -static const uint64_t K[80] = { +static const u64 K[80] = { UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd), UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc), UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019), @@ -63,8 +63,8 @@ static const uint64_t K[80] = { /* Various logical functions */ #define ROR64c(x, y) \ - ( ((((x)&UINT64_C(0xFFFFFFFFFFFFFFFF))>>((uint64_t)(y)&UINT64_C(63))) | \ - ((x)<<((uint64_t)(64-((y)&UINT64_C(63)))))) & UINT64_C(0xFFFFFFFFFFFFFFFF)) + ( ((((x)&UINT64_C(0xFFFFFFFFFFFFFFFF))>>((u64)(y)&UINT64_C(63))) | \ + ((x)<<((u64)(64-((y)&UINT64_C(63)))))) & UINT64_C(0xFFFFFFFFFFFFFFFF)) #define STORE64H(x, y) \ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ @@ -73,16 +73,16 @@ static const uint64_t K[80] = { (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } #define LOAD64H(x, y) \ - { x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \ - (((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \ - (((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \ - (((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); } + { x = (((u64)((y)[0] & 255))<<56)|(((u64)((y)[1] & 255))<<48) | \ + (((u64)((y)[2] & 255))<<40)|(((u64)((y)[3] & 255))<<32) | \ + (((u64)((y)[4] & 255))<<24)|(((u64)((y)[5] & 255))<<16) | \ + (((u64)((y)[6] & 255))<<8)|(((u64)((y)[7] & 255))); } #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) ROR64c(x, n) -#define R(x, n) (((x) &UINT64_C(0xFFFFFFFFFFFFFFFF))>>((uint64_t)n)) +#define R(x, n) (((x) &UINT64_C(0xFFFFFFFFFFFFFFFF))>>((u64)n)) #define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39)) #define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41)) #define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7)) @@ -94,7 +94,7 @@ static const uint64_t K[80] = { /* compress 1024-bits */ static int sha512_compress(sha512_context *md, unsigned char *buf) { - uint64_t S[8], W[80], t0, t1; + u64 S[8], W[80], t0, t1; int i; /* copy state into S */ diff --git a/ed25519/src/sha512.h b/ed25519/src/sha512.h index 0cdd0a3d5..7f93a3264 100644 --- a/ed25519/src/sha512.h +++ b/ed25519/src/sha512.h @@ -7,7 +7,7 @@ /* state */ typedef struct sha512_context_ { - uint64_t length, state[8]; + u64 length, state[8]; size_t curlen; unsigned char buf[128]; } sha512_context; diff --git a/include/libtorrent/buffer.hpp b/include/libtorrent/buffer.hpp index 16217e5ae..3302b13e1 100644 --- a/include/libtorrent/buffer.hpp +++ b/include/libtorrent/buffer.hpp @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #define LIBTORRENT_BUFFER_HPP #include +#include // for numeric_limits #include "libtorrent/invariant_check.hpp" #include "libtorrent/assert.hpp" #include // malloc/free/realloc diff --git a/include/libtorrent/debug.hpp b/include/libtorrent/debug.hpp index 12576de52..fad26747b 100644 --- a/include/libtorrent/debug.hpp +++ b/include/libtorrent/debug.hpp @@ -118,17 +118,17 @@ namespace libtorrent _wakeups.push_back(wakeup_t()); wakeup_t& w = _wakeups.back(); w.timestamp = time_now_hires(); - } #ifdef __MACH__ - task_events_info teinfo; - mach_msg_type_number_t t_info_count = TASK_EVENTS_INFO_COUNT; - task_info(mach_task_self(), TASK_EVENTS_INFO, (task_info_t)&teinfo - , &t_info_count); - w.context_switches = teinfo.csw; + task_events_info teinfo; + mach_msg_type_number_t t_info_count = TASK_EVENTS_INFO_COUNT; + task_info(mach_task_self(), TASK_EVENTS_INFO, (task_info_t)&teinfo + , &t_info_count); + w.context_switches = teinfo.csw; #else - w.context_switches = 0; + w.context_switches = 0; #endif - w.operation = name; + w.operation = name; + } } inline void async_inc_threads()