diff --git a/libtorrent/include/libtorrent/assert.hpp b/libtorrent/include/libtorrent/assert.hpp index 6396526ba..71a1aa406 100644 --- a/libtorrent/include/libtorrent/assert.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/aux_/session_impl.hpp b/libtorrent/include/libtorrent/aux_/session_impl.hpp index aa5d1bae1..033522bb7 100644 --- a/libtorrent/include/libtorrent/aux_/session_impl.hpp +++ b/libtorrent/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() @@ -577,7 +577,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/libtorrent/include/libtorrent/bandwidth_manager.hpp b/libtorrent/include/libtorrent/bandwidth_manager.hpp index 20344ebc5..dc296a13a 100644 --- a/libtorrent/include/libtorrent/bandwidth_manager.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/bencode.hpp b/libtorrent/include/libtorrent/bencode.hpp index 49b59e9da..b5b330d4d 100644 --- a/libtorrent/include/libtorrent/bencode.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/bt_peer_connection.hpp b/libtorrent/include/libtorrent/bt_peer_connection.hpp index a900bfc7e..c9a1bc7e5 100644 --- a/libtorrent/include/libtorrent/bt_peer_connection.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/connection_queue.hpp b/libtorrent/include/libtorrent/connection_queue.hpp index 749d72133..c41124e64 100644 --- a/libtorrent/include/libtorrent/connection_queue.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/disk_io_thread.hpp b/libtorrent/include/libtorrent/disk_io_thread.hpp index 948db1176..0ae84898c 100644 --- a/libtorrent/include/libtorrent/disk_io_thread.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/entry.hpp b/libtorrent/include/libtorrent/entry.hpp index 473eb1ca8..a970bf81b 100644 --- a/libtorrent/include/libtorrent/entry.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/file.hpp b/libtorrent/include/libtorrent/file.hpp index c1f70b50c..568f7378c 100644 --- a/libtorrent/include/libtorrent/file.hpp +++ b/libtorrent/include/libtorrent/file.hpp @@ -124,7 +124,7 @@ namespace libtorrent #else int m_fd; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG open_mode m_open_mode; #endif diff --git a/libtorrent/include/libtorrent/invariant_check.hpp b/libtorrent/include/libtorrent/invariant_check.hpp index c687b6a63..175a9861b 100644 --- a/libtorrent/include/libtorrent/invariant_check.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/kademlia/node.hpp b/libtorrent/include/libtorrent/kademlia/node.hpp index 594a68e9f..a018ef040 100644 --- a/libtorrent/include/libtorrent/kademlia/node.hpp +++ b/libtorrent/include/libtorrent/kademlia/node.hpp @@ -139,7 +139,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/libtorrent/include/libtorrent/kademlia/observer.hpp b/libtorrent/include/libtorrent/kademlia/observer.hpp index 073f453bc..7e11a4c70 100644 --- a/libtorrent/include/libtorrent/kademlia/observer.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/kademlia/rpc_manager.hpp b/libtorrent/include/libtorrent/kademlia/rpc_manager.hpp index 837c091dd..dcfa1b6eb 100644 --- a/libtorrent/include/libtorrent/kademlia/rpc_manager.hpp +++ b/libtorrent/include/libtorrent/kademlia/rpc_manager.hpp @@ -93,7 +93,7 @@ public: void reply(msg& m); void reply_with_ping(msg& m); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_t allocation_size() const; void check_invariant() const; #endif diff --git a/libtorrent/include/libtorrent/peer_connection.hpp b/libtorrent/include/libtorrent/peer_connection.hpp index 4be5d772b..f4a86a064 100644 --- a/libtorrent/include/libtorrent/peer_connection.hpp +++ b/libtorrent/include/libtorrent/peer_connection.hpp @@ -396,7 +396,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 @@ -458,7 +458,7 @@ namespace libtorrent bool packet_finished() const { return m_packet_size <= m_recv_pos; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG bool piece_failed; #endif @@ -566,7 +566,7 @@ namespace libtorrent char m_country[2]; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG boost::intrusive_ptr self() { TORRENT_ASSERT(!m_in_constructor); @@ -870,7 +870,7 @@ namespace libtorrent // this is set to true once the bitfield is received bool m_bitfield_received:1; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG public: bool m_in_constructor:1; bool m_disconnect_started:1; diff --git a/libtorrent/include/libtorrent/piece_picker.hpp b/libtorrent/include/libtorrent/piece_picker.hpp index 2e76e8a9f..1cdc84bec 100644 --- a/libtorrent/include/libtorrent/piece_picker.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/policy.hpp b/libtorrent/include/libtorrent/policy.hpp index 500d59e4d..62d165b77 100644 --- a/libtorrent/include/libtorrent/policy.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/stat.hpp b/libtorrent/include/libtorrent/stat.hpp index abb83ebfc..d328fd0df 100644 --- a/libtorrent/include/libtorrent/stat.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/storage.hpp b/libtorrent/include/libtorrent/storage.hpp index 4f7cd5238..03841ecb5 100644 --- a/libtorrent/include/libtorrent/storage.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/time.hpp b/libtorrent/include/libtorrent/time.hpp index ca9e2d85b..93aa17a34 100644 --- a/libtorrent/include/libtorrent/time.hpp +++ b/libtorrent/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/libtorrent/include/libtorrent/torrent.hpp b/libtorrent/include/libtorrent/torrent.hpp index ea5a91fbb..ac0b03764 100644 --- a/libtorrent/include/libtorrent/torrent.hpp +++ b/libtorrent/include/libtorrent/torrent.hpp @@ -147,7 +147,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 @@ -431,7 +431,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount(index); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -447,7 +447,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount(bits); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -462,7 +462,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->inc_refcount_all(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -477,7 +477,7 @@ namespace libtorrent TORRENT_ASSERT(!is_seed()); m_picker->dec_refcount(index); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG else { TORRENT_ASSERT(is_seed()); @@ -596,7 +596,7 @@ namespace libtorrent #endif // DEBUG -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif @@ -718,11 +718,11 @@ namespace libtorrent // the time of next tracker announce ptime m_next_tracker_announce; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG public: #endif std::set m_connections; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG private: #endif @@ -872,7 +872,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/libtorrent/include/libtorrent/torrent_handle.hpp b/libtorrent/include/libtorrent/torrent_handle.hpp index 80680b357..2775e930d 100644 --- a/libtorrent/include/libtorrent/torrent_handle.hpp +++ b/libtorrent/include/libtorrent/torrent_handle.hpp @@ -487,7 +487,7 @@ namespace libtorrent : m_torrent(t) {} -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void check_invariant() const; #endif diff --git a/libtorrent/include/libtorrent/udp_socket.hpp b/libtorrent/include/libtorrent/udp_socket.hpp index d1c87e2aa..dc257f806 100644 --- a/libtorrent/include/libtorrent/udp_socket.hpp +++ b/libtorrent/include/libtorrent/udp_socket.hpp @@ -64,7 +64,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 @@ -108,7 +108,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/libtorrent/include/libtorrent/upnp.hpp b/libtorrent/include/libtorrent/upnp.hpp index 5913e70d0..59baa915b 100644 --- a/libtorrent/include/libtorrent/upnp.hpp +++ b/libtorrent/include/libtorrent/upnp.hpp @@ -176,12 +176,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); @@ -216,7 +216,7 @@ private: mutable boost::shared_ptr upnp_connection; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int magic; #endif void close() const diff --git a/libtorrent/include/libtorrent/web_peer_connection.hpp b/libtorrent/include/libtorrent/web_peer_connection.hpp index f8e7af99f..51e8de7b4 100644 --- a/libtorrent/include/libtorrent/web_peer_connection.hpp +++ b/libtorrent/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/src/assert.cpp b/libtorrent/src/assert.cpp index 2595b6114..aa048e444 100644 --- a/libtorrent/src/assert.cpp +++ b/libtorrent/src/assert.cpp @@ -60,7 +60,7 @@ std::string demangle(char const* name) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #include #include diff --git a/libtorrent/src/bt_peer_connection.cpp b/libtorrent/src/bt_peer_connection.cpp index 5a21cd250..418240ce2 100755 --- a/libtorrent/src/bt_peer_connection.cpp +++ b/libtorrent/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 @@ -1452,7 +1452,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; @@ -1521,7 +1521,7 @@ namespace libtorrent bitfield_string << "\n"; (*m_logger) << bitfield_string.str(); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_sent_bitfield = true; #endif @@ -2632,7 +2632,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/libtorrent/src/connection_queue.cpp b/libtorrent/src/connection_queue.cpp index 560f31e59..d7f730746 100644 --- a/libtorrent/src/connection_queue.cpp +++ b/libtorrent/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/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp index dded34e79..cab82f305 100644 --- a/libtorrent/src/disk_io_thread.cpp +++ b/libtorrent/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 @@ -740,7 +740,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; @@ -857,7 +857,7 @@ namespace libtorrent if (test_error(j)) { ret = -1; - return; + break; } #ifdef TORRENT_DISK_STATS m_log << log_time() << " read " << j.buffer_size << std::endl; diff --git a/libtorrent/src/entry.cpp b/libtorrent/src/entry.cpp index 59e5b061d..f6c9a8137 100755 --- a/libtorrent/src/entry.cpp +++ b/libtorrent/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/libtorrent/src/file.cpp b/libtorrent/src/file.cpp index ebcc2cf97..7aa594987 100755 --- a/libtorrent/src/file.cpp +++ b/libtorrent/src/file.cpp @@ -142,7 +142,7 @@ namespace libtorrent #else : m_fd(-1) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_open_mode(0) #endif {} @@ -153,7 +153,7 @@ namespace libtorrent #else : m_fd(-1) #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_open_mode(0) #endif { @@ -214,7 +214,7 @@ namespace libtorrent return false; } #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_open_mode = mode; #endif TORRENT_ASSERT(is_open()); @@ -241,7 +241,7 @@ namespace libtorrent ::close(m_fd); m_fd = -1; #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_open_mode = 0; #endif } diff --git a/libtorrent/src/identify_client.cpp b/libtorrent/src/identify_client.cpp index 0e7cbb138..9eb0fd3c9 100755 --- a/libtorrent/src/identify_client.cpp +++ b/libtorrent/src/identify_client.cpp @@ -271,7 +271,7 @@ namespace std::lower_bound(name_map, name_map + size , tmp, &compare_id); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG for (int i = 1; i < size; ++i) { TORRENT_ASSERT(compare_id(name_map[i-1] diff --git a/libtorrent/src/kademlia/closest_nodes.cpp b/libtorrent/src/kademlia/closest_nodes.cpp index 859170f7f..e9039642f 100644 --- a/libtorrent/src/kademlia/closest_nodes.cpp +++ b/libtorrent/src/kademlia/closest_nodes.cpp @@ -100,7 +100,7 @@ void closest_nodes::invoke(node_id const& id, udp::endpoint addr) { TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(closest_nodes_observer)); observer_ptr o(new (m_rpc.allocator().malloc()) closest_nodes_observer(this, id, m_target)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_rpc.invoke(messages::find_node, addr, o); diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp index 71750d700..0cd2a9220 100644 --- a/libtorrent/src/kademlia/dht_tracker.cpp +++ b/libtorrent/src/kademlia/dht_tracker.cpp @@ -239,7 +239,7 @@ namespace libtorrent { namespace dht } catch (std::exception& exc) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG std::cerr << "exception-type: " << typeid(exc).name() << std::endl; std::cerr << "what: " << exc.what() << std::endl; TORRENT_ASSERT(false); diff --git a/libtorrent/src/kademlia/find_data.cpp b/libtorrent/src/kademlia/find_data.cpp index 5d5b79724..c33842a50 100644 --- a/libtorrent/src/kademlia/find_data.cpp +++ b/libtorrent/src/kademlia/find_data.cpp @@ -112,7 +112,7 @@ void find_data::invoke(node_id const& id, udp::endpoint addr) TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(find_data_observer)); observer_ptr o(new (m_rpc.allocator().malloc()) find_data_observer(this, id, m_target)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_rpc.invoke(messages::get_peers, addr, o); diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index 42db5a950..223cc3ce0 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -281,7 +281,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, i->addr, o); @@ -303,7 +303,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/libtorrent/src/kademlia/refresh.cpp b/libtorrent/src/kademlia/refresh.cpp index 1c5978893..39b4272e0 100644 --- a/libtorrent/src/kademlia/refresh.cpp +++ b/libtorrent/src/kademlia/refresh.cpp @@ -104,7 +104,7 @@ void refresh::invoke(node_id const& nid, udp::endpoint addr) TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(refresh_observer)); observer_ptr o(new (m_rpc.allocator().malloc()) refresh_observer( this, nid, m_target)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif @@ -159,7 +159,7 @@ void refresh::invoke_pings_or_finish(bool prevent_request) TORRENT_ASSERT(m_rpc.allocation_size() >= sizeof(ping_observer)); observer_ptr o(new (m_rpc.allocator().malloc()) ping_observer( this, node.id)); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif m_rpc.invoke(messages::ping, node.addr, o); diff --git a/libtorrent/src/kademlia/rpc_manager.cpp b/libtorrent/src/kademlia/rpc_manager.cpp index c57059984..6aa410061 100644 --- a/libtorrent/src/kademlia/rpc_manager.cpp +++ b/libtorrent/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); @@ -423,7 +423,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 @@ -481,7 +481,7 @@ void rpc_manager::reply_with_ping(msg& m) TORRENT_ASSERT(allocation_size() >= sizeof(null_observer)); observer_ptr o(new (allocator().malloc()) null_observer(allocator())); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG o->m_in_constructor = false; #endif TORRENT_ASSERT(!m_transactions[m_next_transaction_id]); diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index a2848281d..81a8afd5f 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/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 @@ -130,7 +130,7 @@ namespace libtorrent , m_upload_only(false) , m_snubbed(false) , m_bitfield_received(false) -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_in_constructor(true) , m_disconnect_started(false) , m_initialized(false) @@ -160,7 +160,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 @@ -177,7 +177,7 @@ namespace libtorrent , tcp::endpoint const& endp , policy::peer* peerinfo) : -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_last_choke(time_now() - hours(1)) , #endif @@ -237,7 +237,7 @@ namespace libtorrent , m_upload_only(false) , m_snubbed(false) , m_bitfield_received(false) -#ifndef NDEBUG +#ifdef TORRENT_DEBUG , m_in_constructor(true) , m_disconnect_started(false) , m_initialized(false) @@ -272,7 +272,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); @@ -518,7 +518,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, @@ -582,7 +582,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)); @@ -684,7 +684,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)); @@ -862,12 +862,12 @@ namespace libtorrent TORRENT_ASSERT(m_torrent.expired()); // check to make sure we don't have another connection with the same // info_hash and peer_id. If we do. close this connection. -#ifndef NDEBUG +#ifdef TORRENT_DEBUG try { #endif t->attach_peer(this); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG } catch (std::exception& e) { @@ -1563,7 +1563,7 @@ namespace libtorrent m_last_piece = time_now(); } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG struct check_postcondition { check_postcondition(boost::shared_ptr const& t_ @@ -1644,7 +1644,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(); @@ -1723,7 +1723,7 @@ namespace libtorrent send_block_requests(); return; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG pending_block pending_b = *b; #endif @@ -1821,7 +1821,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 @@ -1883,7 +1883,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 @@ -2248,7 +2248,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; @@ -2461,7 +2461,7 @@ namespace libtorrent { session_impl::mutex_t::scoped_lock l(m_ses.m_mutex); -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_disconnect_started = true; #endif @@ -2537,7 +2537,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() @@ -2761,7 +2761,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 @@ -3632,7 +3632,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 @@ -3816,7 +3816,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/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index 6321413ad..ab30440b0 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/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/libtorrent/src/policy.cpp b/libtorrent/src/policy.cpp index 2c67d9f8a..2f2987278 100755 --- a/libtorrent/src/policy.cpp +++ b/libtorrent/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) @@ -211,7 +211,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 @@ -313,7 +313,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)); @@ -652,7 +652,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); @@ -785,7 +785,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); @@ -1052,7 +1052,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/libtorrent/src/session.cpp b/libtorrent/src/session.cpp index 3451ba353..e6f2f186d 100755 --- a/libtorrent/src/session.cpp +++ b/libtorrent/src/session.cpp @@ -132,7 +132,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 @@ -173,7 +173,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/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index 412330db0..edccf8831 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -506,7 +506,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"); @@ -907,7 +907,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 @@ -925,7 +925,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)); @@ -1621,7 +1621,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 @@ -1636,7 +1636,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) { @@ -1660,7 +1660,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) { @@ -1851,7 +1851,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); @@ -2503,7 +2503,7 @@ namespace aux { #endif } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void session_impl::check_invariant() const { std::set unique; diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index 91fd47f21..933395526 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -75,7 +75,7 @@ POSSIBILITY OF SUCH DAMAGE. //#define TORRENT_PARTIAL_HASH_LOG -#ifndef NDEBUG +#ifdef TORRENT_DEBUG #include #include #include @@ -242,7 +242,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; @@ -463,7 +463,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; @@ -484,7 +484,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; @@ -904,7 +904,7 @@ namespace libtorrent return false; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG /* void storage::shuffle() { @@ -999,7 +999,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()); @@ -1046,7 +1046,7 @@ namespace libtorrent return size; } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG size_type in_tell = in->tell(ec); TORRENT_ASSERT(in_tell == file_offset + file_iter->file_base && !ec); #endif @@ -1061,7 +1061,7 @@ namespace libtorrent size_type result = left_to_read; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int counter = 0; #endif @@ -1073,7 +1073,7 @@ namespace libtorrent if (read_bytes > 0) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG TORRENT_ASSERT(int(slices.size()) > counter); size_type slice_size = slices[counter].size; TORRENT_ASSERT(slice_size == read_bytes); @@ -1105,7 +1105,7 @@ namespace libtorrent if (left_to_read > 0) { ++file_iter; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG // empty files are not returned by map_block, so if // this file was empty, don't increment the slice counter if (read_bytes > 0) ++counter; @@ -1148,7 +1148,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()); @@ -1200,7 +1200,7 @@ namespace libtorrent TORRENT_ASSERT(left_to_write >= 0); int buf_pos = 0; -#ifndef NDEBUG +#ifdef TORRENT_DEBUG int counter = 0; #endif while (left_to_write > 0) @@ -1239,7 +1239,7 @@ namespace libtorrent if (left_to_write > 0) { -#ifndef NDEBUG +#ifdef TORRENT_DEBUG if (write_bytes > 0) ++counter; #endif ++file_iter; @@ -1403,7 +1403,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 @@ -1574,7 +1574,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); @@ -2579,7 +2579,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.."; @@ -2614,7 +2614,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 } @@ -2682,7 +2682,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/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index bc0dbcf68..311cd20d8 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -295,7 +295,7 @@ namespace libtorrent m_obfuscated_hash = h.final(); #endif -#ifndef NDEBUG +#ifdef TORRENT_DEBUG m_files_checked = false; #endif INVARIANT_CHECK; @@ -1184,7 +1184,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) { @@ -1244,7 +1244,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 @@ -1266,7 +1266,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()) { @@ -1461,7 +1461,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) { @@ -1543,7 +1543,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) { @@ -2334,7 +2334,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 @@ -2907,7 +2907,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()); @@ -2930,7 +2930,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 @@ -3070,12 +3070,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; @@ -3110,7 +3110,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()) @@ -3545,7 +3545,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); @@ -4237,7 +4237,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); @@ -4250,7 +4250,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 } @@ -4431,7 +4431,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/libtorrent/src/torrent_handle.cpp b/libtorrent/src/torrent_handle.cpp index c484c9254..e573dc506 100755 --- a/libtorrent/src/torrent_handle.cpp +++ b/libtorrent/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/libtorrent/src/udp_socket.cpp b/libtorrent/src/udp_socket.cpp index 622cce7e6..e66adf1b5 100644 --- a/libtorrent/src/udp_socket.cpp +++ b/libtorrent/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/libtorrent/src/web_peer_connection.cpp b/libtorrent/src/web_peer_connection.cpp index ab3b0bf64..fd8a30346 100755 --- a/libtorrent/src/web_peer_connection.cpp +++ b/libtorrent/src/web_peer_connection.cpp @@ -695,7 +695,7 @@ namespace libtorrent } -#ifndef NDEBUG +#ifdef TORRENT_DEBUG void web_peer_connection::check_invariant() const { /*