epoll: epoll_create(1) to match linux API more closely

This commit is contained in:
Bert Belder 2017-09-25 19:54:20 +02:00
parent 929ea10ebd
commit 4ea40313be
5 changed files with 20 additions and 6 deletions

View File

@ -60,7 +60,8 @@ struct epoll_event {
extern "C" {
#endif
EPOLL_EXTERN HANDLE epoll_create(void);
EPOLL_EXTERN HANDLE epoll_create(int size);
EPOLL_EXTERN HANDLE epoll_create1(int flags);
EPOLL_EXTERN int epoll_close(HANDLE ephnd);

View File

@ -1,7 +1,6 @@
#include <stdint.h>
#include <stdlib.h>
#include "epoll-socket.h"
#include "epoll.h"
#include "error.h"
#include "init.h"
@ -22,7 +21,7 @@ int epoll_global_init(void) {
return 0;
}
HANDLE epoll_create(void) {
static HANDLE _epoll_create(void) {
ep_port_t* port_info;
HANDLE ephnd;
@ -43,6 +42,20 @@ HANDLE epoll_create(void) {
return ephnd;
}
HANDLE epoll_create(int size) {
if (size <= 0)
return_error(INVALID_HANDLE_VALUE, ERROR_INVALID_PARAMETER);
return _epoll_create();
}
HANDLE epoll_create1(int flags) {
if (flags != 0)
return_error(INVALID_HANDLE_VALUE, ERROR_INVALID_PARAMETER);
return _epoll_create();
}
int epoll_close(HANDLE ephnd) {
reflock_tree_node_t* tree_node;
ep_port_t* port_info;

View File

@ -46,7 +46,7 @@ int main(void) {
r = init();
assert(r == 0);
epfd = epoll_create();
epfd = epoll_create1(0);
assert(epfd != NULL);
for (size_t i = 0; i < NUM_SOCKETS; i++)

View File

@ -70,7 +70,7 @@ static unsigned int __stdcall poll_thread(void* arg) {
sock = (SOCKET) arg;
epfd = epoll_create();
epfd = epoll_create1(0);
assert(epfd != NULL);
ev_in.events = EPOLLIN;

View File

@ -23,7 +23,7 @@ int main(void) {
SOCKET srv;
struct epoll_event ev;
epoll_hnd = epoll_create();
epoll_hnd = epoll_create1(0);
assert(epoll_hnd && epoll_hnd != INVALID_HANDLE_VALUE);
srv = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);