From 795bee4b2c28d9313d1aad7745201b0e2b6a9a73 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 13 Jan 2008 06:17:56 +0000 Subject: [PATCH] added option to disable invariant checks and added more build documentation --- Jamfile | 3 +++ docs/building.html | 28 ++++++++++++++++++++++++++ docs/building.rst | 20 ++++++++++++++++++ include/libtorrent/invariant_check.hpp | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Jamfile b/Jamfile index 6eb581236..3b095f720 100755 --- a/Jamfile +++ b/Jamfile @@ -152,6 +152,9 @@ rule building ( properties * ) feature bandwidth-limit-logging : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_VERBOSE_BANDWIDTH_LIMIT ; +feature invariant-checks : on off : composite propagated link-incompatible ; +feature.compose off : TORRENT_DISABLE_INVARIANT_CHECKS ; + feature disk-stats : off on : composite propagated link-incompatible ; feature.compose on : TORRENT_DISK_STATS ; diff --git a/docs/building.html b/docs/building.html index f5d985238..957139ca7 100644 --- a/docs/building.html +++ b/docs/building.html @@ -291,6 +291,26 @@ API is used. +invariant-checks +

This setting only affects debug builds (where +NDEBUG is not defined). It defaults to on.

+
    +
  • on - internal invariant checks are enabled.
  • +
  • off - internal invariant checks are +disabled. The resulting executable will run +faster than a regular debug build.
  • +
+ + +debug-symbols +
    +
  • on - default for debug builds. This setting +is useful for building release builds with +symbols.
  • +
  • off - default for release builds.
  • +
+ +

The variant feature is implicit, which means you don't need to specify @@ -558,6 +578,14 @@ non-ansi characters. Defining this will disable the ability to resolve countries of origin for peer IPs. +TORRENT_DISABLE_INVARIANT_CHECKS +This will disable internal invariant checks in +libtorrent. The invariant checks can sometime +be quite expensive, they typically don't scale +very well. This option can be used to still +build in debug mode, with asserts enabled, but +make the resulting executable faster. +

If you experience that libtorrent uses unreasonable amounts of cpu, it will diff --git a/docs/building.rst b/docs/building.rst index 7a9537039..cf782373f 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -262,6 +262,19 @@ Build features: | | * ``unicode`` - The unicode version of the win32 | | | API is used. | +------------------------+----------------------------------------------------+ +| ``invariant-checks`` | This setting only affects debug builds (where | +| | ``NDEBUG`` is not defined). It defaults to ``on``. | +| | | +| | * ``on`` - internal invariant checks are enabled. | +| | * ``off`` - internal invariant checks are | +| | disabled. The resulting executable will run | +| | faster than a regular debug build. | ++------------------------+----------------------------------------------------+ +| ``debug-symbols`` | * ``on`` - default for debug builds. This setting | +| | is useful for building release builds with | +| | symbols. | +| | * ``off`` - default for release builds. | ++------------------------+----------------------------------------------------+ The ``variant`` feature is *implicit*, which means you don't need to specify the name of the feature, just the value. @@ -527,6 +540,13 @@ defines you can use to control the build. | ``TORRENT_DISABLE_RESOLVE_COUNTRIES`` | Defining this will disable the ability to | | | resolve countries of origin for peer IPs. | +---------------------------------------+-------------------------------------------------+ +| ``TORRENT_DISABLE_INVARIANT_CHECKS`` | This will disable internal invariant checks in | +| | libtorrent. The invariant checks can sometime | +| | be quite expensive, they typically don't scale | +| | very well. This option can be used to still | +| | build in debug mode, with asserts enabled, but | +| | make the resulting executable faster. | ++---------------------------------------+-------------------------------------------------+ If you experience that libtorrent uses unreasonable amounts of cpu, it will diff --git a/include/libtorrent/invariant_check.hpp b/include/libtorrent/invariant_check.hpp index 3075b8975..c687b6a63 100755 --- a/include/libtorrent/invariant_check.hpp +++ b/include/libtorrent/invariant_check.hpp @@ -66,7 +66,7 @@ namespace libtorrent } } -#ifndef NDEBUG +#if !defined NDEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS #define INVARIANT_CHECK \ invariant_checker const& _invariant_check = make_invariant_checker(*this); \ (void)_invariant_check; \