win32 fluff

more win32 on msc++ fluff

and a solaris patch that i may revert later if the cpp directives aren't processed correctly
-despair86
pull/13/head
despair86 6 years ago
parent d394e229ca
commit 8c1b2c3b79

@ -47,8 +47,10 @@ else()
set(THREAD_LIB pthread)
endif()
if (NOT MSVC)
add_cflags("-march=native")
add_cxxflags("-march=native")
endif(NOT MSVC)
if(STATIC_LINK)
add_cflags("-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")

@ -6,6 +6,9 @@
#define qshift 2295
#define p 761
#ifdef _MSC_VER
#define LOOPS 2*p+1
#endif
#define w 286
#define rq_encode_len 1218

@ -40,8 +40,13 @@ int r3_recip(small *r,const small *s)
int loop;
small f[p + 1];
small g[p + 1];
#ifdef _MSC_VER
small u[LOOPS + 1];
small v[LOOPS + 1];
#else
small u[loops + 1];
small v[loops + 1];
#endif
small c;
int i;
int d = p;

@ -39,8 +39,13 @@ int rq_recip3(modq *r,const small *s)
int loop;
modq f[p + 1];
modq g[p + 1];
#ifdef _MSC_VER
modq u[LOOPS + 1];
modq v[LOOPS + 1];
#else
modq u[loops + 1];
modq v[loops + 1];
#endif
modq c;
int i;
int d = p;

@ -2,6 +2,9 @@
#define LLARP_CODEL_QUEUE_HPP
#ifdef _MSC_VER
#define NOMINMAX
#ifdef min
#undef min
#endif
#endif
#include <llarp/time.h>
#include <llarp/logger.hpp>

@ -2,11 +2,40 @@
#define LLARP_IP_HPP
#include <llarp/buffer.h>
#include <llarp/time.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <netinet/ip.h>
#else
#include <winsock2.h>
// Apparently this does not seem to be located _anywhere_ in the windows sdk??? -despair86
typedef struct ip_hdr
{
unsigned char ip_header_len:4; // 4-bit header length (in 32-bit words) normally=5 (Means 20 Bytes may be 24 also)
unsigned char ip_version :4; // 4-bit IPv4 version
unsigned char ip_tos; // IP type of service
unsigned short ip_total_length; // Total length
unsigned short ip_id; // Unique identifier
unsigned char ip_frag_offset :5; // Fragment offset field
unsigned char ip_more_fragment :1;
unsigned char ip_dont_fragment :1;
unsigned char ip_reserved_zero :1;
unsigned char ip_frag_offset1; //fragment offset
unsigned char ip_ttl; // Time to live
unsigned char ip_protocol; // Protocol(TCP,UDP etc)
unsigned short ip_checksum; // IP checksum
unsigned int ip_srcaddr; // Source address
unsigned int ip_destaddr; // Source address
} IPV4_HDR;
#define iphdr IPV4_HDR
#define saddr ip_srcaddr;
#define daddr ip_destaddr;
#endif
#include <memory>
#ifndef __linux__
// slightly different type names on sunos
#if !defined(__linux__) && !defined(_WIN32)
#define iphdr ip
#define saddr ip_src.s_addr
#define daddr ip_dst.s_addr

@ -52,7 +52,12 @@ namespace llarp
flush_write()
{
m_writeq.Process([this](const std::unique_ptr< WriteBuffer >& buffer) {
// todo: wtf???
#ifndef _WIN32
write(fd, buffer->buf, buffer->bufsz);
#else
// writefile
#endif
});
// todo: wtf???
#ifndef _WIN32

@ -292,7 +292,7 @@ struct llarp_win32_loop : public llarp_ev_loop
}
bool
add_ev(llarp::ev_io* ev)
add_ev(llarp::ev_io* ev, bool write)
{
ev->listener_id = reinterpret_cast< ULONG_PTR >(ev);
if(!::CreateIoCompletionPort(reinterpret_cast< HANDLE >(ev->fd), iocpfd,

@ -41,9 +41,9 @@ namespace llarp
pthread_setname_np(name);
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
pthread_set_name_np(pthread_self(), name);
#elif !defined(_MSC_VER) || !defined(_WIN32)
#elif !defined(_MSC_VER) || !defined(_WIN32) || defined(__linux__)
pthread_setname_np(pthread_self(), name);
#else
#elif defined(_MSC_VER)
SetThreadName(GetCurrentThreadId(), name);
#endif
}

Loading…
Cancel
Save