Skip to content

Commit

Permalink
feat: change epoll.h dir in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanshudong committed Nov 21, 2024
1 parent 0d31c38 commit 117bde3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 249 deletions.
103 changes: 50 additions & 53 deletions util/src/epoll_windows/sys/epoll.h → util/include/util/sys/epoll.h
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,54 +1,51 @@

#ifndef EPOLL_H_
#define EPOLL_H_

#include <WinSock2.h>
#include <Windows.h>
#include <stdint.h>

#define EPOLLIN 0x001
// #define EPOLLPRI 0x002
#define EPOLLOUT 0x004
#define EPOLLERR 0x008
#define EPOLLHUP 0x010
#define EPOLLRDNORM 0x040
#define EPOLLRDBAND 0x080
#define EPOLLWRNORM 0x100
// #define EPOLLMSG 0x400
#define EPOLLWRBAND 0x200
#define EPOLLRDHUP 0x2000

/* #define EPOLLET (1 << 30) Not supported */
// #define EPOLLONESHOT (1 << 31)

#define EPOLL_CTL_ADD 1
#define EPOLL_CTL_MOD 2
#define EPOLL_CTL_DEL 3

typedef void *epoll_t;

typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
// /* Windows-specific extensions. */
// SOCKET sock;
// HANDLE hnd;
} epoll_data_t;

struct epoll_event
{
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
};

epoll_t epoll_create(int);

int epoll_close(epoll_t epoll_hnd);

int epoll_ctl(epoll_t epoll_hnd, int op, SOCKET sock, struct epoll_event *event);

int epoll_wait(epoll_t epoll_hnd, struct epoll_event *events, int maxevents, int timeout);


#ifndef EPOLL_H_
#define EPOLL_H_

#include <WinSock2.h>
#include <Windows.h>
#include <stdint.h>

#define EPOLLIN 0x001
// #define EPOLLPRI 0x002
#define EPOLLOUT 0x004
#define EPOLLERR 0x008
#define EPOLLHUP 0x010
#define EPOLLRDNORM 0x040
#define EPOLLRDBAND 0x080
#define EPOLLWRNORM 0x100
// #define EPOLLMSG 0x400
#define EPOLLWRBAND 0x200
#define EPOLLRDHUP 0x2000

/* #define EPOLLET (1 << 30) Not supported */
// #define EPOLLONESHOT (1 << 31)

#define EPOLL_CTL_ADD 1
#define EPOLL_CTL_MOD 2
#define EPOLL_CTL_DEL 3

typedef void *epoll_t;

typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;

struct epoll_event
{
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
};

epoll_t epoll_create(int);

int epoll_close(epoll_t epoll_hnd);

int epoll_ctl(epoll_t epoll_hnd, int op, SOCKET sock, struct epoll_event *event);

int epoll_wait(epoll_t epoll_hnd, struct epoll_event *events, int maxevents, int timeout);

#endif /* EPOLL_H_ */
7 changes: 5 additions & 2 deletions util/include/util/tc_epoller.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ const int EPOLLERR = 0x0008;

typedef kevent64_s epoll_event;

#else
#include "sys/epoll.h"
// #else
// #include "sys/epoll.h"
#endif

#if TARGET_PLATFORM_WINDOWS
#include "util/sys/epoll.h"
#endif

namespace tars
{
Expand Down
8 changes: 4 additions & 4 deletions util/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if(ENABLE_SHARED)
endif()
endif()

IF(WIN32)
install(DIRECTORY epoll_windows/sys
DESTINATION include)
ENDIF()
# IF(WIN32)
# install(DIRECTORY epoll_windows/sys
# DESTINATION include)
# ENDIF()
2 changes: 1 addition & 1 deletion util/src/epoll_windows/src/epoll.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "sys/epoll.h"
#include "util/sys/epoll.h"
#include "msafd.h"

#include <unordered_map>
Expand Down
188 changes: 0 additions & 188 deletions util/src/epoll_windows/test/test.c

This file was deleted.

2 changes: 1 addition & 1 deletion util/src/tc_epoller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <algorithm>

#if TARGET_PLATFORM_WINDOWS
#include "sys/epoll.h"
#include "util/sys/epoll.h"
#else
#include <unistd.h>
#endif
Expand Down

0 comments on commit 117bde3

Please sign in to comment.