Skip to content

Commit 4cf8722

Browse files
author
wenbob
committed
add mingw make support
1 parent 3a7154a commit 4cf8722

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
CXXFLAGS = -std=gnu++0x -g -O0 -I$(LIBUV_PATH)/include -I$(HTTP_PARSER_PATH) -I. -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
22

33
OS_NAME=$(shell uname -s)
4-
ifeq (${OS_NAME},Darwin)
5-
RTLIB=
4+
ifeq (MINGW,$(findstring MINGW,$(OS_NAME)))
5+
RTLIB=-lws2_32 -lpsapi -liphlpapi
66
else
7-
RTLIB=-lrt
7+
ifeq (Darwin,$(findstring Darwin,$(OS_NAME)))
8+
RTLIB=
9+
else
10+
RTLIB=-lrt
11+
endif
812
endif
913

1014
all: webclient webserver file_test

native/fs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ namespace native
2121
static const int create = O_CREAT;
2222
static const int excl = O_EXCL;
2323
static const int truncate = O_TRUNC;
24+
#ifdef O_NOFOLLOW
2425
static const int no_follow = O_NOFOLLOW;
26+
#endif
27+
#ifdef O_DIRECTORY
2528
static const int directory = O_DIRECTORY;
29+
#endif
2630
#ifdef O_NOATIME
2731
static const int no_access_time = O_NOATIME;
2832
#endif

native/stream.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#include "handle.h"
77
#include "callback.h"
88

9+
#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
10+
#define UV_BUF(base, len) {base, len}
11+
#else
12+
#define UV_BUF(base, len) {len, base}
13+
#endif
14+
915
namespace native
1016
{
1117
namespace base
@@ -45,12 +51,12 @@ namespace native
4551
[](uv_handle_t*, size_t suggested_size){
4652
if(!max_alloc_size)
4753
{
48-
return uv_buf_t { new char[suggested_size], suggested_size };
54+
return uv_buf_t UV_BUF( new char[suggested_size], suggested_size );
4955
}
5056
else
5157
{
5258
auto size = max_alloc_size > suggested_size ? suggested_size : max_alloc_size;
53-
return uv_buf_t { new char[size], size };
59+
return uv_buf_t UV_BUF( new char[size], size );
5460
}
5561
},
5662
[](uv_stream_t* s, ssize_t nread, uv_buf_t buf){
@@ -76,7 +82,7 @@ namespace native
7682

7783
bool write(const char* buf, int len, std::function<void(error)> callback)
7884
{
79-
uv_buf_t bufs[] = { uv_buf_t { const_cast<char*>(buf), len } };
85+
uv_buf_t bufs[] = { uv_buf_t UV_BUF( const_cast<char*>(buf), len ) };
8086
callbacks::store(get()->data, native::internal::uv_cid_write, callback);
8187
return uv_write(new uv_write_t, get<uv_stream_t>(), bufs, 1, [](uv_write_t* req, int status) {
8288
callbacks::invoke<decltype(callback)>(req->handle->data, native::internal::uv_cid_write, status?uv_last_error(req->handle->loop):error());
@@ -86,7 +92,7 @@ namespace native
8692

8793
bool write(const std::string& buf, std::function<void(error)> callback)
8894
{
89-
uv_buf_t bufs[] = { uv_buf_t { const_cast<char*>(buf.c_str()), buf.length()} };
95+
uv_buf_t bufs[] = { uv_buf_t UV_BUF( const_cast<char*>(buf.c_str()), buf.length()) };
9096
callbacks::store(get()->data, native::internal::uv_cid_write, callback);
9197
return uv_write(new uv_write_t, get<uv_stream_t>(), bufs, 1, [](uv_write_t* req, int status) {
9298
callbacks::invoke<decltype(callback)>(req->handle->data, native::internal::uv_cid_write, status?uv_last_error(req->handle->loop):error());
@@ -96,7 +102,7 @@ namespace native
96102

97103
bool write(const std::vector<char>& buf, std::function<void(error)> callback)
98104
{
99-
uv_buf_t bufs[] = { uv_buf_t { const_cast<char*>(&buf[0]), buf.size() } };
105+
uv_buf_t bufs[] = { uv_buf_t UV_BUF( const_cast<char*>(&buf[0]), buf.size() ) };
100106
callbacks::store(get()->data, native::internal::uv_cid_write, callback);
101107
return uv_write(new uv_write_t, get<uv_stream_t>(), bufs, 1, [](uv_write_t* req, int status) {
102108
callbacks::invoke<decltype(callback)>(req->handle->data, native::internal::uv_cid_write, status?uv_last_error(req->handle->loop):error());

0 commit comments

Comments
 (0)