33#include <errno.h>
44#include <netinet/in.h>
55#include <stdbool.h>
6+ #include <stdint.h>
67#include <string.h>
78#include <sys/event.h>
89#include <sys/syscall.h>
910#include <time.h>
1011
1112#include "../../util/signal.h"
13+ #include "../../util/types.h"
1214#include "../../websocket/websocket_local.h"
1315#include "./epoll.h"
1416
15- bool websocket_epoll_add (const int epoll_fd , const int sock_fd , PWebSocketEpollEvent event )
17+ bool websocket_epoll_add (const int32_t epoll_fd , const int32_t sock_fd , PWebSocketEpollEvent event )
1618{
1719 EV_SET (event , sock_fd , EVFILT_READ , EV_ADD , 0 , 0 , NULL );
1820
@@ -35,7 +37,7 @@ bool websocket_epoll_add(const int epoll_fd, const int sock_fd, PWebSocketEpollE
3537 return true;
3638}
3739
38- bool websocket_epoll_del (const int epoll_fd , const int sock_fd )
40+ bool websocket_epoll_del (const int32_t epoll_fd , const int32_t sock_fd )
3941{
4042 struct kevent event ;
4143 EV_SET (& event , sock_fd , EVFILT_READ , EV_DELETE , 0 , 0 , NULL );
@@ -48,9 +50,9 @@ bool websocket_epoll_del(const int epoll_fd, const int sock_fd)
4850 return true;
4951}
5052
51- int websocket_epoll_create ()
53+ int32_t websocket_epoll_create ()
5254{
53- int epoll_fd = kqueue ();
55+ int32_t epoll_fd = kqueue ();
5456 if (epoll_fd == -1 ) {
5557 str_error ("Failed to kqueue(). reason : " , strerror (errno ));
5658 return WEBSOCKET_ERRORCODE_FATAL_ERROR ;
@@ -59,15 +61,15 @@ int websocket_epoll_create()
5961 return epoll_fd ;
6062}
6163
62- int websocket_epoll_wait (const int epoll_fd , PWebSocketEpollEvent events , const int max_events )
64+ int32_t websocket_epoll_wait (const int32_t epoll_fd , PWebSocketEpollEvent events , const int32_t max_events )
6365{
6466 if (is_rise_signal ()) {
6567 log_info ("A signal was raised during kevent(). The system will abort processing.\n" );
6668 return WEBSOCKET_ERRORCODE_FATAL_ERROR ;
6769 }
6870
6971 struct timespec timeout = {0 , 0 }; // Non-blocking
70- int num_of_event = kevent (epoll_fd , NULL , 0 , events , max_events , & timeout );
72+ int32_t num_of_event = kevent (epoll_fd , NULL , 0 , events , max_events , & timeout );
7173
7274 if (num_of_event < 0 ) {
7375 if (errno == EINTR || errno == EAGAIN ) {
@@ -82,12 +84,12 @@ int websocket_epoll_wait(const int epoll_fd, PWebSocketEpollEvent events, const
8284 return num_of_event ;
8385}
8486
85- int websocket_epoll_getfd (PWebSocketEpollEvent event )
87+ int32_t websocket_epoll_getfd (PWebSocketEpollEvent event )
8688{
8789 return event -> ident ;
8890}
8991
90- int websocket_epoll_rise_error (PWebSocketEpollEvent event )
92+ int32_t websocket_epoll_rise_error (PWebSocketEpollEvent event )
9193{
9294 if (event -> flags & EV_ERROR ) {
9395 str_error ("EV_ERROR : " , strerror ((int )event -> data ));
@@ -97,7 +99,7 @@ int websocket_epoll_rise_error(PWebSocketEpollEvent event)
9799 return WEBSOCKET_ERRORCODE_NONE ;
98100}
99101
100- int websocket_epoll_rise_input (PWebSocketEpollEvent event )
102+ int32_t websocket_epoll_rise_input (PWebSocketEpollEvent event )
101103{
102104 if (!(event -> filter | EVFILT_READ )) {
103105 return WEBSOCKET_ERRORCODE_CONTINUABLE_ERROR ;
0 commit comments