fix windows and linux build

This commit is contained in:
Arvid Norberg 2015-03-15 04:25:54 +00:00
parent 58aa4e5ae7
commit 6c67694d22
4 changed files with 21 additions and 6 deletions

View File

@ -233,8 +233,9 @@ struct bdecode_token
// There are 5 different types of nodes, see type_t.
struct TORRENT_EXPORT bdecode_node
{
friend int bdecode(char const* start, char const* end, bdecode_node& ret
, error_code& ec, int* error_pos, int depth_limit, int token_limit);
TORRENT_EXPORT friend int bdecode(char const* start, char const* end, bdecode_node& ret
, error_code& ec, int* error_pos, int depth_limit
, int token_limit);
// creates a default constructed node, it will have the type ``none_t``.
bdecode_node();

View File

@ -61,6 +61,9 @@ namespace libtorrent
typedef boost::asio::detail::mutex mutex;
typedef boost::asio::detail::event event;
// internal
void sleep(int milliseconds);
struct TORRENT_EXTRA_EXPORT condition_variable
{
condition_variable();

View File

@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/string_util.hpp"
#include "libtorrent/random.hpp"
#include <stdlib.h> // for malloc/free
#include <string.h> // for strcpy/strlen
#include <cstdlib> // for malloc
#include <cstring> // for memmov/strcpy/strlen
namespace libtorrent
{
@ -138,9 +138,9 @@ namespace libtorrent
char* allocate_string_copy(char const* str)
{
if (str == 0) return 0;
char* tmp = (char*)malloc(strlen(str) + 1);
char* tmp = (char*)std::malloc(std::strlen(str) + 1);
if (tmp == 0) return 0;
strcpy(tmp, str);
std::strcpy(tmp, str);
return tmp;
}

View File

@ -47,6 +47,17 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
void sleep(int milliseconds)
{
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
Sleep(milliseconds);
#elif defined TORRENT_BEOS
snooze_until(system_time() + boost::int64_t(milliseconds) * 1000, B_SYSTEM_TIMEBASE);
#else
usleep(milliseconds * 1000);
#endif
}
#ifdef BOOST_HAS_PTHREADS
condition_variable::condition_variable()