merge RC_1_1 into master

This commit is contained in:
arvidn 2016-10-08 14:17:51 -04:00
commit 1c89fcda48
16 changed files with 273 additions and 279 deletions

View File

@ -3,7 +3,7 @@ language: cpp
matrix: matrix:
include: include:
- env: variant=test_release coverage=1 toolset=gcc-coverage - env: variant=test_release coverage=1 toolset=gcc-coverage
- env: variant=test_debug sim=1 ssl=openssl crypto=libcrypto toolset=gcc - env: variant=test_debug sim=1 ssl=openssl crypto=libcrypto toolset=ubsan
- env: variant=test_barebones toolset=gcc - env: variant=test_barebones toolset=gcc
- env: autotools=1 toolset=gcc - env: autotools=1 toolset=gcc
- os: osx - os: osx
@ -64,7 +64,10 @@ before_install:
- if [ "$coverage" == "1" ]; then - if [ "$coverage" == "1" ]; then
pip install --user codecov; pip install --user codecov;
fi fi
- 'echo "using toolset: " ${toolset}' - 'if [[ $lang == "ubsan" ]]; then export test_args=testing.arg="--no-stderr-redirect"; fi'
- 'echo "toolset: " ${toolset}'
- 'echo "coverage_toolset: " ${coverage_toolset}'
- 'echo "variant: " ${variant}'
install: install:
@ -73,13 +76,16 @@ install:
g++-5 --version; g++-5 --version;
echo "using gcc : : ccache g++-5 : <cxxflags>-std=c++11 ;" >> ~/user-config.jam; echo "using gcc : : ccache g++-5 : <cxxflags>-std=c++11 ;" >> ~/user-config.jam;
fi' fi'
- 'if [[ $toolset == "gcc-ubsan" ]]; then
echo "using gcc : ubsan : ccache g++-5 : <cxxflags>-std=c++11 <compileflags>-fsanitize=undefined <compileflags>-fno-sanitize-recover=undefined <linkflags>-fsanitize=undefined <linkflags>-fno-sanitize-recover=undefined ;" >> ~/user-config.jam;
fi'
- 'if [[ $toolset == "gcc-coverage" ]]; then - 'if [[ $toolset == "gcc-coverage" ]]; then
echo "using gcc : coverage : ccache g++-5 --coverage : <cxxflags>-std=c++11 <linkflags>--coverage ;" >> ~/user-config.jam; echo "using gcc : coverage : ccache g++-5 --coverage : <cxxflags>-std=c++11 <linkflags>--coverage ;" >> ~/user-config.jam;
fi' fi'
- 'if [[ $toolset == "gcc-arm" ]]; then - 'if [[ $toolset == "gcc-arm" ]]; then
echo "using gcc : arm : ccache armv8l-linux-gnueabihf-g++ : <cxxflags>\"-std=c++11 -fsigned-char -march=armv8-a+crc -mfpu=crypto-neon-fp-armv8 -DTORRENT_FORCE_ARM_CRC32\" <linkflags>-lm ;" >> ~/user-config.jam; echo "using gcc : arm : ccache armv8l-linux-gnueabihf-g++ : <cxxflags>\"-std=c++11 -fsigned-char -march=armv8-a+crc -mfpu=crypto-neon-fp-armv8 -DTORRENT_FORCE_ARM_CRC32\" <linkflags>-lm ;" >> ~/user-config.jam;
fi;' fi;'
- 'echo "using darwin : : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 ;" >> ~/user-config.jam' - 'echo "using darwin : : ccache clang++ : <cxxflags>-std=c++11 ;" >> ~/user-config.jam'
- 'echo "using python : 2.7 ;" >> ~/user-config.jam' - 'echo "using python : 2.7 ;" >> ~/user-config.jam'
- if [ "$docs" == "1" ]; then rst2html.py --version; fi - if [ "$docs" == "1" ]; then rst2html.py --version; fi
@ -145,7 +151,7 @@ script:
fi' fi'
- cd bindings/python - cd bindings/python
- 'if [ "$variant" != "" ]; then - 'if [[ "$lang" != "ubsan" && "$variant" != "" ]]; then
bjam -j3 warnings-as-errors=on ssl=$ssl crypto=$crypto debug-iterators=on picker-debugging=on invariant-checks=full $toolset variant=$variant stage_module libtorrent-link=shared install-type=LIB dll-path=../../lib && bjam -j3 warnings-as-errors=on ssl=$ssl crypto=$crypto debug-iterators=on picker-debugging=on invariant-checks=full $toolset variant=$variant stage_module libtorrent-link=shared install-type=LIB dll-path=../../lib &&
LD_LIBRARY_PATH=../../lib DYLD_LIBRARY_PATH=../../lib python test.py; LD_LIBRARY_PATH=../../lib DYLD_LIBRARY_PATH=../../lib python test.py;
fi' fi'

View File

@ -288,7 +288,6 @@ rule warnings ( properties * )
{ {
# disable warning C4503: decorated name length exceeded, name was truncated # disable warning C4503: decorated name length exceeded, name was truncated
result += <cflags>/wd4503 ; result += <cflags>/wd4503 ;
result += <warnings>all ;
# enable these warnings again, once the other ones are dealt with # enable these warnings again, once the other ones are dealt with
@ -521,7 +520,7 @@ variant test_release : release
: <asserts>production <debug-symbols>on : <asserts>production <debug-symbols>on
<invariant-checks>full <boost-link>shared <optimization>off <invariant-checks>full <boost-link>shared <optimization>off
<export-extra>on <debug-iterators>on <threading>multi <export-extra>on <debug-iterators>on <threading>multi
<inlining>off <inlining>on
; ;
variant test_debug : debug variant test_debug : debug
: <logging>on <disk-stats>on : <logging>on <disk-stats>on

View File

@ -434,7 +434,7 @@ void bind_torrent_handle()
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
.def("force_dht_announce", _(&torrent_handle::force_dht_announce)) .def("force_dht_announce", _(&torrent_handle::force_dht_announce))
#endif #endif
.def("scrape_tracker", _(&torrent_handle::scrape_tracker)) .def("scrape_tracker", _(&torrent_handle::scrape_tracker), arg("index") = -1)
.def("set_upload_mode", _(&torrent_handle::set_upload_mode)) .def("set_upload_mode", _(&torrent_handle::set_upload_mode))
.def("set_share_mode", _(&torrent_handle::set_share_mode)) .def("set_share_mode", _(&torrent_handle::set_share_mode))
.def("flush_cache", &torrent_handle::flush_cache) .def("flush_cache", &torrent_handle::flush_cache)

View File

@ -34,6 +34,9 @@ static u64 load_4(const unsigned char *in) {
return result; return result;
} }
static inline i64 shift_left(i64 v, int s) {
return i64(u64(v) << s);
}
/* /*
@ -326,34 +329,34 @@ void fe_frombytes(fe h, const unsigned char *s) {
carry9 = (h9 + (i64) (1 << 24)) >> 25; carry9 = (h9 + (i64) (1 << 24)) >> 25;
h0 += carry9 * 19; h0 += carry9 * 19;
h9 -= carry9 << 25; h9 -= shift_left(carry9, 25);
carry1 = (h1 + (i64) (1 << 24)) >> 25; carry1 = (h1 + (i64) (1 << 24)) >> 25;
h2 += carry1; h2 += carry1;
h1 -= carry1 << 25; h1 -= shift_left(carry1, 25);
carry3 = (h3 + (i64) (1 << 24)) >> 25; carry3 = (h3 + (i64) (1 << 24)) >> 25;
h4 += carry3; h4 += carry3;
h3 -= carry3 << 25; h3 -= shift_left(carry3, 25);
carry5 = (h5 + (i64) (1 << 24)) >> 25; carry5 = (h5 + (i64) (1 << 24)) >> 25;
h6 += carry5; h6 += carry5;
h5 -= carry5 << 25; h5 -= shift_left(carry5, 25);
carry7 = (h7 + (i64) (1 << 24)) >> 25; carry7 = (h7 + (i64) (1 << 24)) >> 25;
h8 += carry7; h8 += carry7;
h7 -= carry7 << 25; h7 -= shift_left(carry7, 25);
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
carry2 = (h2 + (i64) (1 << 25)) >> 26; carry2 = (h2 + (i64) (1 << 25)) >> 26;
h3 += carry2; h3 += carry2;
h2 -= carry2 << 26; h2 -= shift_left(carry2, 26);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry6 = (h6 + (i64) (1 << 25)) >> 26; carry6 = (h6 + (i64) (1 << 25)) >> 26;
h7 += carry6; h7 += carry6;
h6 -= carry6 << 26; h6 -= shift_left(carry6, 26);
carry8 = (h8 + (i64) (1 << 25)) >> 26; carry8 = (h8 + (i64) (1 << 25)) >> 26;
h9 += carry8; h9 += carry8;
h8 -= carry8 << 26; h8 -= shift_left(carry8, 26);
h[0] = (i32) h0; h[0] = (i32) h0;
h[1] = (i32) h1; h[1] = (i32) h1;
@ -528,7 +531,6 @@ int fe_isnonzero(const fe f) {
} }
/* /*
h = f * g h = f * g
Can overlap h with f or g. Can overlap h with f or g.
@ -719,46 +721,46 @@ void fe_mul(fe h, const fe f, const fe g) {
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry1 = (h1 + (i64) (1 << 24)) >> 25; carry1 = (h1 + (i64) (1 << 24)) >> 25;
h2 += carry1; h2 += carry1;
h1 -= carry1 << 25; h1 -= shift_left(carry1, 25);
carry5 = (h5 + (i64) (1 << 24)) >> 25; carry5 = (h5 + (i64) (1 << 24)) >> 25;
h6 += carry5; h6 += carry5;
h5 -= carry5 << 25; h5 -= shift_left(carry5, 25);
carry2 = (h2 + (i64) (1 << 25)) >> 26; carry2 = (h2 + (i64) (1 << 25)) >> 26;
h3 += carry2; h3 += carry2;
h2 -= carry2 << 26; h2 -= shift_left(carry2, 26);
carry6 = (h6 + (i64) (1 << 25)) >> 26; carry6 = (h6 + (i64) (1 << 25)) >> 26;
h7 += carry6; h7 += carry6;
h6 -= carry6 << 26; h6 -= shift_left(carry6, 26);
carry3 = (h3 + (i64) (1 << 24)) >> 25; carry3 = (h3 + (i64) (1 << 24)) >> 25;
h4 += carry3; h4 += carry3;
h3 -= carry3 << 25; h3 -= shift_left(carry3, 25);
carry7 = (h7 + (i64) (1 << 24)) >> 25; carry7 = (h7 + (i64) (1 << 24)) >> 25;
h8 += carry7; h8 += carry7;
h7 -= carry7 << 25; h7 -= shift_left(carry7, 25);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry8 = (h8 + (i64) (1 << 25)) >> 26; carry8 = (h8 + (i64) (1 << 25)) >> 26;
h9 += carry8; h9 += carry8;
h8 -= carry8 << 26; h8 -= shift_left(carry8, 26);
carry9 = (h9 + (i64) (1 << 24)) >> 25; carry9 = (h9 + (i64) (1 << 24)) >> 25;
h0 += carry9 * 19; h0 += carry9 * 19;
h9 -= carry9 << 25; h9 -= shift_left(carry9, 25);
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
h[0] = (i32) h0; h[0] = (i32) h0;
h[1] = (i32) h1; h[1] = (i32) h1;
@ -816,17 +818,17 @@ void fe_mul121666(fe h, fe f) {
i64 carry8; i64 carry8;
i64 carry9; i64 carry9;
carry9 = (h9 + (i64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; carry9 = (h9 + (i64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= shift_left(carry9, 25);
carry1 = (h1 + (i64) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; carry1 = (h1 + (i64) (1<<24)) >> 25; h2 += carry1; h1 -= shift_left(carry1, 25);
carry3 = (h3 + (i64) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; carry3 = (h3 + (i64) (1<<24)) >> 25; h4 += carry3; h3 -= shift_left(carry3, 25);
carry5 = (h5 + (i64) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; carry5 = (h5 + (i64) (1<<24)) >> 25; h6 += carry5; h5 -= shift_left(carry5, 25);
carry7 = (h7 + (i64) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; carry7 = (h7 + (i64) (1<<24)) >> 25; h8 += carry7; h7 -= shift_left(carry7, 25);
carry0 = (h0 + (i64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; carry0 = (h0 + (i64) (1<<25)) >> 26; h1 += carry0; h0 -= shift_left(carry0, 26);
carry2 = (h2 + (i64) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; carry2 = (h2 + (i64) (1<<25)) >> 26; h3 += carry2; h2 -= shift_left(carry2, 26);
carry4 = (h4 + (i64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; carry4 = (h4 + (i64) (1<<25)) >> 26; h5 += carry4; h4 -= shift_left(carry4, 26);
carry6 = (h6 + (i64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; carry6 = (h6 + (i64) (1<<25)) >> 26; h7 += carry6; h6 -= shift_left(carry6, 26);
carry8 = (h8 + (i64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; carry8 = (h8 + (i64) (1<<25)) >> 26; h9 += carry8; h8 -= shift_left(carry8, 26);
h[0] = h0; h[0] = h0;
h[1] = h1; h[1] = h1;
@ -1088,40 +1090,40 @@ void fe_sq(fe h, const fe f) {
i64 carry9; i64 carry9;
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry1 = (h1 + (i64) (1 << 24)) >> 25; carry1 = (h1 + (i64) (1 << 24)) >> 25;
h2 += carry1; h2 += carry1;
h1 -= carry1 << 25; h1 -= shift_left(carry1, 25);
carry5 = (h5 + (i64) (1 << 24)) >> 25; carry5 = (h5 + (i64) (1 << 24)) >> 25;
h6 += carry5; h6 += carry5;
h5 -= carry5 << 25; h5 -= shift_left(carry5, 25);
carry2 = (h2 + (i64) (1 << 25)) >> 26; carry2 = (h2 + (i64) (1 << 25)) >> 26;
h3 += carry2; h3 += carry2;
h2 -= carry2 << 26; h2 -= shift_left(carry2, 26);
carry6 = (h6 + (i64) (1 << 25)) >> 26; carry6 = (h6 + (i64) (1 << 25)) >> 26;
h7 += carry6; h7 += carry6;
h6 -= carry6 << 26; h6 -= shift_left(carry6, 26);
carry3 = (h3 + (i64) (1 << 24)) >> 25; carry3 = (h3 + (i64) (1 << 24)) >> 25;
h4 += carry3; h4 += carry3;
h3 -= carry3 << 25; h3 -= shift_left(carry3, 25);
carry7 = (h7 + (i64) (1 << 24)) >> 25; carry7 = (h7 + (i64) (1 << 24)) >> 25;
h8 += carry7; h8 += carry7;
h7 -= carry7 << 25; h7 -= shift_left(carry7, 25);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry8 = (h8 + (i64) (1 << 25)) >> 26; carry8 = (h8 + (i64) (1 << 25)) >> 26;
h9 += carry8; h9 += carry8;
h8 -= carry8 << 26; h8 -= shift_left(carry8, 26);
carry9 = (h9 + (i64) (1 << 24)) >> 25; carry9 = (h9 + (i64) (1 << 24)) >> 25;
h0 += carry9 * 19; h0 += carry9 * 19;
h9 -= carry9 << 25; h9 -= shift_left(carry9, 25);
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
h[0] = (i32) h0; h[0] = (i32) h0;
h[1] = (i32) h1; h[1] = (i32) h1;
h[2] = (i32) h2; h[2] = (i32) h2;
@ -1261,40 +1263,40 @@ void fe_sq2(fe h, const fe f) {
h9 += h9; h9 += h9;
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry1 = (h1 + (i64) (1 << 24)) >> 25; carry1 = (h1 + (i64) (1 << 24)) >> 25;
h2 += carry1; h2 += carry1;
h1 -= carry1 << 25; h1 -= shift_left(carry1, 25);
carry5 = (h5 + (i64) (1 << 24)) >> 25; carry5 = (h5 + (i64) (1 << 24)) >> 25;
h6 += carry5; h6 += carry5;
h5 -= carry5 << 25; h5 -= shift_left(carry5, 25);
carry2 = (h2 + (i64) (1 << 25)) >> 26; carry2 = (h2 + (i64) (1 << 25)) >> 26;
h3 += carry2; h3 += carry2;
h2 -= carry2 << 26; h2 -= shift_left(carry2, 26);
carry6 = (h6 + (i64) (1 << 25)) >> 26; carry6 = (h6 + (i64) (1 << 25)) >> 26;
h7 += carry6; h7 += carry6;
h6 -= carry6 << 26; h6 -= shift_left(carry6, 26);
carry3 = (h3 + (i64) (1 << 24)) >> 25; carry3 = (h3 + (i64) (1 << 24)) >> 25;
h4 += carry3; h4 += carry3;
h3 -= carry3 << 25; h3 -= shift_left(carry3, 25);
carry7 = (h7 + (i64) (1 << 24)) >> 25; carry7 = (h7 + (i64) (1 << 24)) >> 25;
h8 += carry7; h8 += carry7;
h7 -= carry7 << 25; h7 -= shift_left(carry7, 25);
carry4 = (h4 + (i64) (1 << 25)) >> 26; carry4 = (h4 + (i64) (1 << 25)) >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry8 = (h8 + (i64) (1 << 25)) >> 26; carry8 = (h8 + (i64) (1 << 25)) >> 26;
h9 += carry8; h9 += carry8;
h8 -= carry8 << 26; h8 -= shift_left(carry8, 26);
carry9 = (h9 + (i64) (1 << 24)) >> 25; carry9 = (h9 + (i64) (1 << 24)) >> 25;
h0 += carry9 * 19; h0 += carry9 * 19;
h9 -= carry9 << 25; h9 -= shift_left(carry9, 25);
carry0 = (h0 + (i64) (1 << 25)) >> 26; carry0 = (h0 + (i64) (1 << 25)) >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
h[0] = (i32) h0; h[0] = (i32) h0;
h[1] = (i32) h1; h[1] = (i32) h1;
h[2] = (i32) h2; h[2] = (i32) h2;
@ -1429,33 +1431,33 @@ void fe_tobytes(unsigned char *s, const fe h) {
/* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */ /* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */
carry0 = h0 >> 26; carry0 = h0 >> 26;
h1 += carry0; h1 += carry0;
h0 -= carry0 << 26; h0 -= shift_left(carry0, 26);
carry1 = h1 >> 25; carry1 = h1 >> 25;
h2 += carry1; h2 += carry1;
h1 -= carry1 << 25; h1 -= shift_left(carry1, 25);
carry2 = h2 >> 26; carry2 = h2 >> 26;
h3 += carry2; h3 += carry2;
h2 -= carry2 << 26; h2 -= shift_left(carry2, 26);
carry3 = h3 >> 25; carry3 = h3 >> 25;
h4 += carry3; h4 += carry3;
h3 -= carry3 << 25; h3 -= shift_left(carry3, 25);
carry4 = h4 >> 26; carry4 = h4 >> 26;
h5 += carry4; h5 += carry4;
h4 -= carry4 << 26; h4 -= shift_left(carry4, 26);
carry5 = h5 >> 25; carry5 = h5 >> 25;
h6 += carry5; h6 += carry5;
h5 -= carry5 << 25; h5 -= shift_left(carry5, 25);
carry6 = h6 >> 26; carry6 = h6 >> 26;
h7 += carry6; h7 += carry6;
h6 -= carry6 << 26; h6 -= shift_left(carry6, 26);
carry7 = h7 >> 25; carry7 = h7 >> 25;
h8 += carry7; h8 += carry7;
h7 -= carry7 << 25; h7 -= shift_left(carry7, 25);
carry8 = h8 >> 26; carry8 = h8 >> 26;
h9 += carry8; h9 += carry8;
h8 -= carry8 << 26; h8 -= shift_left(carry8, 26);
carry9 = h9 >> 25; carry9 = h9 >> 25;
h9 -= carry9 << 25; h9 -= shift_left(carry9, 25);
/* h10 = carry9 */ /* h10 = carry9 */
/* /*

View File

@ -357,9 +357,11 @@ static void cmov(ge_precomp *t, ge_precomp *u, unsigned char b) {
static void select(ge_precomp *t, int pos, signed char b) { static void select(ge_precomp *t, int pos, signed char b) {
typedef signed char schar;
typedef unsigned char uchar;
ge_precomp minust; ge_precomp minust;
unsigned char bnegative = negative(b); unsigned char const bnegative = negative(b);
unsigned char babs = b - (((-bnegative) & b) << 1); unsigned char const babs = b - schar(uchar((-bnegative) & b) << 1);
fe_1(t->yplusx); fe_1(t->yplusx);
fe_1(t->yminusx); fe_1(t->yminusx);
fe_0(t->xy2d); fe_0(t->xy2d);

View File

@ -25,6 +25,10 @@ static u64 load_4(const unsigned char *in) {
return result; return result;
} }
static inline i64 shift_left(i64 v, int s) {
return i64(u64(v) << s);
}
/* /*
Input: Input:
s[0]+256*s[1]+...+256^63*s[63] = s s[0]+256*s[1]+...+256^63*s[63] = s
@ -122,37 +126,37 @@ void sc_reduce(unsigned char *s) {
s18 = 0; s18 = 0;
carry6 = (s6 + (1 << 20)) >> 21; carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry8 = (s8 + (1 << 20)) >> 21; carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry10 = (s10 + (1 << 20)) >> 21; carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry12 = (s12 + (1 << 20)) >> 21; carry12 = (s12 + (1 << 20)) >> 21;
s13 += carry12; s13 += carry12;
s12 -= carry12 << 21; s12 -= shift_left(carry12, 21);
carry14 = (s14 + (1 << 20)) >> 21; carry14 = (s14 + (1 << 20)) >> 21;
s15 += carry14; s15 += carry14;
s14 -= carry14 << 21; s14 -= shift_left(carry14, 21);
carry16 = (s16 + (1 << 20)) >> 21; carry16 = (s16 + (1 << 20)) >> 21;
s17 += carry16; s17 += carry16;
s16 -= carry16 << 21; s16 -= shift_left(carry16, 21);
carry7 = (s7 + (1 << 20)) >> 21; carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry9 = (s9 + (1 << 20)) >> 21; carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry11 = (s11 + (1 << 20)) >> 21; carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
carry13 = (s13 + (1 << 20)) >> 21; carry13 = (s13 + (1 << 20)) >> 21;
s14 += carry13; s14 += carry13;
s13 -= carry13 << 21; s13 -= shift_left(carry13, 21);
carry15 = (s15 + (1 << 20)) >> 21; carry15 = (s15 + (1 << 20)) >> 21;
s16 += carry15; s16 += carry15;
s15 -= carry15 << 21; s15 -= shift_left(carry15, 21);
s5 += s17 * 666643; s5 += s17 * 666643;
s6 += s17 * 470296; s6 += s17 * 470296;
s7 += s17 * 654183; s7 += s17 * 654183;
@ -197,40 +201,40 @@ void sc_reduce(unsigned char *s) {
s12 = 0; s12 = 0;
carry0 = (s0 + (1 << 20)) >> 21; carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry2 = (s2 + (1 << 20)) >> 21; carry2 = (s2 + (1 << 20)) >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry4 = (s4 + (1 << 20)) >> 21; carry4 = (s4 + (1 << 20)) >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry6 = (s6 + (1 << 20)) >> 21; carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry8 = (s8 + (1 << 20)) >> 21; carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry10 = (s10 + (1 << 20)) >> 21; carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry1 = (s1 + (1 << 20)) >> 21; carry1 = (s1 + (1 << 20)) >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry3 = (s3 + (1 << 20)) >> 21; carry3 = (s3 + (1 << 20)) >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry5 = (s5 + (1 << 20)) >> 21; carry5 = (s5 + (1 << 20)) >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry7 = (s7 + (1 << 20)) >> 21; carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry9 = (s9 + (1 << 20)) >> 21; carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry11 = (s11 + (1 << 20)) >> 21; carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
s0 += s12 * 666643; s0 += s12 * 666643;
s1 += s12 * 470296; s1 += s12 * 470296;
s2 += s12 * 654183; s2 += s12 * 654183;
@ -240,40 +244,40 @@ void sc_reduce(unsigned char *s) {
s12 = 0; s12 = 0;
carry0 = s0 >> 21; carry0 = s0 >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry1 = s1 >> 21; carry1 = s1 >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry2 = s2 >> 21; carry2 = s2 >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry3 = s3 >> 21; carry3 = s3 >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry4 = s4 >> 21; carry4 = s4 >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry5 = s5 >> 21; carry5 = s5 >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry6 = s6 >> 21; carry6 = s6 >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry7 = s7 >> 21; carry7 = s7 >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry8 = s8 >> 21; carry8 = s8 >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry9 = s9 >> 21; carry9 = s9 >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry10 = s10 >> 21; carry10 = s10 >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry11 = s11 >> 21; carry11 = s11 >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
s0 += s12 * 666643; s0 += s12 * 666643;
s1 += s12 * 470296; s1 += s12 * 470296;
s2 += s12 * 654183; s2 += s12 * 654183;
@ -283,37 +287,37 @@ void sc_reduce(unsigned char *s) {
s12 = 0; s12 = 0;
carry0 = s0 >> 21; carry0 = s0 >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry1 = s1 >> 21; carry1 = s1 >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry2 = s2 >> 21; carry2 = s2 >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry3 = s3 >> 21; carry3 = s3 >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry4 = s4 >> 21; carry4 = s4 >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry5 = s5 >> 21; carry5 = s5 >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry6 = s6 >> 21; carry6 = s6 >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry7 = s7 >> 21; carry7 = s7 >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry8 = s8 >> 21; carry8 = s8 >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry9 = s9 >> 21; carry9 = s9 >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry10 = s10 >> 21; carry10 = s10 >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
s[0] = (unsigned char) ((s0 >> 0) & 0xff); s[0] = (unsigned char) ((s0 >> 0) & 0xff);
s[1] = (unsigned char) ((s0 >> 8) & 0xff); s[1] = (unsigned char) ((s0 >> 8) & 0xff);
@ -473,73 +477,73 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s23 = 0; s23 = 0;
carry0 = (s0 + (1 << 20)) >> 21; carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry2 = (s2 + (1 << 20)) >> 21; carry2 = (s2 + (1 << 20)) >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry4 = (s4 + (1 << 20)) >> 21; carry4 = (s4 + (1 << 20)) >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry6 = (s6 + (1 << 20)) >> 21; carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry8 = (s8 + (1 << 20)) >> 21; carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry10 = (s10 + (1 << 20)) >> 21; carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry12 = (s12 + (1 << 20)) >> 21; carry12 = (s12 + (1 << 20)) >> 21;
s13 += carry12; s13 += carry12;
s12 -= carry12 << 21; s12 -= shift_left(carry12, 21);
carry14 = (s14 + (1 << 20)) >> 21; carry14 = (s14 + (1 << 20)) >> 21;
s15 += carry14; s15 += carry14;
s14 -= carry14 << 21; s14 -= shift_left(carry14, 21);
carry16 = (s16 + (1 << 20)) >> 21; carry16 = (s16 + (1 << 20)) >> 21;
s17 += carry16; s17 += carry16;
s16 -= carry16 << 21; s16 -= shift_left(carry16, 21);
carry18 = (s18 + (1 << 20)) >> 21; carry18 = (s18 + (1 << 20)) >> 21;
s19 += carry18; s19 += carry18;
s18 -= carry18 << 21; s18 -= shift_left(carry18, 21);
carry20 = (s20 + (1 << 20)) >> 21; carry20 = (s20 + (1 << 20)) >> 21;
s21 += carry20; s21 += carry20;
s20 -= carry20 << 21; s20 -= shift_left(carry20, 21);
carry22 = (s22 + (1 << 20)) >> 21; carry22 = (s22 + (1 << 20)) >> 21;
s23 += carry22; s23 += carry22;
s22 -= carry22 << 21; s22 -= shift_left(carry22, 21);
carry1 = (s1 + (1 << 20)) >> 21; carry1 = (s1 + (1 << 20)) >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry3 = (s3 + (1 << 20)) >> 21; carry3 = (s3 + (1 << 20)) >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry5 = (s5 + (1 << 20)) >> 21; carry5 = (s5 + (1 << 20)) >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry7 = (s7 + (1 << 20)) >> 21; carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry9 = (s9 + (1 << 20)) >> 21; carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry11 = (s11 + (1 << 20)) >> 21; carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
carry13 = (s13 + (1 << 20)) >> 21; carry13 = (s13 + (1 << 20)) >> 21;
s14 += carry13; s14 += carry13;
s13 -= carry13 << 21; s13 -= shift_left(carry13, 21);
carry15 = (s15 + (1 << 20)) >> 21; carry15 = (s15 + (1 << 20)) >> 21;
s16 += carry15; s16 += carry15;
s15 -= carry15 << 21; s15 -= shift_left(carry15, 21);
carry17 = (s17 + (1 << 20)) >> 21; carry17 = (s17 + (1 << 20)) >> 21;
s18 += carry17; s18 += carry17;
s17 -= carry17 << 21; s17 -= shift_left(carry17, 21);
carry19 = (s19 + (1 << 20)) >> 21; carry19 = (s19 + (1 << 20)) >> 21;
s20 += carry19; s20 += carry19;
s19 -= carry19 << 21; s19 -= shift_left(carry19, 21);
carry21 = (s21 + (1 << 20)) >> 21; carry21 = (s21 + (1 << 20)) >> 21;
s22 += carry21; s22 += carry21;
s21 -= carry21 << 21; s21 -= shift_left(carry21, 21);
s11 += s23 * 666643; s11 += s23 * 666643;
s12 += s23 * 470296; s12 += s23 * 470296;
s13 += s23 * 654183; s13 += s23 * 654183;
@ -584,37 +588,37 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s18 = 0; s18 = 0;
carry6 = (s6 + (1 << 20)) >> 21; carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry8 = (s8 + (1 << 20)) >> 21; carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry10 = (s10 + (1 << 20)) >> 21; carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry12 = (s12 + (1 << 20)) >> 21; carry12 = (s12 + (1 << 20)) >> 21;
s13 += carry12; s13 += carry12;
s12 -= carry12 << 21; s12 -= shift_left(carry12, 21);
carry14 = (s14 + (1 << 20)) >> 21; carry14 = (s14 + (1 << 20)) >> 21;
s15 += carry14; s15 += carry14;
s14 -= carry14 << 21; s14 -= shift_left(carry14, 21);
carry16 = (s16 + (1 << 20)) >> 21; carry16 = (s16 + (1 << 20)) >> 21;
s17 += carry16; s17 += carry16;
s16 -= carry16 << 21; s16 -= shift_left(carry16, 21);
carry7 = (s7 + (1 << 20)) >> 21; carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry9 = (s9 + (1 << 20)) >> 21; carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry11 = (s11 + (1 << 20)) >> 21; carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
carry13 = (s13 + (1 << 20)) >> 21; carry13 = (s13 + (1 << 20)) >> 21;
s14 += carry13; s14 += carry13;
s13 -= carry13 << 21; s13 -= shift_left(carry13, 21);
carry15 = (s15 + (1 << 20)) >> 21; carry15 = (s15 + (1 << 20)) >> 21;
s16 += carry15; s16 += carry15;
s15 -= carry15 << 21; s15 -= shift_left(carry15, 21);
s5 += s17 * 666643; s5 += s17 * 666643;
s6 += s17 * 470296; s6 += s17 * 470296;
s7 += s17 * 654183; s7 += s17 * 654183;
@ -659,40 +663,40 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s12 = 0; s12 = 0;
carry0 = (s0 + (1 << 20)) >> 21; carry0 = (s0 + (1 << 20)) >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry2 = (s2 + (1 << 20)) >> 21; carry2 = (s2 + (1 << 20)) >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry4 = (s4 + (1 << 20)) >> 21; carry4 = (s4 + (1 << 20)) >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry6 = (s6 + (1 << 20)) >> 21; carry6 = (s6 + (1 << 20)) >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry8 = (s8 + (1 << 20)) >> 21; carry8 = (s8 + (1 << 20)) >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry10 = (s10 + (1 << 20)) >> 21; carry10 = (s10 + (1 << 20)) >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry1 = (s1 + (1 << 20)) >> 21; carry1 = (s1 + (1 << 20)) >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry3 = (s3 + (1 << 20)) >> 21; carry3 = (s3 + (1 << 20)) >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry5 = (s5 + (1 << 20)) >> 21; carry5 = (s5 + (1 << 20)) >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry7 = (s7 + (1 << 20)) >> 21; carry7 = (s7 + (1 << 20)) >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry9 = (s9 + (1 << 20)) >> 21; carry9 = (s9 + (1 << 20)) >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry11 = (s11 + (1 << 20)) >> 21; carry11 = (s11 + (1 << 20)) >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
s0 += s12 * 666643; s0 += s12 * 666643;
s1 += s12 * 470296; s1 += s12 * 470296;
s2 += s12 * 654183; s2 += s12 * 654183;
@ -702,40 +706,40 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s12 = 0; s12 = 0;
carry0 = s0 >> 21; carry0 = s0 >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry1 = s1 >> 21; carry1 = s1 >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry2 = s2 >> 21; carry2 = s2 >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry3 = s3 >> 21; carry3 = s3 >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry4 = s4 >> 21; carry4 = s4 >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry5 = s5 >> 21; carry5 = s5 >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry6 = s6 >> 21; carry6 = s6 >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry7 = s7 >> 21; carry7 = s7 >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry8 = s8 >> 21; carry8 = s8 >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry9 = s9 >> 21; carry9 = s9 >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry10 = s10 >> 21; carry10 = s10 >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
carry11 = s11 >> 21; carry11 = s11 >> 21;
s12 += carry11; s12 += carry11;
s11 -= carry11 << 21; s11 -= shift_left(carry11, 21);
s0 += s12 * 666643; s0 += s12 * 666643;
s1 += s12 * 470296; s1 += s12 * 470296;
s2 += s12 * 654183; s2 += s12 * 654183;
@ -745,37 +749,37 @@ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b,
s12 = 0; s12 = 0;
carry0 = s0 >> 21; carry0 = s0 >> 21;
s1 += carry0; s1 += carry0;
s0 -= carry0 << 21; s0 -= shift_left(carry0, 21);
carry1 = s1 >> 21; carry1 = s1 >> 21;
s2 += carry1; s2 += carry1;
s1 -= carry1 << 21; s1 -= shift_left(carry1, 21);
carry2 = s2 >> 21; carry2 = s2 >> 21;
s3 += carry2; s3 += carry2;
s2 -= carry2 << 21; s2 -= shift_left(carry2, 21);
carry3 = s3 >> 21; carry3 = s3 >> 21;
s4 += carry3; s4 += carry3;
s3 -= carry3 << 21; s3 -= shift_left(carry3, 21);
carry4 = s4 >> 21; carry4 = s4 >> 21;
s5 += carry4; s5 += carry4;
s4 -= carry4 << 21; s4 -= shift_left(carry4, 21);
carry5 = s5 >> 21; carry5 = s5 >> 21;
s6 += carry5; s6 += carry5;
s5 -= carry5 << 21; s5 -= shift_left(carry5, 21);
carry6 = s6 >> 21; carry6 = s6 >> 21;
s7 += carry6; s7 += carry6;
s6 -= carry6 << 21; s6 -= shift_left(carry6, 21);
carry7 = s7 >> 21; carry7 = s7 >> 21;
s8 += carry7; s8 += carry7;
s7 -= carry7 << 21; s7 -= shift_left(carry7, 21);
carry8 = s8 >> 21; carry8 = s8 >> 21;
s9 += carry8; s9 += carry8;
s8 -= carry8 << 21; s8 -= shift_left(carry8, 21);
carry9 = s9 >> 21; carry9 = s9 >> 21;
s10 += carry9; s10 += carry9;
s9 -= carry9 << 21; s9 -= shift_left(carry9, 21);
carry10 = s10 >> 21; carry10 = s10 >> 21;
s11 += carry10; s11 += carry10;
s10 -= carry10 << 21; s10 -= shift_left(carry10, 21);
s[0] = (unsigned char) ((s0 >> 0) & 0xff); s[0] = (unsigned char) ((s0 >> 0) & 0xff);
s[1] = (unsigned char) ((s0 >> 8) & 0xff); s[1] = (unsigned char) ((s0 >> 8) & 0xff);

View File

@ -849,7 +849,8 @@ void generate_data(char const* path, torrent_info const& ti)
for (int j = 0; j < ti.piece_size(i); j += 0x4000) for (int j = 0; j < ti.piece_size(i); j += 0x4000)
{ {
generate_block(piece, i, j, 0x4000); generate_block(piece, i, j, 0x4000);
file::iovec_t b = { piece, 0x4000}; int const left_in_piece = ti.piece_size(i) - j;
file::iovec_t const b = { piece, size_t(std::min(left_in_piece, 0x4000))};
storage_error error; storage_error error;
st->writev(b, i, j, 0, error); st->writev(b, i, j, 0, error);
if (error) if (error)

View File

@ -89,7 +89,6 @@ namespace libtorrent
void debug_log(char const* fmt, ...) void debug_log(char const* fmt, ...)
{ {
#if DEBUG_DISK_THREAD
static std::mutex log_mutex; static std::mutex log_mutex;
static const time_point start = clock_type::now(); static const time_point start = clock_type::now();
va_list v; va_list v;
@ -113,14 +112,10 @@ namespace libtorrent
prepend_time = (usr[len-1] == '\n'); prepend_time = (usr[len-1] == '\n');
std::unique_lock<std::mutex> l(log_mutex); std::unique_lock<std::mutex> l(log_mutex);
fputs(buf, stderr); fputs(buf, stderr);
#else
TORRENT_UNUSED(fmt);
#endif
} }
#endif // DEBUG_DISK_THREAD #endif // DEBUG_DISK_THREAD
int file_flags_for_job(disk_io_job* j int file_flags_for_job(disk_io_job* j
, bool const coalesce_buffers) , bool const coalesce_buffers)
{ {

View File

@ -6426,8 +6426,7 @@ namespace aux {
int const disconnect = std::min(to_disconnect, num - my_average); int const disconnect = std::min(to_disconnect, num - my_average);
to_disconnect -= disconnect; to_disconnect -= disconnect;
t.second->disconnect_peers(disconnect t.second->disconnect_peers(disconnect, errors::too_many_connections);
, error_code(errors::too_many_connections));
} }
} }
} }

View File

@ -74,7 +74,7 @@ namespace libtorrent
{ return boost::system::error_condition(ev, *this); } { return boost::system::error_condition(ev, *this); }
}; };
TORRENT_EXPORT boost::system::error_category& socks_category() boost::system::error_category& socks_category()
{ {
static socks_error_category cat; static socks_error_category cat;
return cat; return cat;

View File

@ -924,14 +924,15 @@ namespace libtorrent
// since the call to disconnect_if_redundant() may // since the call to disconnect_if_redundant() may
// delete the entry from this container, make sure // delete the entry from this container, make sure
// to increment the iterator early // to increment the iterator early
bt_peer_connection* p = static_cast<bt_peer_connection*>(*i); peer_connection* p = *i;
if (p->type() == connection_type::bittorrent) if (p->type() == connection_type::bittorrent)
{ {
std::shared_ptr<peer_connection> me(p->self()); bt_peer_connection* btp = static_cast<bt_peer_connection*>(p);
if (!p->is_disconnecting()) std::shared_ptr<peer_connection> me(btp->self());
if (!btp->is_disconnecting())
{ {
p->send_not_interested(); btp->send_not_interested();
p->write_upload_only(); btp->write_upload_only();
} }
} }

View File

@ -769,7 +769,7 @@ void utp_socket_impl::update_mtu_limits()
m_mtu = (m_mtu_floor + m_mtu_ceiling) / 2; m_mtu = (m_mtu_floor + m_mtu_ceiling) / 2;
if ((m_cwnd >> 16) < m_mtu) m_cwnd = std::int64_t(m_mtu) << 16; if ((m_cwnd >> 16) < m_mtu) m_cwnd = std::int64_t(m_mtu) * (1 << 16);
UTP_LOGV("%8p: updating MTU to: %d [%d, %d]\n" UTP_LOGV("%8p: updating MTU to: %d [%d, %d]\n"
, static_cast<void*>(this), m_mtu, m_mtu_floor, m_mtu_ceiling); , static_cast<void*>(this), m_mtu, m_mtu_floor, m_mtu_ceiling);
@ -2291,7 +2291,8 @@ void utp_socket_impl::experienced_loss(int const seq_nr)
if (compare_less_wrap(seq_nr, m_loss_seq_nr + 1, ACK_MASK)) return; if (compare_less_wrap(seq_nr, m_loss_seq_nr + 1, ACK_MASK)) return;
// cut window size in 2 // cut window size in 2
m_cwnd = (std::max)(m_cwnd * m_sm->loss_multiplier() / 100, std::int64_t(m_mtu << 16)); m_cwnd = (std::max)(m_cwnd * m_sm->loss_multiplier() / 100
, std::int64_t(m_mtu) * (1 << 16));
m_loss_seq_nr = m_seq_nr; m_loss_seq_nr = m_seq_nr;
UTP_LOGV("%8p: Lost packet %d caused cwnd cut\n", static_cast<void*>(this), seq_nr); UTP_LOGV("%8p: Lost packet %d caused cwnd cut\n", static_cast<void*>(this), seq_nr);
@ -2652,7 +2653,7 @@ void utp_socket_impl::init_mtu(int link_mtu, int utp_mtu)
// if the window size is smaller than one packet size // if the window size is smaller than one packet size
// set it to one // set it to one
if ((m_cwnd >> 16) < m_mtu) m_cwnd = std::int64_t(m_mtu) << 16; if ((m_cwnd >> 16) < m_mtu) m_cwnd = std::int64_t(m_mtu) * (1 << 16);
UTP_LOGV("%8p: initializing MTU to: %d [%d, %d]\n" UTP_LOGV("%8p: initializing MTU to: %d [%d, %d]\n"
, static_cast<void*>(this), m_mtu, m_mtu_floor, m_mtu_ceiling); , static_cast<void*>(this), m_mtu, m_mtu_floor, m_mtu_ceiling);
@ -3377,8 +3378,8 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
const bool cwnd_saturated = (m_bytes_in_flight + acked_bytes + m_mtu > (m_cwnd >> 16)); const bool cwnd_saturated = (m_bytes_in_flight + acked_bytes + m_mtu > (m_cwnd >> 16));
// all of these are fixed points with 16 bits fraction portion // all of these are fixed points with 16 bits fraction portion
const std::int64_t window_factor = (std::int64_t(acked_bytes) << 16) / in_flight; const std::int64_t window_factor = (std::int64_t(acked_bytes) * (1 << 16)) / in_flight;
const std::int64_t delay_factor = (std::int64_t(target_delay - delay) << 16) / target_delay; const std::int64_t delay_factor = (std::int64_t(target_delay - delay) * (1 << 16)) / target_delay;
std::int64_t scaled_gain; std::int64_t scaled_gain;
if (delay >= target_delay) if (delay >= target_delay)
@ -3405,7 +3406,7 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
// congestion window), don't adjust it at all. // congestion window), don't adjust it at all.
if (cwnd_saturated) if (cwnd_saturated)
{ {
std::int64_t exponential_gain = std::int64_t(acked_bytes) << 16; std::int64_t exponential_gain = std::int64_t(acked_bytes) * (1 << 16);
if (m_slow_start) if (m_slow_start)
{ {
// mimic TCP slow-start by adding the number of acked // mimic TCP slow-start by adding the number of acked
@ -3576,13 +3577,13 @@ void utp_socket_impl::tick(time_point now)
{ {
// this is just a timeout because this direction of // this is just a timeout because this direction of
// the stream is idle. Don't reset the cwnd, just decay it // the stream is idle. Don't reset the cwnd, just decay it
m_cwnd = (std::max)(m_cwnd * 2 / 3, std::int64_t(m_mtu) << 16); m_cwnd = std::max(m_cwnd * 2 / 3, std::int64_t(m_mtu) * (1 << 16));
} }
else else
{ {
// we timed out because a packet was not ACKed or because // we timed out because a packet was not ACKed or because
// the cwnd was made smaller than one packet // the cwnd was made smaller than one packet
m_cwnd = std::int64_t(m_mtu) << 16; m_cwnd = std::int64_t(m_mtu) * (1 << 16);
} }
TORRENT_ASSERT(m_cwnd >= 0); TORRENT_ASSERT(m_cwnd >= 0);

View File

@ -70,7 +70,8 @@ using namespace libtorrent;
// out, such as the log // out, such as the log
int old_stdout = -1; int old_stdout = -1;
int old_stderr = -1; int old_stderr = -1;
bool redirect_output = true; bool redirect_stdout = true;
bool redirect_stderr = true;
bool keep_files = false; bool keep_files = false;
extern int _g_test_idx; extern int _g_test_idx;
@ -81,7 +82,7 @@ unit_test_t* current_test = nullptr;
void output_test_log_to_terminal() void output_test_log_to_terminal()
{ {
if (current_test == nullptr || old_stdout == -1 || old_stderr == -1 if (current_test == nullptr || old_stdout == -1 || old_stderr == -1
|| !redirect_output || current_test->output == nullptr) || !redirect_stdout || current_test->output == nullptr)
return; return;
fflush(stdout); fflush(stdout);
@ -95,7 +96,7 @@ void output_test_log_to_terminal()
int size = 0; int size = 0;
do { do {
size = int(fread(buf, 1, sizeof(buf), current_test->output)); size = int(fread(buf, 1, sizeof(buf), current_test->output));
if (size > 0) fwrite(buf, 1, size, stderr); if (size > 0) fwrite(buf, 1, size, stdout);
} while (size > 0); } while (size > 0);
} }
@ -210,6 +211,10 @@ void print_usage(char const* executable)
"-n,--no-redirect don't redirect test output to\n" "-n,--no-redirect don't redirect test output to\n"
" temporary file, but let it go straight\n" " temporary file, but let it go straight\n"
" to stdout\n" " to stdout\n"
"--no-stderr-redirect don't redirect stderr, but still redirect\n"
" stdout. This is useful when building with\n"
" sanitizers, which rely on being able to print\n"
" to stderr and exit\n"
"\n" "\n"
"for tests, specify one or more test names as printed\n" "for tests, specify one or more test names as printed\n"
"by -l. If no test is specified, all tests are run\n", executable); "by -l. If no test is specified, all tests are run\n", executable);
@ -243,7 +248,13 @@ EXPORT int main(int argc, char const* argv[])
if (strcmp(argv[0], "-n") == 0 || strcmp(argv[0], "--no-redirect") == 0) if (strcmp(argv[0], "-n") == 0 || strcmp(argv[0], "--no-redirect") == 0)
{ {
redirect_output = false; redirect_stdout = false;
redirect_stderr = false;
}
if (strcmp(argv[0], "--no-stderr-redirect") == 0)
{
redirect_stderr = false;
} }
if (strcmp(argv[0], "-k") == 0 || strcmp(argv[0], "--keep") == 0) if (strcmp(argv[0], "-k") == 0 || strcmp(argv[0], "--keep") == 0)
@ -341,11 +352,8 @@ EXPORT int main(int argc, char const* argv[])
return 1; return 1;
} }
if (redirect_output) if (redirect_stdout) old_stdout = dup(fileno(stdout));
{ if (redirect_stderr) old_stderr = dup(fileno(stderr));
old_stdout = dup(fileno(stdout));
old_stderr = dup(fileno(stderr));
}
int num_run = 0; int num_run = 0;
for (int i = 0; i < _g_num_unit_tests; ++i) for (int i = 0; i < _g_num_unit_tests; ++i)
@ -355,7 +363,7 @@ EXPORT int main(int argc, char const* argv[])
unit_test_t& t = _g_unit_tests[i]; unit_test_t& t = _g_unit_tests[i];
if (redirect_output) if (redirect_stdout)
{ {
// redirect test output to a temporary file // redirect test output to a temporary file
fflush(stdout); fflush(stdout);
@ -365,7 +373,7 @@ EXPORT int main(int argc, char const* argv[])
if (f != nullptr) if (f != nullptr)
{ {
int ret1 = dup2(fileno(f), fileno(stdout)); int ret1 = dup2(fileno(f), fileno(stdout));
dup2(fileno(f), fileno(stderr)); if (redirect_stderr) dup2(fileno(f), fileno(stderr));
if (ret1 >= 0) if (ret1 >= 0)
{ {
t.output = f; t.output = f;
@ -432,17 +440,12 @@ EXPORT int main(int argc, char const* argv[])
total_failures += _g_test_failures; total_failures += _g_test_failures;
++num_run; ++num_run;
if (redirect_output && t.output) if (redirect_stdout && t.output)
{
fclose(t.output); fclose(t.output);
} }
}
if (redirect_output) if (redirect_stdout) dup2(old_stdout, fileno(stdout));
{ if (redirect_stderr) dup2(old_stderr, fileno(stderr));
dup2(old_stdout, fileno(stdout));
dup2(old_stderr, fileno(stderr));
}
if (!tests_to_run.empty()) if (!tests_to_run.empty())
{ {
@ -468,11 +471,8 @@ EXPORT int main(int argc, char const* argv[])
stop_peer(); stop_peer();
stop_dht(); stop_dht();
if (redirect_output) if (redirect_stdout) fflush(stdout);
{ if (redirect_stderr) fflush(stderr);
fflush(stdout);
fflush(stderr);
}
ret = print_failures(); ret = print_failures();
#if !defined TORRENT_LOGGING #if !defined TORRENT_LOGGING

View File

@ -365,7 +365,7 @@ TORRENT_TEST(bdecode_error)
error_code ec(bdecode_errors::overflow); error_code ec(bdecode_errors::overflow);
TEST_EQUAL(ec.message(), "integer overflow"); TEST_EQUAL(ec.message(), "integer overflow");
TEST_EQUAL(ec.category().name(), std::string("bdecode error")); TEST_EQUAL(ec.category().name(), std::string("bdecode error"));
ec.assign(5434, get_bdecode_category()); ec.assign(5434, bdecode_category());
TEST_EQUAL(ec.message(), "Unknown error"); TEST_EQUAL(ec.message(), "Unknown error");
} }
@ -448,8 +448,7 @@ TORRENT_TEST(depth_limit)
error_code ec; error_code ec;
int ret = bdecode(b, b + sizeof(b), e, ec, nullptr, 100); int ret = bdecode(b, b + sizeof(b), e, ec, nullptr, 100);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
TEST_EQUAL(ec, error_code(bdecode_errors::depth_exceeded TEST_EQUAL(ec, error_code(bdecode_errors::depth_exceeded));
, get_bdecode_category()));
} }
// test the item limit // test the item limit
@ -466,8 +465,7 @@ TORRENT_TEST(item_limit)
error_code ec; error_code ec;
int ret = bdecode(b, b + i + 1, e, ec, nullptr, 1000, 1000); int ret = bdecode(b, b + i + 1, e, ec, nullptr, 1000, 1000);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
TEST_EQUAL(ec, error_code(bdecode_errors::limit_exceeded TEST_EQUAL(ec, error_code(bdecode_errors::limit_exceeded));
, get_bdecode_category()));
} }
// test unexpected EOF // test unexpected EOF

View File

@ -240,8 +240,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_CHECK(ec == error_code(bdecode_errors::expected_value TEST_EQUAL(ec, error_code(bdecode_errors::expected_value));
, get_bdecode_category()));
} }
// test strings with overflow length-prefix // test strings with overflow length-prefix
@ -252,8 +251,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_CHECK(ec == error_code(bdecode_errors::overflow TEST_EQUAL(ec, error_code(bdecode_errors::overflow));
, get_bdecode_category()));
} }
// test integers that don't fit in 64 bits // test integers that don't fit in 64 bits
@ -330,8 +328,7 @@ TORRENT_TEST(lazy_entry)
error_code ec; error_code ec;
int ret = lazy_bdecode(b, b + sizeof(b), e, ec); int ret = lazy_bdecode(b, b + sizeof(b), e, ec);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
TEST_EQUAL(ec, error_code(bdecode_errors::depth_exceeded TEST_EQUAL(ec, error_code(bdecode_errors::depth_exceeded));
, get_bdecode_category()));
} }
// test the item limit // test the item limit
@ -347,8 +344,7 @@ TORRENT_TEST(lazy_entry)
error_code ec; error_code ec;
int ret = lazy_bdecode(b, b + i + 1, e, ec, nullptr, 1000, 1000); int ret = lazy_bdecode(b, b + i + 1, e, ec, nullptr, 1000, 1000);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
TEST_EQUAL(ec, error_code(bdecode_errors::limit_exceeded TEST_EQUAL(ec, error_code(bdecode_errors::limit_exceeded));
, get_bdecode_category()));
} }
// test unexpected EOF // test unexpected EOF
@ -360,8 +356,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
// test unexpected EOF (really expected terminator) // test unexpected EOF (really expected terminator)
@ -373,8 +368,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
// test expected string // test expected string
@ -387,8 +381,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::expected_digit TEST_EQUAL(ec, error_code(bdecode_errors::expected_digit));
, get_bdecode_category()));
} }
// test unexpected EOF while parsing dict key // test unexpected EOF while parsing dict key
@ -400,8 +393,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
// test unexpected EOF while parsing dict key // test unexpected EOF while parsing dict key
@ -413,8 +405,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
// test expected string while parsing dict key // test expected string while parsing dict key
@ -426,8 +417,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::expected_digit TEST_EQUAL(ec, error_code(bdecode_errors::expected_digit));
, get_bdecode_category()));
} }
// test unexpected EOF while parsing int // test unexpected EOF while parsing int
@ -439,8 +429,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
// test unexpected EOF while parsing int // test unexpected EOF while parsing int
@ -452,8 +441,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
@ -466,8 +454,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::expected_colon TEST_EQUAL(ec, error_code(bdecode_errors::expected_colon));
, get_bdecode_category()));
} }
// test empty string // test empty string
@ -478,8 +465,7 @@ TORRENT_TEST(lazy_entry)
error_code ec; error_code ec;
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_EQUAL(ret, -1); TEST_EQUAL(ret, -1);
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
} }
@ -492,8 +478,7 @@ TORRENT_TEST(lazy_entry)
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr); int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
TEST_CHECK(ret != 0); TEST_CHECK(ret != 0);
std::printf("%s\n", print_entry(e).c_str()); std::printf("%s\n", print_entry(e).c_str());
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
, get_bdecode_category()));
} }
// test pascal string dict // test pascal string dict

View File

@ -286,3 +286,4 @@ TORRENT_TEST(empty)
TEST_CHECK(true); TEST_CHECK(true);
} }
#endif // TORRENT_DISABLE_DHT #endif // TORRENT_DISABLE_DHT