Skip to content

Commit b2535d7

Browse files
committed
Fix windows-x64 platform compile issues
1 parent 39d7e23 commit b2535d7

33 files changed

+110
-100
lines changed

benchmark/ioevent/evpp/evpp_ioevent_bench.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
using namespace evpp;
2222

23-
std::vector<int> g_pipes;
23+
std::vector<evpp_socket_t> g_pipes;
2424
int numPipes;
2525
int numActive;
2626
int numWrites;
@@ -30,7 +30,7 @@ std::vector<FdChannel*> g_channels;
3030
int g_reads, g_writes, g_fired;
3131
int g_total_reads = 0;
3232

33-
void readCallback(int fd, int idx) {
33+
void readCallback(evpp_socket_t fd, int idx) {
3434
g_total_reads++;
3535
char ch = 0;
3636
g_reads += static_cast<int>(::recv(fd, &ch, sizeof(ch), 0));

benchmark/ioevent/fd_channel_vs_pipe_event_watcher/fd_channel_vs_pipe_event_watcher.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
using namespace evpp;
2020

21-
std::vector<int> g_pipes;
21+
std::vector<evpp_socket_t> g_pipes;
2222
int numPipes;
2323
int numActive;
2424
int numWrites;
@@ -28,7 +28,7 @@ std::vector<std::shared_ptr<PipeEventWatcher>> g_pipe_event_watchers;
2828

2929
int g_reads, g_writes, g_fired;
3030

31-
void ReadCallbackOfFdChannel(int fd, int idx) {
31+
void ReadCallbackOfFdChannel(evpp_socket_t fd, int idx) {
3232
char ch = 'm';
3333

3434
g_reads += static_cast<int>(::recv(fd, &ch, sizeof(ch), 0));
@@ -88,7 +88,7 @@ std::pair<int, int> FdChannelRunOnce() {
8888
std::pair<int, int> PipeEventWatcherRunOnce() {
8989
Timestamp beforeInit(Timestamp::Now());
9090
for (int i = 0; i < numActive; ++i) {
91-
int fd = g_pipe_event_watchers[i]->wfd();
91+
evpp_socket_t fd = g_pipe_event_watchers[i]->wfd();
9292
::send(fd, "m", 1, 0);
9393
}
9494

evpp/buffer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const char Buffer::kCRLF[] = "\r\n";
1919
const size_t Buffer::kCheapPrependSize = 8;
2020
const size_t Buffer::kInitialSize = 1024;
2121

22-
ssize_t Buffer::ReadFromFD(int fd, int* savedErrno) {
22+
ssize_t Buffer::ReadFromFD(evpp_socket_t fd, int* savedErrno) {
2323
// saved an ioctl()/FIONREAD call to tell how much to read
2424
char extrabuf[65536];
2525
struct iovec vec[2];

evpp/buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class EVPP_EXPORT Buffer {
235235

236236
// ReadFromFD reads data from a fd directly into buffer,
237237
// and return result of readv, errno is saved into saved_errno
238-
ssize_t ReadFromFD(int fd, int* saved_errno);
238+
ssize_t ReadFromFD(evpp_socket_t fd, int* saved_errno);
239239

240240
// Next returns a slice containing the next n bytes from the buffer,
241241
// advancing the buffer as if the bytes had been returned by Read.

evpp/connector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DNSResolver;
1313
class TCPClient;
1414
class EVPP_EXPORT Connector : public std::enable_shared_from_this<Connector> {
1515
public:
16-
typedef std::function<void(int sockfd, const std::string& /*local addr*/)> NewConnectionCallback;
16+
typedef std::function<void(evpp_socket_t sockfd, const std::string& /*local addr*/)> NewConnectionCallback;
1717
Connector(EventLoop* loop, TCPClient* client);
1818
~Connector();
1919
void Start();
@@ -54,7 +54,7 @@ class EVPP_EXPORT Connector : public std::enable_shared_from_this<Connector> {
5454

5555
Duration timeout_;
5656

57-
int fd_ = -1;
57+
evpp_socket_t fd_ = -1;
5858

5959
// A flag indicate whether the Connector owns this fd.
6060
// If the Connector owns this fd, the Connector has responsibility to close this fd.

evpp/event_watcher.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void PipeEventWatcher::DoClose() {
149149
}
150150
}
151151

152-
void PipeEventWatcher::HandlerFn(int /*fd*/, short /*which*/, void* v) {
152+
void PipeEventWatcher::HandlerFn(evpp_socket_t /*fd*/, short /*which*/, void* v) {
153153
PipeEventWatcher* e = (PipeEventWatcher*)v;
154154
#ifdef H_BENCHMARK_TESTING
155155
// Every time we only read 1 byte for testing the IO event performance.
@@ -213,7 +213,7 @@ bool TimerEventWatcher::DoInit() {
213213
return true;
214214
}
215215

216-
void TimerEventWatcher::HandlerFn(int /*fd*/, short /*which*/, void* v) {
216+
void TimerEventWatcher::HandlerFn(evpp_socket_t /*fd*/, short /*which*/, void* v) {
217217
TimerEventWatcher* h = (TimerEventWatcher*)v;
218218
h->handler_();
219219
}
@@ -226,14 +226,14 @@ bool TimerEventWatcher::AsyncWait() {
226226
//////////////////////////////////////////////////////////////////////////
227227
//////////////////////////////////////////////////////////////////////////
228228
//////////////////////////////////////////////////////////////////////////
229-
SignalEventWatcher::SignalEventWatcher(int signo, EventLoop* loop,
229+
SignalEventWatcher::SignalEventWatcher(signal_number_t signo, EventLoop* loop,
230230
const Handler& handler)
231231
: EventWatcher(loop->event_base(), handler)
232232
, signo_(signo) {
233233
assert(signo_);
234234
}
235235

236-
SignalEventWatcher::SignalEventWatcher(int signo, EventLoop* loop,
236+
SignalEventWatcher::SignalEventWatcher(signal_number_t signo, EventLoop* loop,
237237
Handler&& h)
238238
: EventWatcher(loop->event_base(), std::move(h))
239239
, signo_(signo) {
@@ -246,7 +246,7 @@ bool SignalEventWatcher::DoInit() {
246246
return true;
247247
}
248248

249-
void SignalEventWatcher::HandlerFn(int /*sn*/, short /*which*/, void* v) {
249+
void SignalEventWatcher::HandlerFn(signal_number_t /*sn*/, short /*which*/, void* v) {
250250
SignalEventWatcher* h = (SignalEventWatcher*)v;
251251
h->handler_();
252252
}

evpp/event_watcher.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ class EVPP_EXPORT PipeEventWatcher : public EventWatcher {
5757

5858
bool AsyncWait();
5959
void Notify();
60-
int wfd() const { return pipe_[0]; }
60+
evpp_socket_t wfd() const { return pipe_[0]; }
6161
private:
6262
virtual bool DoInit();
6363
virtual void DoClose();
64-
static void HandlerFn(int fd, short which, void* v);
64+
static void HandlerFn(evpp_socket_t fd, short which, void* v);
6565

66-
int pipe_[2]; // Write to pipe_[0] , Read from pipe_[1]
66+
evpp_socket_t pipe_[2]; // Write to pipe_[0] , Read from pipe_[1]
6767
};
6868

6969
class EVPP_EXPORT TimerEventWatcher : public EventWatcher {
@@ -77,20 +77,20 @@ class EVPP_EXPORT TimerEventWatcher : public EventWatcher {
7777

7878
private:
7979
virtual bool DoInit();
80-
static void HandlerFn(int fd, short which, void* v);
80+
static void HandlerFn(evpp_socket_t fd, short which, void* v);
8181
private:
8282
Duration timeout_;
8383
};
8484

8585
class EVPP_EXPORT SignalEventWatcher : public EventWatcher {
8686
public:
87-
SignalEventWatcher(int signo, EventLoop* loop, const Handler& handler);
88-
SignalEventWatcher(int signo, EventLoop* loop, Handler&& handler);
87+
SignalEventWatcher(signal_number_t signo, EventLoop* loop, const Handler& handler);
88+
SignalEventWatcher(signal_number_t signo, EventLoop* loop, Handler&& handler);
8989

9090
bool AsyncWait();
9191
private:
9292
virtual bool DoInit();
93-
static void HandlerFn(int sn, short which, void* v);
93+
static void HandlerFn(signal_number_t sn, short which, void* v);
9494

9595
int signo_;
9696
};

evpp/fd_channel.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace evpp {
1010
static_assert(FdChannel::kReadable == EV_READ, "");
1111
static_assert(FdChannel::kWritable == EV_WRITE, "");
1212

13-
FdChannel::FdChannel(EventLoop* l, int f, bool r, bool w)
13+
FdChannel::FdChannel(EventLoop* l, evpp_socket_t f, bool r, bool w)
1414
: loop_(l), attached_(false), event_(nullptr), fd_(f) {
1515
DLOG_TRACE << "fd=" << fd_;
1616
assert(fd_ > 0);
@@ -147,12 +147,12 @@ std::string FdChannel::EventsToString() const {
147147
return s;
148148
}
149149

150-
void FdChannel::HandleEvent(int sockfd, short which, void* v) {
150+
void FdChannel::HandleEvent(evpp_socket_t sockfd, short which, void* v) {
151151
FdChannel* c = (FdChannel*)v;
152152
c->HandleEvent(sockfd, which);
153153
}
154154

155-
void FdChannel::HandleEvent(int sockfd, short which) {
155+
void FdChannel::HandleEvent(evpp_socket_t sockfd, short which) {
156156
assert(sockfd == fd_);
157157
DLOG_TRACE << "fd=" << sockfd << " " << EventsToString();
158158

evpp/fd_channel.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class EVPP_EXPORT FdChannel {
2525
typedef std::function<void()> ReadEventCallback;
2626

2727
public:
28-
FdChannel(EventLoop* loop, int fd,
28+
FdChannel(EventLoop* loop, evpp_socket_t fd,
2929
bool watch_read_event, bool watch_write_event);
3030
~FdChannel();
3131

@@ -56,7 +56,7 @@ class EVPP_EXPORT FdChannel {
5656
void DisableAllEvent();
5757

5858
public:
59-
int fd() const {
59+
evpp_socket_t fd() const {
6060
return fd_;
6161
}
6262
std::string EventsToString() const;
@@ -71,8 +71,8 @@ class EVPP_EXPORT FdChannel {
7171
}
7272

7373
private:
74-
void HandleEvent(int fd, short which);
75-
static void HandleEvent(int fd, short which, void* v);
74+
void HandleEvent(evpp_socket_t fd, short which);
75+
static void HandleEvent(evpp_socket_t fd, short which, void* v);
7676

7777
void Update();
7878
void DetachFromLoop();
@@ -86,7 +86,7 @@ class EVPP_EXPORT FdChannel {
8686
struct event* event_;
8787
int events_; // the bitwise OR of zero or more of the EventType flags
8888

89-
int fd_;
89+
evpp_socket_t fd_;
9090
};
9191

9292
}

evpp/libevent.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "evpp/libevent.h"
33

44
#ifdef H_LIBEVENT_VERSION_14
5-
struct event* event_new(struct event_base* base, int fd, short events,
5+
struct event* event_new(struct event_base* base, evpp_socket_t fd, short events,
66
void(*cb)(int, short, void*), void* arg) {
77
struct event* ev;
88
ev = (struct event*)malloc(sizeof(struct event));

0 commit comments

Comments
 (0)