fixed build errors on Solaris

This commit is contained in:
Arvid Norberg 2009-01-27 08:24:48 +00:00
parent 37c48117b0
commit 3cdf9c87a8
26 changed files with 88 additions and 61 deletions

View File

@ -49,6 +49,7 @@ release 0.14.2
be torrent_handle::piece_priorities)
* fixed race condition when saving DHT state
* fixed bugs related to lexical_cast being locale dependent
* added support for SunPro C++ compiler
release 0.14.1

18
Jamfile
View File

@ -70,6 +70,11 @@ rule linking ( properties * )
;
}
if <target-os>solaris in $(properties)
{
result += <library>libsocket <library>libnsl ;
}
if <test-coverage>on in $(properties)
&& ( <toolset>gcc in $(properties)
|| <toolset>darwin in $(properties) )
@ -135,7 +140,8 @@ rule linking ( properties * )
{
result += <library>/boost/thread//boost_thread/<link>shared
<library>/boost/filesystem//boost_filesystem/<link>shared
<library>/boost/system//boost_system/<link>shared ;
<library>/boost/system//boost_system/<link>shared
;
}
result += <include>$(BOOST_ROOT) <define>BOOST_ALL_NO_LIB ;
}
@ -275,19 +281,22 @@ lib user32 : : <name>User32 ;
lib shell32 : : <name>shell32 ;
lib gdi32 : : <name>gdi32 ;
local library-search-path = <search>/opt/local/lib <search>/usr/lib <search>/usr/local/lib <search>/sw/lib ;
local library-search-path = <search>/opt/local/lib <search>/usr/lib <search>/usr/local/lib <search>/sw/lib <search>/usr/sfw/lib ;
lib boost_filesystem : : <name>boost_filesystem $(library-search-path) ;
lib boost_thread : : <name>boost_thread $(library-search-path) ;
lib boost_system : : <name>boost_system $(library-search-path) ;
# openssl on linux/bsd/macos etc.
lib crypto : : <name>crypto ;
lib ssl : : <name>ssl ;
lib crypto : : <name>crypto $(library-search-path) ;
lib ssl : : <name>ssl $(library-search-path) ;
# time functions used on linux require librt
lib librt : : <name>rt ;
lib libsocket : : <use>libnsl <name>socket <link>shared $(library-search-path) ;
lib libnsl : : <name>nsl <link>shared $(library-search-path) ;
lib tcmalloc : : <name>tcmalloc $(library-search-path) ;
# libz
@ -390,6 +399,7 @@ ZLIB_SOURCES =
local usage-requirements =
<include>./include
<include>./include/libtorrent
<include>/usr/sfw/include
<zlib>shipped:<include>./zlib
<variant>release:<define>NDEBUG
<variant>debug:<define>TORRENT_DEBUG

View File

@ -195,6 +195,11 @@ the runtime, but on windows you can do both. Example::
symbol ``clock_gettime``, you have to give ``need-librt=yes`` on the
bjam command line. This will make libtorrent link against ``librt``.
.. note::
When building on Solaris, you might have to specify ``stdlib=sun-stlport``
on the bjam command line.
The build targets are put in a directory called bin, and under it they are
sorted in directories depending on the toolset and build variant used.

View File

@ -232,7 +232,7 @@ std::string const& add_suffix(float val)
for (int i = 0; i < num_prefix; ++i)
{
val /= 1000.f;
if (fabs(val) < 1000.f)
if (std::fabs(val) < 1000.f)
{
std::string& ret = to_string(val, 4);
ret += prefix[i];

View File

@ -69,7 +69,7 @@ typedef enum {
GEOIP_MEMORY_CACHE = 1,
GEOIP_CHECK_CACHE = 2,
GEOIP_INDEX_CACHE = 4,
GEOIP_MMAP_CACHE = 8,
GEOIP_MMAP_CACHE = 8
} GeoIPOptions;
typedef enum {
@ -89,14 +89,14 @@ typedef enum {
typedef enum {
GEOIP_ANON_PROXY = 1,
GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2,
GEOIP_HTTP_CLIENT_IP_PROXY = 3,
GEOIP_HTTP_CLIENT_IP_PROXY = 3
} GeoIPProxyTypes;
typedef enum {
GEOIP_UNKNOWN_SPEED = 0,
GEOIP_DIALUP_SPEED = 1,
GEOIP_CABLEDSL_SPEED = 2,
GEOIP_CORPORATE_SPEED = 3,
GEOIP_CORPORATE_SPEED = 3
} GeoIPNetspeedValues;
extern char **GeoIPDBFileName;

View File

@ -258,9 +258,9 @@ namespace libtorrent
tracker_error_alert(torrent_handle const& h
, int times
, int status
, std::string const& url
, std::string const& url_
, std::string const& msg_)
: tracker_alert(h, url)
: tracker_alert(h, url_)
, times_in_row(times)
, status_code(status)
, msg(msg_)
@ -287,9 +287,9 @@ namespace libtorrent
struct TORRENT_EXPORT tracker_warning_alert: tracker_alert
{
tracker_warning_alert(torrent_handle const& h
, std::string const& url
, std::string const& url_
, std::string const& msg_)
: tracker_alert(h, url)
: tracker_alert(h, url_)
, msg(msg_)
{ TORRENT_ASSERT(!url.empty()); }
@ -311,8 +311,8 @@ namespace libtorrent
scrape_reply_alert(torrent_handle const& h
, int incomplete_
, int complete_
, std::string const& url)
: tracker_alert(h, url)
, std::string const& url_)
: tracker_alert(h, url_)
, incomplete(incomplete_)
, complete(complete_)
{ TORRENT_ASSERT(!url.empty()); }
@ -335,9 +335,9 @@ namespace libtorrent
struct TORRENT_EXPORT scrape_failed_alert: tracker_alert
{
scrape_failed_alert(torrent_handle const& h
, std::string const& url
, std::string const& url_
, std::string const& msg_)
: tracker_alert(h, url)
: tracker_alert(h, url_)
, msg(msg_)
{ TORRENT_ASSERT(!url.empty()); }
@ -358,8 +358,8 @@ namespace libtorrent
{
tracker_reply_alert(torrent_handle const& h
, int np
, std::string const& url)
: tracker_alert(h, url)
, std::string const& url_)
: tracker_alert(h, url_)
, num_peers(np)
{ TORRENT_ASSERT(!url.empty()); }
@ -402,8 +402,8 @@ namespace libtorrent
struct TORRENT_EXPORT tracker_announce_alert: tracker_alert
{
tracker_announce_alert(torrent_handle const& h
, std::string const& url, int event_)
: tracker_alert(h, url)
, std::string const& url_, int event_)
: tracker_alert(h, url_)
, event(event_)
{ TORRENT_ASSERT(!url.empty()); }

View File

@ -60,7 +60,7 @@ namespace libtorrent
~bitfield() { dealloc(); }
void assign(char const* bytes, int bits)
{ resize(bits); memcpy(m_bytes, bytes, (bits + 7) / 8); }
{ resize(bits); std::memcpy(m_bytes, bytes, (bits + 7) / 8); }
bool operator[](int index) const
{ return get_bit(index); }
@ -197,23 +197,23 @@ namespace libtorrent
{
if (old_size_bytes && b) m_bytes[old_size_bytes - 1] |= (0xff >> b);
if (old_size_bytes < new_size_bytes)
memset(m_bytes + old_size_bytes, 0xff, new_size_bytes - old_size_bytes);
std::memset(m_bytes + old_size_bytes, 0xff, new_size_bytes - old_size_bytes);
}
else
{
if (old_size_bytes < new_size_bytes)
memset(m_bytes + old_size_bytes, 0x00, new_size_bytes - old_size_bytes);
std::memset(m_bytes + old_size_bytes, 0x00, new_size_bytes - old_size_bytes);
}
}
void set_all()
{
memset(m_bytes, 0xff, (m_size + 7) / 8);
std::memset(m_bytes, 0xff, (m_size + 7) / 8);
}
void clear_all()
{
memset(m_bytes, 0x00, (m_size + 7) / 8);
std::memset(m_bytes, 0x00, (m_size + 7) / 8);
}
void resize(int bits)
@ -223,20 +223,20 @@ namespace libtorrent
{
if (m_own)
{
m_bytes = (unsigned char*)realloc(m_bytes, bytes);
m_bytes = (unsigned char*)std::realloc(m_bytes, bytes);
m_own = true;
}
else if (bits > m_size)
{
unsigned char* tmp = (unsigned char*)malloc(bytes);
memcpy(tmp, m_bytes, (std::min)((m_size + 7)/ 8, bytes));
unsigned char* tmp = (unsigned char*)std::malloc(bytes);
std::memcpy(tmp, m_bytes, (std::min)((m_size + 7)/ 8, bytes));
m_bytes = tmp;
m_own = true;
}
}
else
{
m_bytes = (unsigned char*)malloc(bytes);
m_bytes = (unsigned char*)std::malloc(bytes);
m_own = true;
}
m_size = bits;
@ -246,7 +246,7 @@ namespace libtorrent
private:
void dealloc() { if (m_own) free(m_bytes); m_bytes = 0; }
void dealloc() { if (m_own) std::free(m_bytes); m_bytes = 0; }
unsigned char* m_bytes;
int m_size; // in bits
bool m_own;

View File

@ -77,6 +77,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_LINUX
#elif defined WIN32
#define TORRENT_WINDOWS
#elif defined sun || defined __sun
#define TORRENT_SOLARIS
#else
#warning unkown OS, assuming BSD
#define TORRENT_BSD

View File

@ -128,7 +128,7 @@ namespace libtorrent
*(p-1) = '?';
tag_end = p - 1;
}
else if (start + 5 < p && memcmp(start, "!--", 3) == 0 && memcmp(p-2, "--", 2) == 0)
else if (start + 5 < p && std::memcmp(start, "!--", 3) == 0 && std::memcmp(p-2, "--", 2) == 0)
{
start += 3;
*(p-2) = 0;

View File

@ -41,16 +41,20 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/asio/ip/host_name.hpp>
#endif
#if defined TORRENT_BSD
#if defined TORRENT_BSD || defined TORRENT_SOLARIS
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/route.h>
#include <sys/sysctl.h>
#include <string.h>
#include <boost/scoped_array.hpp>
#endif
#if defined TORRENT_BSD
#include <sys/sysctl.h>
#endif
#if defined TORRENT_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@ -83,7 +87,7 @@ namespace libtorrent { namespace
{
typedef asio::ip::address_v4::bytes_type bytes_t;
bytes_t b;
memcpy(&b[0], ina, b.size());
std::memcpy(&b[0], ina, b.size());
return address_v4(b);
}
@ -91,7 +95,7 @@ namespace libtorrent { namespace
{
typedef asio::ip::address_v6::bytes_type bytes_t;
bytes_t b;
memcpy(&b[0], ina6, b.size());
std::memcpy(&b[0], ina6, b.size());
return address_v6(b);
}
@ -244,11 +248,11 @@ namespace libtorrent
{
std::vector<ip_interface> ret;
// covers linux, MacOS X and BSD distributions
#if defined TORRENT_LINUX || defined TORRENT_BSD
#if defined TORRENT_LINUX || defined TORRENT_BSD || defined TORRENT_SOLARIS
int s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
{
ec = asio::error::fault;
ec = error_code(errno, asio::error::system_category);
return ret;
}
ifconf ifc;
@ -300,7 +304,7 @@ namespace libtorrent
#if defined TORRENT_BSD
int current_size = item.ifr_addr.sa_len + IFNAMSIZ;
#elif defined TORRENT_LINUX
#elif defined TORRENT_LINUX || defined TORRENT_SOLARIS
int current_size = sizeof(ifreq);
#endif
ifr += current_size;

View File

@ -285,7 +285,7 @@ namespace libtorrent
i->offset = off;
i->file_base = 0;
char name[10];
sprintf(name, "%d", padding_file);
std::sprintf(name, "%d", padding_file);
i->path = *(i+1)->path.begin();
i->path /= "_____padding_file_";
i->path /= name;

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <algorithm>
#include <stdlib.h>
#include "libtorrent/config.hpp"
#include "libtorrent/http_parser.hpp"
@ -162,7 +163,7 @@ namespace libtorrent
if (name == "content-length")
{
#ifdef WIN32
#ifdef TORRENT_WINDOWS
m_content_length = _atoi64(value.c_str());
#else
m_content_length = atoll(value.c_str());

View File

@ -134,7 +134,7 @@ namespace libtorrent
if (found_end)
{
m_buffer.push_back(0);
char* status = strchr(&m_buffer[0], ' ');
char* status = std::strchr(&m_buffer[0], ' ');
if (status == 0)
{
(*h)(asio::error::operation_not_supported);
@ -144,7 +144,7 @@ namespace libtorrent
}
status++;
int code = atoi(status);
int code = std::atoi(status);
if (code != 200)
{
(*h)(asio::error::operation_not_supported);

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <algorithm>
#include <stdio.h>
#ifdef _MSC_VER
#pragma warning(push, 1)

View File

@ -274,7 +274,7 @@ void routing_table::node_failed(node_id const& id)
b.erase(i);
i = find_if(rb.begin(), rb.end(), bind(&node_entry::pinged, _1) == true);
i = std::find_if(rb.begin(), rb.end(), bind(&node_entry::pinged, _1) == true);
if (i == rb.end()) i = rb.begin();
b.push_back(*i);
rb.erase(i);

View File

@ -82,7 +82,7 @@ void intrusive_ptr_release(observer const* o)
if (--o->m_refs == 0)
{
boost::pool<>& p = o->pool_allocator;
o->~observer();
(const_cast<observer*>(o))->~observer();
p.free(const_cast<observer*>(o));
}
}
@ -105,7 +105,7 @@ typedef mpl::max_element<
rpc_manager::rpc_manager(fun const& f, node_id const& our_id
, routing_table& table, send_fun const& sf)
: m_pool_allocator(sizeof(mpl::deref<max_observer_type_iter::base>::type))
, m_next_transaction_id(rand() % max_transactions)
, m_next_transaction_id(std::rand() % max_transactions)
, m_oldest_transaction_id(m_next_transaction_id)
, m_incoming(f)
, m_send(sf)

View File

@ -175,7 +175,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
sha1_hash ih(0);
std::istringstream ih_sstr(ih_str);
ih_sstr >> ih;
int port = atoi(port_str.c_str());
int port = std::atoi(port_str.c_str());
if (!ih.is_all_zeros() && port != 0)
{

View File

@ -115,7 +115,7 @@ namespace libtorrent
{
hostname.assign(start, port_pos);
++port_pos;
port = atoi(std::string(port_pos, end).c_str());
port = std::atoi(std::string(port_pos, end).c_str());
}
else
{

View File

@ -1487,7 +1487,7 @@ namespace libtorrent
// we're not using rarest first (only for the first
// bucket, since that's where the currently downloading
// pieces are)
int start_piece = rand() % m_piece_map.size();
int start_piece = std::rand() % m_piece_map.size();
int piece = start_piece;
while (num_blocks > 0)

View File

@ -81,7 +81,6 @@ POSSIBILITY OF SUCH DAMAGE.
using boost::shared_ptr;
using boost::weak_ptr;
using boost::bind;
using boost::mutex;
using libtorrent::aux::session_impl;
#ifdef TORRENT_MEMDEBUG

View File

@ -84,7 +84,6 @@ using boost::tuples::tuple;
using boost::tuples::get;
using boost::tuples::make_tuple;
using boost::bind;
using boost::mutex;
using libtorrent::aux::session_impl;
namespace

View File

@ -75,7 +75,6 @@ namespace std
#endif
using boost::bind;
using boost::mutex;
using libtorrent::aux::session_impl;
#ifdef BOOST_NO_EXCEPTIONS

View File

@ -164,20 +164,25 @@ namespace
void trim_path_element(std::string& path_element)
{
#ifdef FILENAME_MAX
const int max_path_len = FILENAME_MAX;
#else
// on windows, NAME_MAX refers to Unicode characters
// on linux it refers to bytes (utf-8 encoded)
// TODO: Make this count Unicode characters instead of bytes on windows
if (path_element.size() > NAME_MAX)
const int max_path_len = NAME_MAX;
#endif
if (path_element.size() > max_path_len)
{
// truncate filenames that are too long. But keep extensions!
std::string ext = fs::extension(path_element);
if (ext.size() > 15)
{
path_element.resize(NAME_MAX);
path_element.resize(max_path_len);
}
else
{
path_element.resize(NAME_MAX - ext.size());
path_element.resize(max_path_len - ext.size());
path_element += ext;
}
}
@ -446,7 +451,7 @@ namespace libtorrent
// copy the info section
m_info_section_size = section.second;
m_info_section.reset(new char[m_info_section_size]);
memcpy(m_info_section.get(), section.first, m_info_section_size);
std::memcpy(m_info_section.get(), section.first, m_info_section_size);
TORRENT_ASSERT(section.first[0] == 'd');
TORRENT_ASSERT(section.first[m_info_section_size-1] == 'e');

View File

@ -321,7 +321,7 @@ namespace libtorrent
char* ptr = buf;
if (m_transaction_id == 0)
m_transaction_id = rand() ^ (rand() << 16);
m_transaction_id = std::rand() ^ (std::rand() << 16);
detail::write_uint32(0x417, ptr);
detail::write_uint32(0x27101980, ptr); // connection_id
@ -344,7 +344,7 @@ namespace libtorrent
void udp_tracker_connection::send_udp_scrape()
{
if (m_transaction_id == 0)
m_transaction_id = rand() ^ (rand() << 16);
m_transaction_id = std::rand() ^ (std::rand() << 16);
if (!m_socket.is_open()) return; // the operation was aborted
@ -482,7 +482,7 @@ namespace libtorrent
void udp_tracker_connection::send_udp_announce()
{
if (m_transaction_id == 0)
m_transaction_id = rand() ^ (rand() << 16);
m_transaction_id = std::rand() ^ (std::rand() << 16);
if (!m_socket.is_open()) return; // the operation was aborted

View File

@ -956,7 +956,7 @@ namespace
void find_error_code(int type, char const* string, error_code_parse_state& state)
{
if (state.exit) return;
if (type == xml_start_tag && !strcmp("errorCode", string))
if (type == xml_start_tag && !std::strcmp("errorCode", string))
{
state.in_error_code = true;
}
@ -1088,7 +1088,7 @@ void upnp::on_upnp_map_response(error_code const& e
{
// The external port cannot be wildcarder
// pick a random port
m.external_port = 40000 + (rand() % 10000);
m.external_port = 40000 + (std::rand() % 10000);
m.action = mapping_t::action_add;
++m.failcount;
update_map(d, mapping);

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <limits>
#include <boost/bind.hpp>
#include <sstream>
#include <stdlib.h>
#include "libtorrent/web_peer_connection.hpp"
#include "libtorrent/session.hpp"
@ -497,7 +498,7 @@ namespace libtorrent
else
{
range_start = 0;
range_end = atol(m_parser.header("content-length").c_str());
range_end = m_parser.content_length();
if (range_end == -1)
{
// we should not try this server again.