api: use HANDLE and SOCKET types instead of their underlying types

This commit is contained in:
Bert Belder 2017-09-25 18:04:10 +02:00
parent 16f62017ba
commit 3c2c4bfce7
2 changed files with 15 additions and 13 deletions

View File

@ -39,6 +39,8 @@ enum EPOLL_EVENTS {
#define EPOLL_CTL_MOD 2
#define EPOLL_CTL_DEL 3
typedef void* HANDLE;
typedef uintptr_t SOCKET;
typedef void* epoll_t;
typedef union epoll_data {
@ -46,8 +48,8 @@ typedef union epoll_data {
int fd;
uint32_t u32;
uint64_t u64;
/* SOCKET */ uintptr_t sock;
/* HANDLE */ void* hnd;
SOCKET sock;
HANDLE hnd;
} epoll_data_t;
struct epoll_event {
@ -65,7 +67,7 @@ EPOLL_EXTERN int epoll_close(epoll_t epoll_hnd);
EPOLL_EXTERN int epoll_ctl(epoll_t epoll_hnd,
int op,
/* SOCKET */ uintptr_t sock,
SOCKET sock,
struct epoll_event* event);
EPOLL_EXTERN int epoll_wait(epoll_t epoll_hnd,

View File

@ -47,9 +47,9 @@ int epoll_close(epoll_t port_handle) {
}
static int _ep_ctl_add(ep_port_t* port_info,
uintptr_t socket,
SOCKET sock,
struct epoll_event* ev) {
ep_sock_t* sock_info = ep_sock_new(port_info, socket);
ep_sock_t* sock_info = ep_sock_new(port_info, sock);
if (sock_info == NULL)
return -1;
@ -62,9 +62,9 @@ static int _ep_ctl_add(ep_port_t* port_info,
}
static int _ep_ctl_mod(ep_port_t* port_info,
uintptr_t socket,
SOCKET sock,
struct epoll_event* ev) {
ep_sock_t* sock_info = ep_port_find_socket(port_info, socket);
ep_sock_t* sock_info = ep_port_find_socket(port_info, sock);
if (sock_info == NULL)
return -1;
@ -74,8 +74,8 @@ static int _ep_ctl_mod(ep_port_t* port_info,
return 0;
}
static int _ep_ctl_del(ep_port_t* port_info, uintptr_t socket) {
ep_sock_t* sock_info = ep_port_find_socket(port_info, socket);
static int _ep_ctl_del(ep_port_t* port_info, SOCKET sock) {
ep_sock_t* sock_info = ep_port_find_socket(port_info, sock);
if (sock_info == NULL)
return -1;
@ -86,7 +86,7 @@ static int _ep_ctl_del(ep_port_t* port_info, uintptr_t socket) {
int epoll_ctl(epoll_t port_handle,
int op,
uintptr_t socket,
SOCKET sock,
struct epoll_event* ev) {
ep_port_t* port_info = (ep_port_t*) port_handle;
@ -95,11 +95,11 @@ int epoll_ctl(epoll_t port_handle,
switch (op) {
case EPOLL_CTL_ADD:
return _ep_ctl_add(port_info, socket, ev);
return _ep_ctl_add(port_info, sock, ev);
case EPOLL_CTL_MOD:
return _ep_ctl_mod(port_info, socket, ev);
return _ep_ctl_mod(port_info, sock, ev);
case EPOLL_CTL_DEL:
return _ep_ctl_del(port_info, socket);
return _ep_ctl_del(port_info, sock);
}
return_error(-1, ERROR_INVALID_PARAMETER);