diff --git a/Jamfile b/Jamfile index df5adec81..b084d2450 100755 --- a/Jamfile +++ b/Jamfile @@ -212,11 +212,13 @@ rule tag ( name : type ? : property-set ) feature tcmalloc : no yes : composite propagated link-incompatible ; -feature timer : auto boost absolute performance clock : composite propagated link-incompatible ; +feature timer : auto boost absolute performance clock system_time + : composite propagated link-incompatible ; feature.compose boost : TORRENT_USE_BOOST_DATE_TIME=1 ; feature.compose absolute : TORRENT_USE_ABSOLUTE_TIME=1 ; feature.compose performance : TORRENT_USE_PERFORMANCE_TIMER=1 ; feature.compose clock : TORRENT_USE_CLOCK_GETTIME=1 ; +feature.compose system_time : TORRENT_USE_SYSTEM_TIME=1 ; feature ipv6 : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_USE_IPV6=0 ; diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 52a3b649a..ddc19ddc3 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -429,7 +429,6 @@ namespace libtorrent const static int static_category = alert::peer_notification; virtual std::string message() const { - error_code ec; return peer_alert::message() + " peer error: " + error.message(); } diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index f1388b546..a80a0b09a 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -55,17 +55,15 @@ POSSIBILITY OF SUCH DAMAGE. #if defined __GNUC__ -# define TORRENT_DEPRECATED __attribute__ ((deprecated)) +# if __GNUC__ >= 3 +# define TORRENT_DEPRECATED __attribute__ ((deprecated)) +# endif // GCC pre 4.0 did not have support for the visibility attribute # if __GNUC__ >= 4 # if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED) # define TORRENT_EXPORT __attribute__ ((visibility("default"))) -# else -# define TORRENT_EXPORT # endif -# else -# define TORRENT_EXPORT # endif @@ -76,11 +74,7 @@ POSSIBILITY OF SUCH DAMAGE. # if __SUNPRO_CC >= 0x550 # if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED) # define TORRENT_EXPORT __global -# else -# define TORRENT_EXPORT # endif -# else -# define TORRENT_EXPORT # endif @@ -95,29 +89,15 @@ POSSIBILITY OF SUCH DAMAGE. # define TORRENT_EXPORT __declspec(dllexport) # elif defined(TORRENT_LINKING_SHARED) # define TORRENT_EXPORT __declspec(dllimport) -# else -# define TORRENT_EXPORT # endif #define TORRENT_DEPRECATED_PREFIX __declspec(deprecated) - - -// ======= GENERIC COMPILER ========= - -#else -# define TORRENT_EXPORT #endif +// ======= PLATFORMS ========= -#ifndef TORRENT_DEPRECATED_PREFIX -#define TORRENT_DEPRECATED_PREFIX -#endif - -#ifndef TORRENT_DEPRECATED -#define TORRENT_DEPRECATED -#endif // set up defines for target environments #if (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \ @@ -132,11 +112,27 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_WINDOWS #elif defined sun || defined __sun #define TORRENT_SOLARIS +#elif defined __BEOS__ || defined __HAIKU__ +#define TORRENT_BEOS +#include // B_PATH_NAME_LENGTH +#define TORRENT_HAS_FALLOCATE 0 #else #warning unknown OS, assuming BSD #define TORRENT_BSD #endif +#ifndef TORRENT_EXPORT +# define TORRENT_EXPORT +#endif + +#ifndef TORRENT_DEPRECATED_PREFIX +#define TORRENT_DEPRECATED_PREFIX +#endif + +#ifndef TORRENT_DEPRECATED +#define TORRENT_DEPRECATED +#endif + #ifndef TORRENT_USE_IPV6 #define TORRENT_USE_IPV6 1 #endif @@ -144,7 +140,12 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_USE_MLOCK 1 #define TORRENT_USE_READV 1 #define TORRENT_USE_WRITEV 1 + +#if !defined TORRENT_USE_IOSTREAM && !defined BOOST_NO_IOSTREAM #define TORRENT_USE_IOSTREAM 1 +#else +#define TORRENT_USE_IOSTREAM 0 +#endif #define TORRENT_USE_I2P 1 @@ -161,6 +162,10 @@ POSSIBILITY OF SUCH DAMAGE. #if defined FILENAME_MAX #define TORRENT_MAX_PATH FILENAME_MAX +// beos +#elif defined B_PATH_NAME_LENGTH +#defined TORRENT_MAX_PATH B_PATH_NAME_LENGTH + // solaris #elif defined MAXPATH #define TORRENT_MAX_PATH MAXPATH @@ -216,11 +221,15 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_ISE_ICONV 0 #endif -#if defined UNICODE +#if defined UNICODE && !defined BOOST_NO_STD_WSTRING #define TORRENT_USE_WSTRING 1 #else #define TORRENT_USE_WSTRING 0 -#endif // TORRENT_WINDOWS +#endif // UNICODE + +#ifndef TORRENT_HAS_FALLOCATE +#define TORRENT_HAS_FALLOCATE 1 +#endif #if !defined(TORRENT_READ_HANDLER_MAX_SIZE) # define TORRENT_READ_HANDLER_MAX_SIZE 256 @@ -241,7 +250,8 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #if !defined TORRENT_USE_ABSOLUTE_TIME \ && !defined TORRENT_USE_QUERY_PERFORMANCE_TIMER \ && !defined TORRENT_USE_CLOCK_GETTIME \ - && !defined TORRENT_USE_BOOST_DATE_TIME + && !defined TORRENT_USE_BOOST_DATE_TIME \ + && !defined TORRENT_USE_SYSTEM_TIME #if defined(__MACH__) #define TORRENT_USE_ABSOLUTE_TIME 1 @@ -249,6 +259,8 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_USE_QUERY_PERFORMANCE_TIMER 1 #elif defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 #define TORRENT_USE_CLOCK_GETTIME 1 +#elif defined(TORRENT_BEOS) +#define TORRENT_USE_SYSTEM_TIME 1 #else #define TORRENT_USE_BOOST_DATE_TIME 1 #endif diff --git a/include/libtorrent/deadline_timer.hpp b/include/libtorrent/deadline_timer.hpp index 0263a67ae..3cfa4ed8f 100644 --- a/include/libtorrent/deadline_timer.hpp +++ b/include/libtorrent/deadline_timer.hpp @@ -37,15 +37,21 @@ POSSIBILITY OF SUCH DAMAGE. #define Protocol Protocol_ #endif -#if BOOST_VERSION < 103500 -#include -#include +#if __GNUC__ < 3 +// in GCC 2.95 templates seems to have all symbols +// resolved as they are parsed, so the time_traits +// template actually needs the definitions it uses, +// even though it's never instantiated +#include #else -#include -#include +#include #endif -#include +#if BOOST_VERSION < 103500 +#include +#else +#include +#endif #ifdef __OBJC__ #undef Protocol diff --git a/include/libtorrent/escape_string.hpp b/include/libtorrent/escape_string.hpp index 0f3084bbe..fcb3d5426 100644 --- a/include/libtorrent/escape_string.hpp +++ b/include/libtorrent/escape_string.hpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_ESCAPE_STRING_HPP_INCLUDED #include -#include +#include #include #include "libtorrent/config.hpp" #include "libtorrent/size_type.hpp" diff --git a/include/libtorrent/hasher.hpp b/include/libtorrent/hasher.hpp index 554daa13e..1348fb585 100644 --- a/include/libtorrent/hasher.hpp +++ b/include/libtorrent/hasher.hpp @@ -124,7 +124,7 @@ namespace libtorrent } #endif - void update(std::string const& data) { update(&data[0], data.size()); } + void update(std::string const& data) { update(data.c_str(), data.size()); } void update(const char* data, int len) { TORRENT_ASSERT(data != 0); diff --git a/include/libtorrent/io.hpp b/include/libtorrent/io.hpp index 06c7563ec..552b6c6dd 100644 --- a/include/libtorrent/io.hpp +++ b/include/libtorrent/io.hpp @@ -139,7 +139,7 @@ namespace libtorrent inline void write_string(std::string const& str, char*& start) { - std::memcpy((void*)start, &str[0], str.size()); + std::memcpy((void*)start, str.c_str(), str.size()); start += str.size(); } diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index 175617e4b..8d8089d47 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -149,9 +149,6 @@ namespace detail void add_rule(Addr first, Addr last, int flags) { - using boost::next; - using boost::prior; - TORRENT_ASSERT(!m_access_list.empty()); TORRENT_ASSERT(first < last || first == last); @@ -164,13 +161,13 @@ namespace detail TORRENT_ASSERT(j != i); int first_access = i->access; - int last_access = prior(j)->access; + int last_access = boost::prior(j)->access; if (i->start != first && first_access != flags) { i = m_access_list.insert(i, range(first, flags)); } - else if (i != m_access_list.begin() && prior(i)->access == flags) + else if (i != m_access_list.begin() && boost::prior(i)->access == flags) { --i; first_access = i->access; diff --git a/include/libtorrent/peer_id.hpp b/include/libtorrent/peer_id.hpp index c2010f4de..3624147ad 100644 --- a/include/libtorrent/peer_id.hpp +++ b/include/libtorrent/peer_id.hpp @@ -91,14 +91,14 @@ namespace libtorrent { TORRENT_ASSERT(s.size() >= 20); int sl = int(s.size()) < size ? int(s.size()) : size; - std::memcpy(m_number, &s[0], sl); + std::memcpy(m_number, s.c_str(), sl); } void assign(std::string const& s) { TORRENT_ASSERT(s.size() >= 20); int sl = int(s.size()) < size ? int(s.size()) : size; - std::memcpy(m_number, &s[0], sl); + std::memcpy(m_number, s.c_str(), sl); } void assign(char const* str) diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 3caeaf61e..082fefe23 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -465,9 +465,13 @@ namespace libtorrent downloading_piece& add_download_piece(); void erase_download_piece(std::vector::iterator i); + // some compilers (e.g. gcc 2.95, does not inherit access + // privileges to nested classes) + public: // the number of seeds. These are not added to // the availability counters of the pieces int m_seeds; + private: // the following vectors are mutable because they sometimes may // be updated lazily, triggered by const functions diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index e0a28d33d..d4b27173f 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -169,7 +169,7 @@ namespace libtorrent error_code const& error() const { return m_error; } std::string const& error_file() const { return m_error_file; } - void clear_error() { m_error = error_code(); m_error_file.clear(); } + void clear_error() { m_error = error_code(); m_error_file.resize(0); } mutable error_code m_error; mutable std::string m_error_file; diff --git a/include/libtorrent/time.hpp b/include/libtorrent/time.hpp index cdc3d51cc..15482ffa6 100644 --- a/include/libtorrent/time.hpp +++ b/include/libtorrent/time.hpp @@ -128,7 +128,7 @@ namespace libtorrent s * 1000000 * 60 * 60)); } -#elif defined TORRENT_USE_CLOCK_GETTIME +#elif defined TORRENT_USE_CLOCK_GETTIME || defined TORRENT_USE_SYSTEM_TIME inline int total_seconds(time_duration td) { return td.diff / 1000000; } diff --git a/include/libtorrent/utf8.hpp b/include/libtorrent/utf8.hpp index f9327f8a6..a75af94c1 100644 --- a/include/libtorrent/utf8.hpp +++ b/include/libtorrent/utf8.hpp @@ -33,7 +33,9 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_UTF8_HPP_INCLUDED #define TORRENT_UTF8_HPP_INCLUDED -#if !defined BOOST_NO_STD_WSTRING +#include "libtorrent/config.hpp" + +#if TORRENT_USE_WSTRING #include #include diff --git a/src/alert.cpp b/src/alert.cpp index d7dad2421..e305b0b74 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" #include "libtorrent/time.hpp" #include "libtorrent/error_code.hpp" +#include "libtorrent/escape_string.hpp" #include namespace libtorrent { diff --git a/src/allocator.cpp b/src/allocator.cpp index d8a68edd3..27134d229 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -44,10 +44,15 @@ namespace libtorrent { char* page_aligned_allocator::malloc(const size_type bytes) { -#ifdef TORRENT_WINDOWS - return reinterpret_cast(VirtualAlloc(0, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)); +#if defined TORRENT_WINDOWS + return (char*)VirtualAlloc(0, bytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); +#elif defined TORRENT_BEOS + // we could potentially use create_area() here, but + // you can't free it through its pointer, you need to + // associate the area_id with the pointer somehow + return (char*)::malloc(bytes); #else - return reinterpret_cast(valloc(bytes)); + return (char*)valloc(bytes); #endif } @@ -55,6 +60,8 @@ namespace libtorrent { #ifdef TORRENT_WINDOWS VirtualFree(block, 0, MEM_RELEASE); +#elif defined TORRENT_BEOS + return ::free(block); #else ::free(block); #endif diff --git a/src/assert.cpp b/src/assert.cpp index 328c54a2b..358a696f7 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -41,7 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include // uClibc++ doesn't have cxxabi.h -#if defined __GNUC__ && !defined __UCLIBCXX_MAJOR__ +#if defined __GNUC__ && __GNUC__ >= 3 \ + && !defined __UCLIBCXX_MAJOR__ #include diff --git a/src/bandwidth_manager.cpp b/src/bandwidth_manager.cpp index d04f1b0a0..a23e50193 100644 --- a/src/bandwidth_manager.cpp +++ b/src/bandwidth_manager.cpp @@ -57,7 +57,6 @@ namespace libtorrent m_abort = true; m_queue.clear(); m_queued_bytes = 0; - error_code ec; } #ifdef TORRENT_DEBUG diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 68e55b283..3c2465cbb 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" #include -#include +#include #include #include "libtorrent/bt_peer_connection.hpp" diff --git a/src/escape_string.cpp b/src/escape_string.cpp index 195665087..96aebbbb0 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include +#include #include #include diff --git a/src/file.cpp b/src/file.cpp index 4f22af6b9..6498c925b 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1443,7 +1443,7 @@ namespace libtorrent ec.assign(errno, get_posix_category()); return false; } -#else +#elif TORRENT_HAS_FALLOCATE int ret = posix_fallocate(m_fd, 0, s); if (ret != 0) { diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 7c8f7eec1..b49e9864c 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" #include -#include +#include #include #include "libtorrent/http_seed_connection.hpp" diff --git a/src/identify_client.cpp b/src/identify_client.cpp index d35a939ca..5287005e9 100644 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -91,7 +91,7 @@ namespace { fingerprint ret("..", 0, 0, 0, 0); - if (!std::isalnum(id[0])) + if (!is_alpha(id[0]) && !is_digit(id[0])) return boost::optional(); if (std::equal(id.begin()+4, id.begin()+6, "--")) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index d5a0eacc2..c4accb522 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" #include -#include +#include #include #include "libtorrent/peer_connection.hpp" diff --git a/src/time.cpp b/src/time.cpp index 1d1c7901a..20cf65657 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include +#include #include #include "libtorrent/config.hpp" #include "libtorrent/time.hpp" @@ -182,7 +182,17 @@ namespace libtorrent } } -#endif // TORRENT_USE_CLOCK_GETTIME +#elif defined TORRENT_USE_SYSTEM_TIME + +#include + +namespace libtorrent +{ + ptime time_now_hires() + { return ptime(get_system_time()); } +} + +#endif // TORRENT_USE_SYSTEM_TIME #endif // TORRENT_USE_BOOST_DATE_TIME diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index 32a3b198d..9a1f4ea56 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" #include -#include +#include #include #include