merge build fix with C++11 from RC_0_16

This commit is contained in:
Arvid Norberg 2013-09-25 19:44:29 +00:00
parent 7ce6425534
commit 89c3db477d
24 changed files with 56 additions and 51 deletions

View File

@ -24,6 +24,7 @@
* fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP
* fix building with C++11
* fix IPv6 support in UDP socket (uTP)
* fix mingw build issues
* increase max allowed outstanding piece requests from peers

View File

@ -2134,7 +2134,7 @@ int main(int argc, char* argv[])
progress_bar_color = "32"; // green
}
snprintf(str, sizeof(str), " %-10s: %s%-11"PRId64"%s Bytes %6.2f%% %s\n"
snprintf(str, sizeof(str), " %-10s: %s%-11" PRId64 "%s Bytes %6.2f%% %s\n"
, s.sequential_download?"sequential":"progress"
, esc("32"), s.total_done, esc("0")
, s.progress_ppm / 10000.f
@ -2197,8 +2197,8 @@ int main(int argc, char* argv[])
out += str;
snprintf(str, sizeof(str), "==== waste: %s fail: %s unchoked: %d / %d "
"bw queues: %8d (%d) | %8d (%d) disk queues: %d | %d cache: w: %"PRId64"%% r: %"PRId64"%% "
"size: %s (%s) / %s dq: %"PRId64" ===\n"
"bw queues: %8d (%d) | %8d (%d) disk queues: %d | %d cache: w: %" PRId64 "%% r: %" PRId64 "%% "
"size: %s (%s) / %s dq: %" PRId64 " ===\n"
, add_suffix(sess_stat.total_redundant_bytes).c_str()
, add_suffix(sess_stat.total_failed_bytes).c_str()
, sess_stat.num_unchoked, sess_stat.allowed_upload_slots
@ -2224,7 +2224,7 @@ int main(int argc, char* argv[])
if (show_dht_status)
{
snprintf(str, sizeof(str), "DHT nodes: %d DHT cached nodes: %d "
"total DHT size: %"PRId64" total observers: %d\n"
"total DHT size: %" PRId64 " total observers: %d\n"
, sess_stat.dht_nodes, sess_stat.dht_node_cache, sess_stat.dht_global_nodes
, sess_stat.dht_total_allocations);
out += str;

View File

@ -166,7 +166,7 @@ std::string print_entry(libtorrent::lazy_entry const& e, bool single_line = fals
case lazy_entry::int_t:
{
char str[100];
snprintf(str, sizeof(str), "%"PRId64, e.int_value());
snprintf(str, sizeof(str), "%" PRId64, e.int_value());
return str;
}
case lazy_entry::string_t:

View File

@ -83,7 +83,7 @@ int main(int argc, char* argv[])
for (int i = 0; i < ti->num_files(); ++i)
{
if (ti->file_at(i).size == files[i].first) continue;
fprintf(stderr, "Files for this torrent are missing or incomplete: %s was %"PRId64" bytes, expected %"PRId64" bytes\n"
fprintf(stderr, "Files for this torrent are missing or incomplete: %s was %" PRId64 " bytes, expected %" PRId64 " bytes\n"
, ti->files().file_path(ti->file_at(i)).c_str(), files[i].first, ti->file_at(i).size);
return 1;
}
@ -120,7 +120,7 @@ int main(int argc, char* argv[])
for (int i = 0; i < pieces.size(); ++i)
{
fprintf(f, "%d %"PRId64"\n", pieces[i].first, pieces[i].second);
fprintf(f, "%d %" PRId64 "\n", pieces[i].first, pieces[i].second);
}
fclose(f);

View File

@ -113,7 +113,7 @@ void print_feed(feed_status const& f)
, end(f.items.end()); i != end; ++i)
{
printf("\033[32m%s\033[0m\n------------------------------------------------------\n"
" url: %s\n size: %"PRId64"\n info-hash: %s\n uuid: %s\n description: %s\n"
" url: %s\n size: %" PRId64 "\n info-hash: %s\n uuid: %s\n description: %s\n"
" comment: %s\n category: %s\n"
, i->title.c_str(), i->url.c_str(), i->size
, i->info_hash.is_all_zeros() ? "" : to_hex(i->info_hash.to_string()).c_str()

View File

@ -437,7 +437,7 @@ namespace libtorrent
#endif // TORRENT_NO_DEPRECATE
#ifndef TORRENT_DISABLE_DHT
bool is_dht_running() const { return m_dht; }
bool is_dht_running() const { return m_dht.get(); }
#endif
#if TORRENT_USE_I2P

View File

@ -50,6 +50,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/string_util.hpp" // for allocate_string_copy
#include <stdlib.h> // free
#ifndef BOOST_SYSTEM_NOEXCEPT
#define BOOST_SYSTEM_NOEXCEPT throw()
#endif
namespace libtorrent
{
@ -496,17 +500,17 @@ namespace libtorrent
struct TORRENT_EXPORT libtorrent_error_category : boost::system::error_category
{
virtual const char* name() const throw();
virtual std::string message(int ev) const throw();
virtual boost::system::error_condition default_error_condition(int ev) const throw()
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT;
virtual std::string message(int ev) const BOOST_SYSTEM_NOEXCEPT;
virtual boost::system::error_condition default_error_condition(int ev) const BOOST_SYSTEM_NOEXCEPT
{ return boost::system::error_condition(ev, *this); }
};
struct TORRENT_EXPORT http_error_category : boost::system::error_category
{
virtual const char* name() const throw();
virtual std::string message(int ev) const throw();
virtual boost::system::error_condition default_error_condition(int ev) const throw()
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT;
virtual std::string message(int ev) const BOOST_SYSTEM_NOEXCEPT;
virtual boost::system::error_condition default_error_condition(int ev) const BOOST_SYSTEM_NOEXCEPT
{ return boost::system::error_condition(ev, *this); }
};

View File

@ -67,9 +67,9 @@ namespace libtorrent {
struct TORRENT_EXPORT i2p_error_category : boost::system::error_category
{
virtual const char* name() const;
virtual std::string message(int ev) const;
virtual boost::system::error_condition default_error_condition(int ev) const
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT;
virtual std::string message(int ev) const BOOST_SYSTEM_NOEXCEPT;
virtual boost::system::error_condition default_error_condition(int ev) const BOOST_SYSTEM_NOEXCEPT
{ return boost::system::error_condition(ev, *this); }
};

View File

@ -68,9 +68,9 @@ typedef asio::error::error_category socks_error_category;
struct TORRENT_EXTRA_EXPORT socks_error_category : boost::system::error_category
{
virtual const char* name() const;
virtual std::string message(int ev) const;
virtual boost::system::error_condition default_error_condition(int ev) const
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT;
virtual std::string message(int ev) const BOOST_SYSTEM_NOEXCEPT;
virtual boost::system::error_condition default_error_condition(int ev) const BOOST_SYSTEM_NOEXCEPT
{ return boost::system::error_condition(ev, *this); }
};

View File

@ -99,9 +99,9 @@ namespace libtorrent
struct TORRENT_EXPORT upnp_error_category : boost::system::error_category
{
virtual const char* name() const;
virtual std::string message(int ev) const;
virtual boost::system::error_condition default_error_condition(int ev) const
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT;
virtual std::string message(int ev) const BOOST_SYSTEM_NOEXCEPT;
virtual boost::system::error_condition default_error_condition(int ev) const BOOST_SYSTEM_NOEXCEPT
{ return boost::system::error_condition(ev, *this); }
};

View File

@ -611,7 +611,7 @@ namespace libtorrent
else
{
TORRENT_ASSERT(buf);
file::iovec_t b = { buf.get(), buffer_size };
file::iovec_t b = { buf.get(), size_t(buffer_size) };
int ret = p.storage->write_impl(&b, p.piece, (std::min)(
i * m_block_size, piece_size) - buffer_size, 1);
if (ret > 0) ++num_write_calls;
@ -811,7 +811,7 @@ namespace libtorrent
if (buf)
{
l.unlock();
file::iovec_t b = { buf.get(), buffer_size };
file::iovec_t b = { buf.get(), size_t(buffer_size) };
ret = p.storage->read_impl(&b, p.piece, start_block * m_block_size, 1);
l.lock();
++m_cache_stats.reads;
@ -2025,7 +2025,7 @@ namespace libtorrent
}
else if (ret == -2)
{
file::iovec_t b = { j.buffer, j.buffer_size };
file::iovec_t b = { j.buffer, size_t(j.buffer_size) };
ret = j.storage->read_impl(&b, j.piece, j.offset, 1);
if (ret < 0)
{
@ -2138,7 +2138,7 @@ namespace libtorrent
{
l.unlock();
ptime start = time_now_hires();
file::iovec_t iov = {j.buffer, j.buffer_size};
file::iovec_t iov = {j.buffer, size_t(j.buffer_size) };
ret = j.storage->write_impl(&iov, j.piece, j.offset, 1);
l.lock();
if (ret < 0)

View File

@ -40,12 +40,12 @@ namespace libtorrent
{
#if BOOST_VERSION >= 103500
const char* libtorrent_error_category::name() const throw()
const char* libtorrent_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "libtorrent error";
}
std::string libtorrent_error_category::message(int ev) const throw()
std::string libtorrent_error_category::message(int ev) const BOOST_SYSTEM_NOEXCEPT
{
static char const* msgs[] =
{
@ -275,12 +275,12 @@ namespace libtorrent
return http_category;
}
const char* http_error_category::name() const throw()
const char* http_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "http error";
}
std::string http_error_category::message(int ev) const throw()
std::string http_error_category::message(int ev) const BOOST_SYSTEM_NOEXCEPT
{
std::string ret;
ret += to_string(ev).elems;

View File

@ -1084,7 +1084,7 @@ namespace libtorrent
0, // start offset
0, // length (0 = until EOF)
getpid(), // owner
(mode & write_only) ? F_WRLCK : F_RDLCK, // lock type
short((mode & write_only) ? F_WRLCK : F_RDLCK), // lock type
SEEK_SET // whence
};
if (fcntl(m_fd, F_SETLK, &l) != 0)

View File

@ -141,10 +141,10 @@ namespace libtorrent
, "info_hash=%s"
"&peer_id=%s"
"&port=%d"
"&uploaded=%"PRId64
"&downloaded=%"PRId64
"&left=%"PRId64
"&corrupt=%"PRId64
"&uploaded=%" PRId64
"&downloaded=%" PRId64
"&left=%" PRId64
"&corrupt=%" PRId64
"&key=%X"
"%s%s" // event
"&numwant=%d"

View File

@ -48,12 +48,12 @@ namespace libtorrent
i2p_error_category i2p_category;
const char* i2p_error_category::name() const
const char* i2p_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "i2p error";
}
std::string i2p_error_category::message(int ev) const
std::string i2p_error_category::message(int ev) const BOOST_SYSTEM_NOEXCEPT
{
static char const* messages[] =
{

View File

@ -491,7 +491,7 @@ namespace libtorrent
case lazy_entry::int_t:
{
char str[100];
snprintf(str, sizeof(str), "%"PRId64, e.int_value());
snprintf(str, sizeof(str), "%" PRId64, e.int_value());
return str;
}
case lazy_entry::string_t:

View File

@ -42,12 +42,12 @@ namespace libtorrent
socks_error_category socks_category;
#if BOOST_VERSION >= 103500
const char* socks_error_category::name() const
const char* socks_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "socks error";
}
std::string socks_error_category::message(int ev) const
std::string socks_error_category::message(int ev) const BOOST_SYSTEM_NOEXCEPT
{
static char const* messages[] =
{

View File

@ -82,7 +82,7 @@ namespace libtorrent
{
static const ptime start = time_now_hires();
char ret[200];
snprintf(ret, sizeof(ret), "%"PRId64, total_microseconds(time_now_hires() - start));
snprintf(ret, sizeof(ret), "%" PRId64, total_microseconds(time_now_hires() - start));
return ret;
}
}

View File

@ -1099,12 +1099,12 @@ namespace
#if BOOST_VERSION >= 103500
const char* upnp_error_category::name() const
const char* upnp_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "UPnP error";
}
std::string upnp_error_category::message(int ev) const
std::string upnp_error_category::message(int ev) const BOOST_SYSTEM_NOEXCEPT
{
int num_errors = sizeof(error_codes) / sizeof(error_codes[0]);
error_code_t* end = error_codes + num_errors;

View File

@ -180,7 +180,7 @@ int test_main()
// test invalid encoding
{
char buf[] =
unsigned char buf[] =
{ 0x64 , 0x31 , 0x3a , 0x61 , 0x64 , 0x32 , 0x3a , 0x69
, 0x64 , 0x32 , 0x30 , 0x3a , 0x2a , 0x21 , 0x19 , 0x89
, 0x9f , 0xcd , 0x5f , 0xc9 , 0xbc , 0x80 , 0xc1 , 0x76
@ -198,7 +198,7 @@ int test_main()
printf("%s\n", buf);
lazy_entry e;
error_code ec;
int ret = lazy_bdecode(buf, buf + sizeof(buf), e, ec);
int ret = lazy_bdecode((char*)buf, (char*)buf + sizeof(buf), e, ec);
TEST_CHECK(ret == -1);
}
return 0;

View File

@ -55,7 +55,7 @@ void print_feed(feed_status const& f)
, end(f.items.end()); i != end; ++i)
{
fprintf(stderr, "\033[32m%s\033[0m\n------------------------------------------------------\n"
" url: %s\n size: %"PRId64"\n info-hash: %s\n uuid: %s\n description: %s\n"
" url: %s\n size: %" PRId64 "\n info-hash: %s\n uuid: %s\n description: %s\n"
" comment: %s\n category: %s\n"
, i->title.c_str(), i->url.c_str(), i->size
, i->info_hash.is_all_zeros() ? "" : to_hex(i->info_hash.to_string()).c_str()

View File

@ -429,7 +429,7 @@ int test_main()
int first = ti->map_file(i, 0, 0).piece;
int last = ti->map_file(i, (std::max)(fs.file_size(i)-1, size_type(0)), 0).piece;
int flags = fs.file_flags(i);
fprintf(stderr, " %11"PRId64" %c%c%c%c [ %4d, %4d ] %7u %s %s %s%s\n"
fprintf(stderr, " %11" PRId64 " %c%c%c%c [ %4d, %4d ] %7u %s %s %s%s\n"
, fs.file_size(i)
, (flags & file_storage::flag_pad_file)?'p':'-'
, (flags & file_storage::flag_executable)?'x':'-'

View File

@ -197,7 +197,7 @@ void save_file(char const* filename, char const* data, int size)
fprintf(stderr, "ERROR opening file '%s': %s\n", filename, ec.message().c_str());
return;
}
file::iovec_t b = { (void*)data, size };
file::iovec_t b = { (void*)data, size_t(size) };
out.writev(0, &b, 1, ec);
TEST_CHECK(!ec);
if (ec)

View File

@ -210,7 +210,7 @@ int main(int argc, char* argv[])
if (first_timestamp == 0) first_timestamp = r.timestamp;
fprintf(expand_file, "%"PRIu64"\t%"PRIu64"\t%"PRIu32"\t%"PRIu32"\t%"PRIu32"\t%"PRIu32"\n"
fprintf(expand_file, "%" PRIu64 "\t%" PRIu64 "\t%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\t%" PRIu32 "\n"
, r.timestamp, r.infohash, r.peer, r.piece, r.start, r.length);
bool hit = disk_cache->incoming_request(r);