From 09b3a865ef389b689fe604a6d5ed994c4ec9a745 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 29 Nov 2008 21:33:21 +0000 Subject: [PATCH] fixed compiler flags in pkg-config file and made header files not depend on the NDEBUG define --- Jamfile | 1 + bindings/python/setup.py.in | 2 +- configure.in | 18 +++++--- include/libtorrent/assert.hpp | 2 +- include/libtorrent/aux_/session_impl.hpp | 6 +-- include/libtorrent/bandwidth_manager.hpp | 4 +- include/libtorrent/bencode.hpp | 29 +++++++------ include/libtorrent/bt_peer_connection.hpp | 4 +- include/libtorrent/connection_queue.hpp | 4 +- include/libtorrent/disk_io_thread.hpp | 4 +- include/libtorrent/entry.hpp | 21 ++++----- include/libtorrent/file.hpp | 2 +- include/libtorrent/invariant_check.hpp | 2 +- include/libtorrent/kademlia/node.hpp | 2 +- include/libtorrent/kademlia/observer.hpp | 4 +- include/libtorrent/kademlia/rpc_manager.hpp | 2 +- include/libtorrent/peer_connection.hpp | 8 ++-- include/libtorrent/piece_picker.hpp | 4 +- include/libtorrent/policy.hpp | 4 +- include/libtorrent/session.hpp | 2 +- include/libtorrent/stat.hpp | 2 +- include/libtorrent/storage.hpp | 4 +- include/libtorrent/time.hpp | 4 +- include/libtorrent/torrent.hpp | 18 ++++---- include/libtorrent/torrent_handle.hpp | 2 +- include/libtorrent/udp_socket.hpp | 4 +- include/libtorrent/upnp.hpp | 6 +-- include/libtorrent/web_peer_connection.hpp | 2 +- libtorrent-rasterbar.pc.in | 5 ++- src/assert.cpp | 2 +- src/bt_peer_connection.cpp | 28 ++++++------ src/connection_queue.cpp | 8 ++-- src/disk_io_thread.cpp | 8 ++-- src/entry.cpp | 28 ++++++------ src/file.cpp | 8 ++-- src/kademlia/closest_nodes.cpp | 2 +- src/kademlia/find_data.cpp | 2 +- src/kademlia/node.cpp | 4 +- src/kademlia/refresh.cpp | 4 +- src/kademlia/rpc_manager.cpp | 4 +- src/peer_connection.cpp | 48 ++++++++++----------- src/piece_picker.cpp | 20 ++++----- src/policy.cpp | 14 +++--- src/session.cpp | 4 +- src/session_impl.cpp | 16 +++---- src/storage.cpp | 32 +++++++------- src/torrent.cpp | 32 +++++++------- src/torrent_handle.cpp | 2 +- src/udp_socket.cpp | 4 +- src/web_peer_connection.cpp | 2 +- 50 files changed, 227 insertions(+), 217 deletions(-) diff --git a/Jamfile b/Jamfile index ba47a0625..2fc213fc0 100755 --- a/Jamfile +++ b/Jamfile @@ -372,6 +372,7 @@ local usage-requirements = ./include/libtorrent shipped:./zlib release:NDEBUG + debug:TORRENT_DEBUG _FILE_OFFSET_BITS=64 BOOST_MULTI_INDEX_DISABLE_SERIALIZATION @linking diff --git a/bindings/python/setup.py.in b/bindings/python/setup.py.in index 26867dfb9..8b6e808ff 100644 --- a/bindings/python/setup.py.in +++ b/bindings/python/setup.py.in @@ -50,7 +50,7 @@ if platform.system() == 'Windows': source_list = os.listdir(os.path.join(os.path.dirname(__file__), "src")) source_list = [os.path.join("src", s) for s in source_list if s.endswith(".cpp")] -extra_cmd = '@COMPILETIME_OPTIONS@ @CPPFLAGS@' +extra_cmd = '@COMPILETIME_OPTIONS@ @CPPFLAGS@ @LIBS@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @SSL_LIBS@ @BOOST_SYSTEM_LIB@ @SSL_LDFLAGS@ @SSL_CXXFLAGS@' setup( name='python-libtorrent', version='@PACKAGE_VERSION@', diff --git a/configure.in b/configure.in index 6acc9ee49..0119d286e 100644 --- a/configure.in +++ b/configure.in @@ -410,7 +410,7 @@ esac dnl Set some defines if we are building a shared library if [[ "x$enable_shared" == "xyes" ]]; then AC_DEFINE(TORRENT_BUILDING_SHARED,,[Make sure the functions and classes are exported.]) - AC_DEFINE(TORRENT_LINKING_SHARED,,[Make sure the functions and classes are exported.]) + COMPILETIME_OPTIONS+="-DTORRENT_LINKING_SHARED " fi dnl want some debugging symbols with that? @@ -420,19 +420,23 @@ AC_ARG_ENABLE( [case "$enableval" in no) AC_DEFINE(NDEBUG,,[Define to disable debugging]) - DEBUGFLAGS="" - COMPILETIME_OPTIONS+="-DNDEBUG " + DEBUGFLAGS="-Os" +# COMPILETIME_OPTIONS+="-DNDEBUG " ;; yes) DEBUGFLAGS="-g" - COMPILETIME_OPTIONS+="-DLT_DEBUG " + COMPILETIME_OPTIONS+="-DTORRENT_DEBUG " + AC_DEFINE(TORRENT_DEBUG,,[Define to enable libtorrent debug build]) ;; *) - DEBUGFLAGS="$enableval" + AC_MSG_RESULT() + AC_MSG_ERROR([Unknown --enable-debug option "$enableval". Use either "yes" or "no".]) ;; esac], - [DEBUGFLAGS="" - AC_DEFINE(NDEBUG,,[Define to disable debugging])] + [DEBUGFLAGS="-Os" + AC_DEFINE(NDEBUG,,[Define to disable debugging]) +# COMPILETIME_OPTIONS+="-DNDEBUG " + ] ) AC_SUBST(DEBUGFLAGS) diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index 6396526ba..71a1aa406 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. std::string demangle(char const* name); #endif -#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined(NDEBUG) +#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && defined TORRENT_DEBUG TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function); #define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__); } while (false) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 96795c0d9..baa91e8c5 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -110,7 +110,7 @@ namespace libtorrent // the size of each allocation that is chained in the send buffer enum { send_buffer_size = 200 }; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG friend class ::libtorrent::peer_connection; #endif friend struct checker_impl; @@ -132,7 +132,7 @@ namespace libtorrent void add_extension(boost::function( torrent*, void*)> ext); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool has_peer(peer_connection const* p) const { return std::find_if(m_connections.begin(), m_connections.end() @@ -580,7 +580,7 @@ namespace libtorrent // connect to a peer next time second_tick is called. // This implements a round robin. int m_next_connect_torrent; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index 20344ebc5..dc296a13a 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -157,7 +157,7 @@ struct bandwidth_manager m_history_timer.cancel(ec); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool is_queued(PeerConnection const* peer) const { mutex_t::scoped_lock l(m_mutex); @@ -223,7 +223,7 @@ struct bandwidth_manager if (!m_queue.empty()) hand_out_bandwidth(l); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const { int current_quota = 0; diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 49b59e9da..b5b330d4d 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -238,7 +238,7 @@ namespace libtorrent if (in == end) { err = true; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; @@ -257,7 +257,7 @@ namespace libtorrent ++in; // 'e' ret = entry(entry::int_t); ret.integer() = boost::lexical_cast(val); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif } break; @@ -275,7 +275,7 @@ namespace libtorrent bdecode_recursive(in, end, e, err, depth + 1); if (err) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; @@ -283,13 +283,13 @@ namespace libtorrent if (in == end) { err = true; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; } } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif TORRENT_ASSERT(*in == 'e'); @@ -308,7 +308,7 @@ namespace libtorrent bdecode_recursive(in, end, key, err, depth + 1); if (err || key.type() != entry::string_t) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; @@ -317,7 +317,7 @@ namespace libtorrent bdecode_recursive(in, end, e, err, depth + 1); if (err) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; @@ -325,13 +325,13 @@ namespace libtorrent if (in == end) { err = true; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; } } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif TORRENT_ASSERT(*in == 'e'); @@ -346,7 +346,7 @@ namespace libtorrent std::string len_s = read_until(in, end, ':', err); if (err) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; @@ -358,7 +358,7 @@ namespace libtorrent read_string(in, end, len, ret.string(), err); if (err) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; @@ -367,12 +367,12 @@ namespace libtorrent else { err = true; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif return; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ret.m_type_queried = false; #endif } @@ -391,7 +391,9 @@ namespace libtorrent entry e; bool err = false; detail::bdecode_recursive(start, end, e, err, 0); +#ifdef TORRENT_DEBUG TORRENT_ASSERT(e.m_type_queried == false); +#endif if (err) return entry(); return e; } @@ -411,3 +413,4 @@ namespace libtorrent } #endif // TORRENT_BENCODE_HPP_INCLUDED + diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index a900bfc7e..c9a1bc7e5 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -233,7 +233,7 @@ namespace libtorrent void on_connected(); void on_metadata(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; ptime m_last_choke; #endif @@ -407,7 +407,7 @@ private: boost::scoped_ptr m_sync_hash; #endif // #ifndef TORRENT_DISABLE_ENCRYPTION -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // this is set to true when the client's // bitfield is sent to this peer bool m_sent_bitfield; diff --git a/include/libtorrent/connection_queue.hpp b/include/libtorrent/connection_queue.hpp index 749d72133..c41124e64 100644 --- a/include/libtorrent/connection_queue.hpp +++ b/include/libtorrent/connection_queue.hpp @@ -65,7 +65,7 @@ public: void close(); int size() const { return m_queue.size(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif @@ -101,7 +101,7 @@ private: typedef boost::recursive_mutex mutex_t; mutable mutex_t m_mutex; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool m_in_timeout_function; #endif #ifdef TORRENT_CONNECTION_LOGGING diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 948db1176..0ae84898c 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -191,14 +191,14 @@ namespace libtorrent void operator()(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool is_disk_buffer(char* buffer) const; #endif char* allocate_buffer(); void free_buffer(char* buf); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 473eb1ca8..a970bf81b 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -206,7 +206,7 @@ namespace libtorrent }; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG public: // in debug mode this is set to false by bdecode // to indicate that the program has not yet queried @@ -226,7 +226,7 @@ namespace libtorrent inline entry::data_type entry::type() const { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif return m_type; @@ -245,7 +245,7 @@ namespace libtorrent if (m_type == undefined_t) construct(int_t); #ifndef BOOST_NO_EXCEPTIONS if (m_type != int_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == int_t); @@ -256,7 +256,7 @@ namespace libtorrent { #ifndef BOOST_NO_EXCEPTIONS if (m_type != int_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == int_t); @@ -268,7 +268,7 @@ namespace libtorrent if (m_type == undefined_t) construct(string_t); #ifndef BOOST_NO_EXCEPTIONS if (m_type != string_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == string_t); @@ -279,7 +279,7 @@ namespace libtorrent { #ifndef BOOST_NO_EXCEPTIONS if (m_type != string_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == string_t); @@ -291,7 +291,7 @@ namespace libtorrent if (m_type == undefined_t) construct(list_t); #ifndef BOOST_NO_EXCEPTIONS if (m_type != list_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == list_t); @@ -302,7 +302,7 @@ namespace libtorrent { #ifndef BOOST_NO_EXCEPTIONS if (m_type != list_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == list_t); @@ -314,7 +314,7 @@ namespace libtorrent if (m_type == undefined_t) construct(dictionary_t); #ifndef BOOST_NO_EXCEPTIONS if (m_type != dictionary_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == dictionary_t); @@ -325,7 +325,7 @@ namespace libtorrent { #ifndef BOOST_NO_EXCEPTIONS if (m_type != dictionary_t) throw type_error("invalid type requested from entry"); -#elif !defined NDEBUG +#elif defined TORRENT_DEBUG TORRENT_ASSERT(m_type_queried); #endif TORRENT_ASSERT(m_type == dictionary_t); @@ -335,3 +335,4 @@ namespace libtorrent } #endif // TORRENT_ENTRY_HPP_INCLUDED + diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 6e4ab67f2..87de40f8f 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -111,7 +111,7 @@ namespace libtorrent #else int m_fd; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int m_open_mode; #endif diff --git a/include/libtorrent/invariant_check.hpp b/include/libtorrent/invariant_check.hpp index c687b6a63..175a9861b 100644 --- a/include/libtorrent/invariant_check.hpp +++ b/include/libtorrent/invariant_check.hpp @@ -66,7 +66,7 @@ namespace libtorrent } } -#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS #define INVARIANT_CHECK \ invariant_checker const& _invariant_check = make_invariant_checker(*this); \ (void)_invariant_check; \ diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index 6876fff94..9f4d3c62f 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -150,7 +150,7 @@ public: { observer_ptr o(new (m_rpc.allocator().malloc()) announce_observer( m_rpc.allocator(), m_info_hash, m_listen_port, r.write_token)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_rpc.invoke(messages::announce_peer, r.addr, o); diff --git a/include/libtorrent/kademlia/observer.hpp b/include/libtorrent/kademlia/observer.hpp index 073f453bc..7e11a4c70 100644 --- a/include/libtorrent/kademlia/observer.hpp +++ b/include/libtorrent/kademlia/observer.hpp @@ -57,7 +57,7 @@ struct observer : boost::noncopyable , pool_allocator(p) , m_refs(0) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_in_constructor = true; #endif } @@ -86,7 +86,7 @@ struct observer : boost::noncopyable udp::endpoint target_addr; ptime sent; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool m_in_constructor; #endif private: diff --git a/include/libtorrent/kademlia/rpc_manager.hpp b/include/libtorrent/kademlia/rpc_manager.hpp index a88adcc86..0a08be34d 100644 --- a/include/libtorrent/kademlia/rpc_manager.hpp +++ b/include/libtorrent/kademlia/rpc_manager.hpp @@ -92,7 +92,7 @@ public: void reply(msg& m); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_t allocation_size() const; void check_invariant() const; #endif diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 23aaca60c..9371a7d5f 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -399,7 +399,7 @@ namespace libtorrent void assign_bandwidth(int channel, int amount); void expire_bandwidth(int channel, int amount); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; ptime m_last_choke; #endif @@ -461,7 +461,7 @@ namespace libtorrent bool packet_finished() const { return m_packet_size <= m_recv_pos; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool piece_failed; #endif @@ -569,7 +569,7 @@ namespace libtorrent char m_country[2]; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG boost::intrusive_ptr self() { TORRENT_ASSERT(!m_in_constructor); @@ -877,7 +877,7 @@ namespace libtorrent // pick any pieces from this peer bool m_no_download:1; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG public: bool m_in_constructor:1; bool m_disconnect_started:1; diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 2e76e8a9f..1cdc84bec 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -308,14 +308,14 @@ namespace libtorrent int num_have() const { return m_num_have; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // used in debug mode void verify_priority(int start, int end, int prio) const; void check_invariant(const torrent* t = 0) const; void verify_pick(std::vector const& picked , bitfield const& bits) const; #endif -#if defined TORRENT_PICKER_LOG || !defined NDEBUG +#if defined TORRENT_PICKER_LOG || defined TORRENT_DEBUG void print_pieces() const; #endif diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index 500d59e4d..62d165b77 100644 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -110,7 +110,7 @@ namespace libtorrent void ip_filter_updated(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool has_connection(const peer_connection* p); void check_invariant() const; @@ -156,7 +156,7 @@ namespace libtorrent peer_connection* connection; #ifndef TORRENT_DISABLE_GEO_IP -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // only used in debug mode to assert that // the first entry in the AS pair keeps the same boost::uint16_t inet_as_num; diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index fae835aa6..acd887e05 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -83,7 +83,7 @@ namespace libtorrent // this is used to create linker errors when trying to link to // a library with a conflicting build configuration than the application -#ifdef NDEBUG +#ifdef TORRENT_DEBUG #define G _release #else #define G _debug diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index dfcf82c01..41c0e2750 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -97,7 +97,7 @@ namespace libtorrent private: -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const { int sum = 0; diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 4f7cd5238..03841ecb5 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -298,7 +298,7 @@ namespace libtorrent bool compact_allocation() const { return m_storage_mode == storage_mode_compact; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::string name() const { return m_info->name(); } #endif @@ -333,7 +333,7 @@ namespace libtorrent int move_storage_impl(fs::path const& save_path); int allocate_slot_for_piece(int piece_index); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #ifdef TORRENT_STORAGE_DEBUG void debug_log() const; diff --git a/include/libtorrent/time.hpp b/include/libtorrent/time.hpp index ca9e2d85b..93aa17a34 100644 --- a/include/libtorrent/time.hpp +++ b/include/libtorrent/time.hpp @@ -282,7 +282,7 @@ namespace libtorrent if (performace_counter_frequency.QuadPart == 0) QueryPerformanceFrequency(&performace_counter_frequency); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // make sure we don't overflow boost::int64_t ret = (pc * 1000 / performace_counter_frequency.QuadPart) * 1000; TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 && pc < ret)); @@ -295,7 +295,7 @@ namespace libtorrent static LARGE_INTEGER performace_counter_frequency = {0,0}; if (performace_counter_frequency.QuadPart == 0) QueryPerformanceFrequency(&performace_counter_frequency); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // make sure we don't overflow boost::int64_t ret = (ms / 1000) * performace_counter_frequency.QuadPart / 1000; TORRENT_ASSERT((ms >= 0 && ms <= ret) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 18400b82d..82b57ea4e 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -149,7 +149,7 @@ namespace libtorrent , void* userdata); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool has_peer(peer_connection* p) const { return m_connections.find(p) != m_connections.end(); } #endif @@ -437,7 +437,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount(index); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -453,7 +453,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount(bits); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -468,7 +468,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount_all(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -483,7 +483,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->dec_refcount(index); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -603,7 +603,7 @@ namespace libtorrent #endif // DEBUG -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif @@ -723,11 +723,11 @@ namespace libtorrent // the object. piece_manager* m_storage; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG public: #endif std::set m_connections; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG private: #endif @@ -877,7 +877,7 @@ namespace libtorrent int m_complete; int m_incomplete; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // this is the amount downloaded when this torrent // is started. i.e. // total_done - m_initial_done <= total_payload_download diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 1e773f7ce..2b7cb8ade 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -491,7 +491,7 @@ namespace libtorrent : m_torrent(t) {} -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index 9a3b2a06b..5000af04d 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -65,7 +65,7 @@ namespace libtorrent void set_proxy_settings(proxy_settings const& ps); proxy_settings const& get_proxy_settings() { return m_proxy_settings; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ~udp_socket() { m_magic = 0; } #endif @@ -109,7 +109,7 @@ namespace libtorrent char m_tmp_buf[100]; bool m_tunnel_packets; udp::endpoint m_proxy_addr; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int m_magic; #endif }; diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index f0368196c..5eafac985 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -180,12 +180,12 @@ private: , supports_specific_external(true) , disabled(false) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG magic = 1337; #endif } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG ~rootdevice() { TORRENT_ASSERT(magic == 1337); @@ -220,7 +220,7 @@ private: mutable boost::shared_ptr upnp_connection; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int magic; #endif void close() const diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index f8e7af99f..51e8de7b4 100644 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -128,7 +128,7 @@ namespace libtorrent void write_reject_request(peer_request const&) {} void write_allow_fast(int) {} -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/libtorrent-rasterbar.pc.in b/libtorrent-rasterbar.pc.in index 4f8b14aa8..0e828f2c9 100644 --- a/libtorrent-rasterbar.pc.in +++ b/libtorrent-rasterbar.pc.in @@ -12,5 +12,6 @@ Name: libtorrent-rasterbar Description: Bittorrent library. Version: @VERSION@ Libs: -L${libdir} -ltorrent-rasterbar -Libs.private: @LIBS@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @SSL_LIBS@ @BOOST_SYSTEM_LIB@ -Cflags: -I${includedir} -I${includedir}/libtorrent @COMPILETIME_OPTIONS@ @CPPFLAGS@ +Libs.private: @LIBS@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @SSL_LIBS@ @BOOST_SYSTEM_LIB@ @SSL_LDFLAGS@ +Cflags: -I${includedir} -I${includedir}/libtorrent @COMPILETIME_OPTIONS@ @CPPFLAGS@ @SSL_CXXFLAGS@ + diff --git a/src/assert.cpp b/src/assert.cpp index 2595b6114..aa048e444 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -60,7 +60,7 @@ std::string demangle(char const* name) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #include #include diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index e1e9cb21b..25d02392e 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -107,7 +107,7 @@ namespace libtorrent , m_sync_bytes_read(0) , m_enc_send_buffer(0, 0) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_sent_bitfield(false) , m_in_constructor(true) , m_sent_handshake(false) @@ -117,7 +117,7 @@ namespace libtorrent (*m_logger) << "*** bt_peer_connection\n"; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_in_constructor = false; #endif } @@ -140,7 +140,7 @@ namespace libtorrent , m_sync_bytes_read(0) , m_enc_send_buffer(0, 0) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_sent_bitfield(false) , m_in_constructor(true) , m_sent_handshake(false) @@ -164,7 +164,7 @@ namespace libtorrent m_bandwidth_limit[upload_channel].assign(80); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_in_constructor = false; #endif } @@ -278,7 +278,7 @@ namespace libtorrent { INVARIANT_CHECK; TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_sent_bitfield = true; #endif #ifdef TORRENT_VERBOSE_LOGGING @@ -293,7 +293,7 @@ namespace libtorrent { INVARIANT_CHECK; TORRENT_ASSERT(m_sent_handshake && !m_sent_bitfield); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_sent_bitfield = true; #endif #ifdef TORRENT_VERBOSE_LOGGING @@ -695,7 +695,7 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASSERT(!m_sent_handshake); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_sent_handshake = true; #endif @@ -1373,13 +1373,13 @@ namespace libtorrent TORRENT_ASSERT(m_message_handler[packet_type] != 0); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_type cur_payload_dl = m_statistics.last_payload_downloaded(); size_type cur_protocol_dl = m_statistics.last_protocol_downloaded(); #endif // call the correct handler for this packet type (this->*m_message_handler[packet_type])(received); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0); TORRENT_ASSERT(m_statistics.last_protocol_downloaded() - cur_protocol_dl >= 0); size_type stats_diff = m_statistics.last_payload_downloaded() - cur_payload_dl + @@ -1470,7 +1470,7 @@ namespace libtorrent #ifdef TORRENT_VERBOSE_LOGGING (*m_logger) << time_now_string() << " *** NOT SENDING BITFIELD\n"; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_sent_bitfield = true; #endif return; @@ -1539,7 +1539,7 @@ namespace libtorrent bitfield_string << "\n"; (*m_logger) << bitfield_string.str(); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_sent_bitfield = true; #endif @@ -2645,7 +2645,7 @@ namespace libtorrent disconnect("torrent removed", 1); return; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_type cur_payload_dl = m_statistics.last_payload_downloaded(); size_type cur_protocol_dl = m_statistics.last_protocol_downloaded(); #endif @@ -2654,7 +2654,7 @@ namespace libtorrent m_state = read_packet_size; reset_recv_buffer(5); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0); TORRENT_ASSERT(m_statistics.last_protocol_downloaded() - cur_protocol_dl >= 0); size_type stats_diff = m_statistics.last_payload_downloaded() - cur_payload_dl + @@ -2717,7 +2717,7 @@ namespace libtorrent m_statistics.sent_bytes(amount_payload, bytes_transferred - amount_payload); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void bt_peer_connection::check_invariant() const { #ifndef TORRENT_DISABLE_ENCRYPTION diff --git a/src/connection_queue.cpp b/src/connection_queue.cpp index 715064b17..02f813cf8 100644 --- a/src/connection_queue.cpp +++ b/src/connection_queue.cpp @@ -44,7 +44,7 @@ namespace libtorrent , m_half_open_limit(0) , m_abort(false) , m_timer(ios) -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_in_timeout_function(false) #endif { @@ -141,7 +141,7 @@ namespace libtorrent int connection_queue::limit() const { return m_half_open_limit; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void connection_queue::check_invariant() const { @@ -213,7 +213,7 @@ namespace libtorrent } } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG struct function_guard { function_guard(bool& v): val(v) { TORRENT_ASSERT(!val); val = true; } @@ -228,7 +228,7 @@ namespace libtorrent mutex_t::scoped_lock l(m_mutex); INVARIANT_CHECK; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG function_guard guard_(m_in_timeout_function); #endif diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 357b506b0..fde7ac9bc 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -362,7 +362,7 @@ namespace libtorrent } TORRENT_ASSERT(buffer_size == 0); // std::cerr << " flushing p: " << p.piece << " cached_blocks: " << m_cache_stats.cache_size << std::endl; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (int i = 0; i < blocks_in_piece; ++i) TORRENT_ASSERT(p.blocks[i] == 0); #endif @@ -504,7 +504,7 @@ namespace libtorrent return ret; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void disk_io_thread::check_invariant() const { int cached_write_blocks = 0; @@ -693,7 +693,7 @@ namespace libtorrent m_signal.notify_all(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool disk_io_thread::is_disk_buffer(char* buffer) const { #ifdef TORRENT_DISABLE_POOL_ALLOCATOR @@ -741,7 +741,7 @@ namespace libtorrent j.error = ec; j.error_file = j.storage->error_file(); j.storage->clear_error(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::cout << "ERROR: '" << j.str << "' " << j.error_file << std::endl; #endif return true; diff --git a/src/entry.cpp b/src/entry.cpp index 59e5b061d..f6c9a8137 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -148,7 +148,7 @@ namespace libtorrent entry::entry() : m_type(undefined_t) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -157,7 +157,7 @@ namespace libtorrent : m_type(undefined_t) { construct(t); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -166,7 +166,7 @@ namespace libtorrent : m_type(undefined_t) { copy(e); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = e.m_type_queried; #endif } @@ -174,7 +174,7 @@ namespace libtorrent entry::entry(dictionary_type const& v) : m_type(undefined_t) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif new(data) dictionary_type(v); @@ -184,7 +184,7 @@ namespace libtorrent entry::entry(string_type const& v) : m_type(undefined_t) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif new(data) string_type(v); @@ -194,7 +194,7 @@ namespace libtorrent entry::entry(list_type const& v) : m_type(undefined_t) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif new(data) list_type(v); @@ -204,7 +204,7 @@ namespace libtorrent entry::entry(integer_type const& v) : m_type(undefined_t) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif new(data) integer_type(v); @@ -216,7 +216,7 @@ namespace libtorrent destruct(); new(data) dictionary_type(v); m_type = dictionary_t; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -226,7 +226,7 @@ namespace libtorrent destruct(); new(data) string_type(v); m_type = string_t; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -236,7 +236,7 @@ namespace libtorrent destruct(); new(data) list_type(v); m_type = list_t; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -246,7 +246,7 @@ namespace libtorrent destruct(); new(data) integer_type(v); m_type = int_t; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -291,7 +291,7 @@ namespace libtorrent TORRENT_ASSERT(t == undefined_t); } m_type = t; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -316,7 +316,7 @@ namespace libtorrent TORRENT_ASSERT(e.type() == undefined_t); } m_type = e.type(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = true; #endif } @@ -342,7 +342,7 @@ namespace libtorrent break; } m_type = undefined_t; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_type_queried = false; #endif } diff --git a/src/file.cpp b/src/file.cpp index 23147edf1..93051c25c 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -110,7 +110,7 @@ namespace libtorrent #else : m_fd(-1) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_open_mode(0) #endif {} @@ -121,7 +121,7 @@ namespace libtorrent #else : m_fd(-1) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_open_mode(0) #endif { @@ -182,7 +182,7 @@ namespace libtorrent return false; } #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_open_mode = mode; #endif TORRENT_ASSERT(is_open()); @@ -209,7 +209,7 @@ namespace libtorrent ::close(m_fd); m_fd = -1; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_open_mode = 0; #endif } diff --git a/src/kademlia/closest_nodes.cpp b/src/kademlia/closest_nodes.cpp index 40b243020..42e5dd484 100644 --- a/src/kademlia/closest_nodes.cpp +++ b/src/kademlia/closest_nodes.cpp @@ -88,7 +88,7 @@ void closest_nodes::invoke(node_id const& id, udp::endpoint addr) { TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(closest_nodes_observer)); observer_ptr o(new (m_node.m_rpc.allocator().malloc()) closest_nodes_observer(this, id, m_target)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_node.m_rpc.invoke(messages::find_node, addr, o); diff --git a/src/kademlia/find_data.cpp b/src/kademlia/find_data.cpp index 3f634a1d4..fe2e7e5bc 100644 --- a/src/kademlia/find_data.cpp +++ b/src/kademlia/find_data.cpp @@ -101,7 +101,7 @@ void find_data::invoke(node_id const& id, udp::endpoint addr) TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(find_data_observer)); observer_ptr o(new (m_node.m_rpc.allocator().malloc()) find_data_observer(this, id, m_target)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_node.m_rpc.invoke(messages::get_peers, addr, o); diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index e10e4f0d7..a9a705252 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -273,7 +273,7 @@ namespace TORRENT_LOG(node) << " distance: " << (160 - distance_exp(ih, i->id)); #endif observer_ptr o(new (rpc.allocator().malloc()) get_peers_observer(ih, listen_port, rpc, f)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif rpc.invoke(messages::get_peers, udp::endpoint(i->addr, i->port), o); @@ -295,7 +295,7 @@ void node_impl::add_node(udp::endpoint node) // ping the node, and if we get a reply, it // will be added to the routing table observer_ptr o(new (m_rpc.allocator().malloc()) null_observer(m_rpc.allocator())); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_rpc.invoke(messages::ping, node, o); diff --git a/src/kademlia/refresh.cpp b/src/kademlia/refresh.cpp index 5d9070392..4b7af3164 100644 --- a/src/kademlia/refresh.cpp +++ b/src/kademlia/refresh.cpp @@ -105,7 +105,7 @@ void refresh::invoke(node_id const& nid, udp::endpoint addr) TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(refresh_observer)); observer_ptr o(new (m_node.m_rpc.allocator().malloc()) refresh_observer( this, nid, m_target)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif @@ -161,7 +161,7 @@ void refresh::invoke_pings_or_finish(bool prevent_request) TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(ping_observer)); observer_ptr o(new (m_node.m_rpc.allocator().malloc()) ping_observer( this, node.id)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_node.m_rpc.invoke(messages::ping, node.addr, o); diff --git a/src/kademlia/rpc_manager.cpp b/src/kademlia/rpc_manager.cpp index e64cadc0c..4dcdb8793 100644 --- a/src/kademlia/rpc_manager.cpp +++ b/src/kademlia/rpc_manager.cpp @@ -136,7 +136,7 @@ rpc_manager::~rpc_manager() } } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_t rpc_manager::allocation_size() const { size_t s = sizeof(mpl::deref::type); @@ -410,7 +410,7 @@ void rpc_manager::invoke(int message_id, udp::endpoint target_addr m.id = m_our_id; m.addr = target_addr; TORRENT_ASSERT(!m_transactions[m_next_transaction_id]); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int potential_new_id = m_next_transaction_id; #endif try diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 451b8074d..9cd69c6ca 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -69,7 +69,7 @@ namespace libtorrent , tcp::endpoint const& endp , policy::peer* peerinfo) : -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_last_choke(time_now() - hours(1)) , #endif @@ -131,7 +131,7 @@ namespace libtorrent , m_snubbed(false) , m_bitfield_received(false) , m_no_download(false) -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_in_constructor(true) , m_disconnect_started(false) , m_initialized(false) @@ -161,7 +161,7 @@ namespace libtorrent + boost::lexical_cast(m_remote.port()), m_ses.listen_port()); (*m_logger) << "*** OUTGOING CONNECTION\n"; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG piece_failed = false; #endif #ifndef TORRENT_DISABLE_GEO_IP @@ -178,7 +178,7 @@ namespace libtorrent , tcp::endpoint const& endp , policy::peer* peerinfo) : -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_last_choke(time_now() - hours(1)) , #endif @@ -239,7 +239,7 @@ namespace libtorrent , m_snubbed(false) , m_bitfield_received(false) , m_no_download(false) -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_in_constructor(true) , m_disconnect_started(false) , m_initialized(false) @@ -274,7 +274,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_GEO_IP m_inet_as_name = m_ses.as_name_for_ip(m_remote.address()); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG piece_failed = false; #endif std::fill(m_peer_id.begin(), m_peer_id.end(), 0); @@ -515,7 +515,7 @@ namespace libtorrent m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all); if (m_have_all) m_num_pieces = t->torrent_file().num_pieces(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_initialized = true; #endif // now that we have a piece_picker, @@ -579,7 +579,7 @@ namespace libtorrent } #endif TORRENT_ASSERT(!m_ses.has_peer(this)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin() , end(m_ses.m_torrents.end()); i != end; ++i) TORRENT_ASSERT(!i->second->has_peer(this)); @@ -681,7 +681,7 @@ namespace libtorrent << " ==> HAVE [ piece: " << index << "]\n"; #endif write_have(index); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG boost::shared_ptr t = m_torrent.lock(); TORRENT_ASSERT(t); TORRENT_ASSERT(t->have_piece(index)); @@ -1548,7 +1548,7 @@ namespace libtorrent m_last_piece = time_now(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG struct check_postcondition { check_postcondition(boost::shared_ptr const& t_ @@ -1629,7 +1629,7 @@ namespace libtorrent #endif if (is_disconnecting()) return; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG check_postcondition post_checker_(t); #if !defined TORRENT_DISABLE_INVARIANT_CHECKS && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS t->check_invariant(); @@ -1710,7 +1710,7 @@ namespace libtorrent send_block_requests(); return; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG pending_block pending_b = *b; #endif @@ -1808,7 +1808,7 @@ namespace libtorrent TORRENT_ASSERT(picker.num_peers(block_finished) == 0); -#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS \ +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS \ && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS t->check_invariant(); #endif @@ -1870,7 +1870,7 @@ namespace libtorrent // did we just finish the piece? if (picker.is_piece_finished(p.piece)) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG check_postcondition post_checker2_(t, false); #endif t->async_verify_piece(p.piece, bind(&torrent::piece_finished, t @@ -2235,7 +2235,7 @@ namespace libtorrent #ifdef TORRENT_VERBOSE_LOGGING (*m_logger) << time_now_string() << " ==> CHOKE\n"; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_last_choke = time_now(); #endif m_num_invalid_requests = 0; @@ -2448,7 +2448,7 @@ namespace libtorrent { session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_disconnect_started = true; #endif @@ -2523,7 +2523,7 @@ namespace libtorrent m_torrent.reset(); } -#if !defined NDEBUG && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS +#if defined TORRENT_DEBUG && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS // since this connection doesn't have a torrent reference // no torrent should have a reference to this connection either for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin() @@ -2748,7 +2748,7 @@ namespace libtorrent m_recv_pos -= size; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::fill(m_recv_buffer.begin() + m_recv_pos, m_recv_buffer.end(), 0); #endif @@ -3537,12 +3537,12 @@ namespace libtorrent TORRENT_ASSERT(m_recv_pos <= int(m_recv_buffer.size() + m_disk_recv_buffer_size)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_type cur_payload_dl = m_statistics.last_payload_downloaded(); size_type cur_protocol_dl = m_statistics.last_protocol_downloaded(); #endif on_receive(error, bytes_transferred); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(m_statistics.last_payload_downloaded() - cur_payload_dl >= 0); TORRENT_ASSERT(m_statistics.last_protocol_downloaded() - cur_protocol_dl >= 0); size_type stats_diff = m_statistics.last_payload_downloaded() - cur_payload_dl + @@ -3639,7 +3639,7 @@ namespace libtorrent void peer_connection::connect(int ticket) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // in case we disconnect here, we need to // keep the connection alive until the // exit invariant check is run @@ -3822,12 +3822,12 @@ namespace libtorrent m_last_sent = time_now(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_type cur_payload_ul = m_statistics.last_payload_uploaded(); size_type cur_protocol_ul = m_statistics.last_protocol_uploaded(); #endif on_sent(error, bytes_transferred); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(m_statistics.last_payload_uploaded() - cur_payload_ul >= 0); TORRENT_ASSERT(m_statistics.last_protocol_uploaded() - cur_protocol_ul >= 0); size_type stats_diff = m_statistics.last_payload_uploaded() - cur_payload_ul @@ -3840,7 +3840,7 @@ namespace libtorrent setup_send(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void peer_connection::check_invariant() const { TORRENT_ASSERT(bool(m_disk_recv_buffer) == (m_disk_recv_buffer_size > 0)); diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 6321413ad..ab30440b0 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/bitfield.hpp" -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #include "libtorrent/peer_connection.hpp" #include "libtorrent/torrent.hpp" #endif @@ -70,7 +70,7 @@ namespace libtorrent #ifdef TORRENT_PICKER_LOG std::cerr << "new piece_picker" << std::endl; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG check_invariant(); #endif } @@ -195,7 +195,7 @@ namespace libtorrent m_downloads.erase(i); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void piece_picker::verify_pick(std::vector const& picked , bitfield const& bits) const @@ -226,7 +226,7 @@ namespace libtorrent } } -#if defined TORRENT_PICKER_LOG || !defined NDEBUG +#if defined TORRENT_PICKER_LOG || defined TORRENT_DEBUG void piece_picker::print_pieces() const { for (std::vector::const_iterator i = m_priority_boundries.begin() @@ -787,7 +787,7 @@ namespace libtorrent , has_index(index)); TORRENT_ASSERT(i != m_downloads.end()); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int num_blocks = blocks_in_piece(i->index); for (int k = 0; k < num_blocks; ++k) { @@ -1501,7 +1501,7 @@ namespace libtorrent if (num_blocks <= 0) return; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG verify_pick(interesting_blocks, pieces); verify_pick(backup_blocks, pieces); verify_pick(backup_blocks2, pieces); @@ -1538,7 +1538,7 @@ namespace libtorrent } } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // make sure that we at this point have added requests to all unrequested blocks // in all downloading pieces @@ -1726,7 +1726,7 @@ namespace libtorrent } } } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG verify_pick(interesting_blocks, pieces); #endif if (num_blocks <= 0) return 0; @@ -1825,7 +1825,7 @@ namespace libtorrent if (int(backup_blocks.size()) >= num_blocks) return num_blocks; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG verify_pick(backup_blocks, pieces); #endif return num_blocks; @@ -1871,7 +1871,7 @@ namespace libtorrent int max_blocks = blocks_in_piece(index); if ((int)i->finished < max_blocks) return false; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (int k = 0; k < max_blocks; ++k) { TORRENT_ASSERT(i->info[k].state == block_info::state_finished); diff --git a/src/policy.cpp b/src/policy.cpp index b43a35eb8..5e6cb3873 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/piece_picker.hpp" -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #include "libtorrent/bt_peer_connection.hpp" #endif @@ -150,7 +150,7 @@ namespace tcp::endpoint const& m_ep; }; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG struct match_peer_connection { match_peer_connection(peer_connection const& c) @@ -212,7 +212,7 @@ namespace libtorrent // the number of blocks we want, but it will try to make the picked // blocks be from whole pieces, possibly by returning more blocks // than we requested. -#ifndef NDEBUG +#ifdef TORRENT_DEBUG error_code ec; TORRENT_ASSERT(c.remote() == c.get_socket()->remote_endpoint(ec) || ec); #endif @@ -314,7 +314,7 @@ namespace libtorrent busy_pieces.begin(), busy_pieces.end() , bind(&piece_picker::num_peers, boost::cref(p), _1) < bind(&piece_picker::num_peers, boost::cref(p), _2)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG piece_picker::downloading_piece st; p.piece_info(i->piece_index, st); TORRENT_ASSERT(st.requested + st.finished + st.writing == p.blocks_in_piece(i->piece_index)); @@ -653,7 +653,7 @@ namespace libtorrent i = m_peers.insert(std::make_pair(c.remote().address(), p)); #ifndef TORRENT_DISABLE_GEO_IP int as = ses.as_for_ip(c.remote().address()); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG i->second.inet_as_num = as; #endif i->second.inet_as = ses.lookup_as(as); @@ -786,7 +786,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_GEO_IP int as = ses.as_for_ip(remote.address()); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG i->second.inet_as_num = as; #endif i->second.inet_as = ses.lookup_as(as); @@ -1053,7 +1053,7 @@ namespace libtorrent c.send_block_requests(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool policy::has_connection(const peer_connection* c) { // too expensive diff --git a/src/session.cpp b/src/session.cpp index cb8ad948b..22f8f0364 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -136,7 +136,7 @@ namespace libtorrent // turn off the filename checking in boost.filesystem TORRENT_ASSERT(listen_port_range.first > 0); TORRENT_ASSERT(listen_port_range.first < listen_port_range.second); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // this test was added after it came to my attention // that devstudios managed c++ failed to generate // correct code for boost.function @@ -180,7 +180,7 @@ namespace libtorrent #ifdef TORRENT_MEMDEBUG start_malloc_debug(); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG boost::function0 test = boost::ref(*m_impl); TORRENT_ASSERT(!test.empty()); #endif diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 5af255fed..f26fc83cd 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -510,7 +510,7 @@ namespace aux { // abort all connections while (!m_connections.empty()) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int conn = m_connections.size(); #endif (*m_connections.begin())->disconnect("stopping torrent"); @@ -911,7 +911,7 @@ namespace aux { boost::intrusive_ptr c( new bt_peer_connection(*this, s, endp, 0)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG c->m_in_constructor = false; #endif @@ -929,7 +929,7 @@ namespace aux { // too expensive // INVARIANT_CHECK; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // for (aux::session_impl::torrent_map::const_iterator i = m_torrents.begin() // , end(m_torrents.end()); i != end; ++i) // TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p)); @@ -1689,7 +1689,7 @@ namespace aux { TORRENT_ASSERT(m_abort == true); if (ec) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::cerr << ec.message() << "\n"; std::string err = ec.message(); #endif @@ -1704,7 +1704,7 @@ namespace aux { session_impl::mutex_t::scoped_lock l(m_mutex); /* -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (torrent_map::iterator i = m_torrents.begin(); i != m_torrents.end(); ++i) { @@ -1728,7 +1728,7 @@ namespace aux { { std::map >::iterator i = m_torrents.find(info_hash); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (std::map >::iterator j = m_torrents.begin(); j != m_torrents.end(); ++j) { @@ -1942,7 +1942,7 @@ namespace aux { t.delete_files(); t.abort(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG sha1_hash i_hash = t.torrent_file().info_hash(); #endif t.set_queue_position(-1); @@ -2632,7 +2632,7 @@ namespace aux { #endif } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void session_impl::check_invariant() const { int num_checking = std::count_if(m_queued_for_checking.begin() diff --git a/src/storage.cpp b/src/storage.cpp index 42a95fbd8..4203c9565 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -75,7 +75,7 @@ POSSIBILITY OF SUCH DAMAGE. //#define TORRENT_PARTIAL_HASH_LOG -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #include #include #include @@ -243,7 +243,7 @@ using boost::bind; using namespace ::boost::multi_index; using boost::multi_index::multi_index_container; -#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG) +#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG namespace { using namespace libtorrent; @@ -465,7 +465,7 @@ namespace libtorrent sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size) { TORRENT_ASSERT(!error()); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG hasher partial; hasher whole; int slot_size1 = piece_size; @@ -486,7 +486,7 @@ namespace libtorrent if (error()) return sha1_hash(0); ph.h.update(&m_scratch_buffer[0], slot_size); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG sha1_hash ret = ph.h.final(); TORRENT_ASSERT(ret == whole.final()); return ret; @@ -915,7 +915,7 @@ namespace libtorrent return false; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG /* void storage::shuffle() { @@ -1010,7 +1010,7 @@ namespace libtorrent TORRENT_ASSERT(offset < m_files.piece_size(slot)); TORRENT_ASSERT(size > 0); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::vector slices = files().map_block(slot, offset, size); TORRENT_ASSERT(!slices.empty()); @@ -1047,7 +1047,7 @@ namespace libtorrent size_type result = left_to_read; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int counter = 0; #endif @@ -1064,7 +1064,7 @@ namespace libtorrent if (read_bytes == 0) continue; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(int(slices.size()) > counter); size_type slice_size = slices[counter].size; TORRENT_ASSERT(slice_size == read_bytes); @@ -1132,7 +1132,7 @@ namespace libtorrent TORRENT_ASSERT(offset >= 0); TORRENT_ASSERT(size > 0); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::vector slices = files().map_block(slot, offset, size); TORRENT_ASSERT(!slices.empty()); @@ -1167,7 +1167,7 @@ namespace libtorrent TORRENT_ASSERT(left_to_write >= 0); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int counter = 0; #endif @@ -1184,7 +1184,7 @@ namespace libtorrent if (write_bytes == 0) continue; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(int(slices.size()) > counter); size_type slice_size = slices[counter].size; TORRENT_ASSERT(slice_size == write_bytes); @@ -1361,7 +1361,7 @@ namespace libtorrent // since that is the size of the pool allocator's buffers TORRENT_ASSERT(r.length <= 16 * 1024); m_io_thread.add_job(j, handler); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG boost::recursive_mutex::scoped_lock l(m_mutex); // if this assert is hit, it suggests // that check_files was not successful @@ -1532,7 +1532,7 @@ namespace libtorrent std::map::iterator i = m_piece_hasher.find(piece_index); if (i != m_piece_hasher.end()) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(i->second.offset > 0); int hash_offset = i->second.offset; TORRENT_ASSERT(offset >= hash_offset); @@ -2537,7 +2537,7 @@ namespace libtorrent && m_slot_to_piece[piece_index] >= 0) { -#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG) +#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG std::stringstream s; s << "there is another piece at our slot, swapping.."; @@ -2572,7 +2572,7 @@ namespace libtorrent slot_index = piece_index; -#if !defined(NDEBUG) && defined(TORRENT_STORAGE_DEBUG) +#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG debug_log(); #endif } @@ -2640,7 +2640,7 @@ namespace libtorrent return m_slot_to_piece[slot]; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void piece_manager::check_invariant() const { boost::recursive_mutex::scoped_lock lock(m_mutex); diff --git a/src/torrent.cpp b/src/torrent.cpp index 4049e8892..6510c6332 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -271,7 +271,7 @@ namespace libtorrent m_obfuscated_hash = h.final(); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_files_checked = false; #endif INVARIANT_CHECK; @@ -1235,7 +1235,7 @@ namespace libtorrent if (m_picker->have_piece(index)) continue; TORRENT_ASSERT(i->finished <= m_picker->blocks_in_piece(index)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (std::vector::const_iterator j = boost::next(i); j != dl_queue.end(); ++j) { @@ -1295,7 +1295,7 @@ namespace libtorrent { downloading_piece[block] = p->bytes_downloaded; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(p->bytes_downloaded <= p->full_block_bytes); int last_piece = m_torrent_file->num_pieces() - 1; if (p->piece_index == last_piece @@ -1317,7 +1317,7 @@ namespace libtorrent TORRENT_ASSERT(total_done <= m_torrent_file->total_size()); TORRENT_ASSERT(wanted_done <= m_torrent_file->total_size()); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG if (total_done >= m_torrent_file->total_size()) { @@ -1512,7 +1512,7 @@ namespace libtorrent std::set peers; std::copy(downloaders.begin(), downloaders.end(), std::inserter(peers, peers.begin())); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (std::vector::iterator i = downloaders.begin() , end(downloaders.end()); i != end; ++i) { @@ -1594,7 +1594,7 @@ namespace libtorrent TORRENT_ASSERT(m_picker->have_piece(index) == false); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (std::vector::iterator i = downloaders.begin() , end(downloaders.end()); i != end; ++i) { @@ -2407,7 +2407,7 @@ namespace libtorrent m_ses, shared_from_this(), s, a, url, 0)); if (!c) return; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG c->m_in_constructor = false; #endif @@ -2980,7 +2980,7 @@ namespace libtorrent TORRENT_ASSERT(peerinfo->connection == 0); peerinfo->connected = time_now(); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // this asserts that we don't have duplicates in the policy's peer list peer_iterator i_ = std::find_if(m_connections.begin(), m_connections.end() , bind(&peer_connection::remote, _1) == peerinfo->ip()); @@ -3003,7 +3003,7 @@ namespace libtorrent boost::intrusive_ptr c(new bt_peer_connection( m_ses, shared_from_this(), s, a, peerinfo)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG c->m_in_constructor = false; #endif @@ -3169,12 +3169,12 @@ namespace libtorrent #endif TORRENT_ASSERT(m_connections.find(p) == m_connections.end()); peer_iterator ci = m_connections.insert(p).first; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG error_code ec; TORRENT_ASSERT(p->remote() == p->get_socket()->remote_endpoint(ec) || ec); #endif -#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS m_policy.check_invariant(); #endif return true; @@ -3210,7 +3210,7 @@ namespace libtorrent else (*p->m_logger) << "*** CLOSING CONNECTION 'pausing'\n"; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::size_t size = m_connections.size(); #endif if (p->is_disconnecting()) @@ -3632,7 +3632,7 @@ namespace libtorrent return m_ses.settings(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void torrent::check_invariant() const { session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); @@ -4387,7 +4387,7 @@ namespace libtorrent TORRENT_ASSERT(piece_index >= 0); TORRENT_ASSERT(piece_index < m_torrent_file->num_pieces()); TORRENT_ASSERT(piece_index < (int)m_picker->num_pieces()); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG if (m_picker) { int blocks_in_piece = m_picker->blocks_in_piece(piece_index); @@ -4400,7 +4400,7 @@ namespace libtorrent m_storage->async_hash(piece_index, bind(&torrent::on_piece_verified , shared_from_this(), _1, _2, f)); -#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS +#if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS check_invariant(); #endif } @@ -4590,7 +4590,7 @@ namespace libtorrent void torrent::set_state(torrent_status::state_t s) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG if (s == torrent_status::seeding) TORRENT_ASSERT(is_seed()); if (s == torrent_status::finished) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 4f8b3d81b..26597d0f0 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -134,7 +134,7 @@ namespace libtorrent #endif } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void torrent_handle::check_invariant() const {} diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index dc1457897..37b784294 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -25,12 +25,12 @@ udp_socket::udp_socket(asio::io_service& ios, udp_socket::callback_t const& c , m_resolver(ios) , m_tunnel_packets(false) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_magic = 0x1337; #endif } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #define CHECK_MAGIC check_magic_ cm_(m_magic) struct check_magic_ { diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index ab3b0bf64..fd8a30346 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -695,7 +695,7 @@ namespace libtorrent } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void web_peer_connection::check_invariant() const { /*