OS/2 (eCS) support
This commit is contained in:
parent
852502ef2c
commit
b8149ead5c
|
@ -261,6 +261,18 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_USE_IFADDRS 1
|
||||
#define TORRENT_USE_IFCONF 1
|
||||
|
||||
// ==== eCS(OS/2) ===
|
||||
#elif defined __OS2__
|
||||
#define TORRENT_OS2
|
||||
#define TORRENT_HAS_FALLOCATE 0
|
||||
#define TORRENT_USE_IFCONF 1
|
||||
#define TORRENT_USE_SYSCTL 1
|
||||
#define TORRENT_USE_MLOCK 0
|
||||
#define TORRENT_USE_IPV6 0
|
||||
#define TORRENT_ICONV_ARG (const char**)
|
||||
#define TORRENT_USE_WRITEV 0
|
||||
#define TORRENT_USE_READV 0
|
||||
|
||||
#else
|
||||
#warning unknown OS, assuming BSD
|
||||
#define TORRENT_BSD
|
||||
|
|
|
@ -51,6 +51,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/debug.hpp"
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_OS2 && defined ioc
|
||||
#undef ioc
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
|
||||
#define TORRENT_SOCKTYPE_I2P_FORWARD(x) \
|
||||
|
|
|
@ -334,7 +334,7 @@ int _check_mtime(GeoIP *gi) {
|
|||
char const* src_start;
|
||||
/* GeoIP Database file updated */
|
||||
if (gi->flags & (GEOIP_MEMORY_CACHE | GEOIP_MMAP_CACHE)) {
|
||||
#ifndef WIN32
|
||||
#if !defined WIN32 && !defined __OS2__
|
||||
if ( gi->flags & GEOIP_MMAP_CACHE) {
|
||||
munmap(gi->cache, gi->size);
|
||||
gi->cache = NULL;
|
||||
|
@ -371,7 +371,7 @@ int _check_mtime(GeoIP *gi) {
|
|||
gi->mtime = buf.st_mtime;
|
||||
gi->size = buf.st_size;
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined WIN32 && !defined __OS2__
|
||||
if ( gi->flags & GEOIP_MMAP_CACHE) {
|
||||
gi->cache = (unsigned char*)mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fileno(gi->GeoIPDatabase), 0);
|
||||
if ( gi->cache == MAP_FAILED ) {
|
||||
|
@ -594,7 +594,7 @@ GeoIP* GeoIP_open (const char * filename, int flags) {
|
|||
}
|
||||
gi->mtime = buf.st_mtime;
|
||||
gi->size = buf.st_size;
|
||||
#ifndef WIN32
|
||||
#if !defined WIN32 && !defined __OS2__
|
||||
/* MMAP added my Peter Shipley */
|
||||
if ( flags & GEOIP_MMAP_CACHE) {
|
||||
gi->cache = (unsigned char*)mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fileno(gi->GeoIPDatabase), 0);
|
||||
|
@ -660,7 +660,7 @@ void GeoIP_delete (GeoIP *gi) {
|
|||
if (gi->GeoIPDatabase != NULL)
|
||||
fclose(gi->GeoIPDatabase);
|
||||
if (gi->cache != NULL) {
|
||||
#ifndef WIN32
|
||||
#if !defined WIN32 && !defined __OS2__
|
||||
if ( gi->flags & GEOIP_MMAP_CACHE) {
|
||||
munmap(gi->cache, gi->size);
|
||||
} else
|
||||
|
|
|
@ -32,6 +32,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
#if defined TORRENT_OS2
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "libtorrent/socket.hpp"
|
||||
|
|
|
@ -88,6 +88,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
#if defined(TORRENT_OS2) and !defined(IF_NAMESIZE)
|
||||
#define IF_NAMESIZE IFNAMSIZ
|
||||
#endif
|
||||
|
||||
namespace libtorrent { namespace
|
||||
{
|
||||
|
||||
|
@ -222,6 +226,9 @@ namespace libtorrent { namespace
|
|||
#endif
|
||||
|
||||
#if TORRENT_USE_SYSCTL
|
||||
#ifdef TORRENT_OS2
|
||||
int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
|
||||
#endif
|
||||
|
||||
bool parse_route(int s, rt_msghdr* rtm, ip_route* rt_info)
|
||||
{
|
||||
|
@ -493,7 +500,11 @@ namespace libtorrent
|
|||
close(s);
|
||||
return ret;
|
||||
}
|
||||
#ifndef TORRENT_OS2
|
||||
iface.mtu = req.ifr_mtu;
|
||||
#else
|
||||
iface.mtu = req.ifr_metric; // according to tcp/ip reference
|
||||
#endif
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE - 1);
|
||||
|
@ -762,7 +773,11 @@ namespace libtorrent
|
|||
int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_UNSPEC, NET_RT_DUMP, 0};
|
||||
|
||||
size_t needed = 0;
|
||||
#ifdef TORRENT_OS2
|
||||
if (__libsocket_sysctl(mib, 6, 0, &needed, 0, 0) < 0)
|
||||
#else
|
||||
if (sysctl(mib, 6, 0, &needed, 0, 0) < 0)
|
||||
#endif
|
||||
{
|
||||
ec = error_code(errno, asio::error::system_category);
|
||||
return std::vector<ip_route>();
|
||||
|
@ -780,7 +795,11 @@ namespace libtorrent
|
|||
return std::vector<ip_route>();
|
||||
}
|
||||
|
||||
#ifdef TORRENT_OS2
|
||||
if (__libsocket_sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
|
||||
#else
|
||||
if (sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
|
||||
#endif
|
||||
{
|
||||
ec = error_code(errno, asio::error::system_category);
|
||||
return std::vector<ip_route>();
|
||||
|
|
17
src/file.cpp
17
src/file.cpp
|
@ -384,7 +384,7 @@ namespace libtorrent
|
|||
{
|
||||
while (*p != '/'
|
||||
&& *p != '\0'
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
&& *p != '\\'
|
||||
#endif
|
||||
) ++p;
|
||||
|
@ -426,7 +426,7 @@ namespace libtorrent
|
|||
{
|
||||
if (f.empty()) return false;
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
// match \\ form
|
||||
if (f == "\\\\") return true;
|
||||
int i = 0;
|
||||
|
@ -503,7 +503,7 @@ namespace libtorrent
|
|||
if (f.empty()) return "";
|
||||
char const* first = f.c_str();
|
||||
char const* sep = strrchr(first, '/');
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
char const* altsep = strrchr(first, '\\');
|
||||
if (sep == 0 || altsep > sep) sep = altsep;
|
||||
#endif
|
||||
|
@ -518,7 +518,7 @@ namespace libtorrent
|
|||
{
|
||||
--sep;
|
||||
if (*sep == '/'
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
|| *sep == '\\'
|
||||
#endif
|
||||
)
|
||||
|
@ -537,7 +537,7 @@ namespace libtorrent
|
|||
if (lhs.empty() || lhs == ".") return rhs;
|
||||
if (rhs.empty() || rhs == ".") return lhs;
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
#define TORRENT_SEPARATOR "\\"
|
||||
bool need_sep = lhs[lhs.size()-1] != '\\' && lhs[lhs.size()-1] != '/';
|
||||
#else
|
||||
|
@ -728,7 +728,7 @@ namespace libtorrent
|
|||
bool is_complete(std::string const& f)
|
||||
{
|
||||
if (f.empty()) return false;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
int i = 0;
|
||||
// match the xx:\ or xx:/ form
|
||||
while (f[i] && is_alpha(f[i])) ++i;
|
||||
|
@ -970,8 +970,11 @@ namespace libtorrent
|
|||
|
||||
if (mode & attribute_executable)
|
||||
permissions |= S_IXGRP | S_IXOTH | S_IXUSR;
|
||||
|
||||
#ifdef O_BINARY
|
||||
static const int mode_array[] = {O_RDONLY | O_BINARY, O_WRONLY | O_CREAT | O_BINARY, O_RDWR | O_CREAT | O_BINARY};
|
||||
#else
|
||||
static const int mode_array[] = {O_RDONLY, O_WRONLY | O_CREAT, O_RDWR | O_CREAT};
|
||||
#endif
|
||||
#ifdef O_DIRECT
|
||||
static const int no_buffer_flag[] = {0, O_DIRECT};
|
||||
#else
|
||||
|
|
|
@ -29,6 +29,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include "libtorrent/config.hpp"
|
||||
#if defined TORRENT_OS2
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include "libtorrent/pch.hpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue