/*
 * Copyright (C) 2012-2019, Samsung Electronics Co., Ltd.
 *
 * Support epoll routines.
 */

#ifndef _TZSL_SYS_EPOLL_H_
#define _TZSL_SYS_EPOLL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <compiler.h>
//#include <core/epoll.h>
//#include <signal.h>
#define EPOLLIN                 (1U << 0)
#define EPOLLOUT                (1U << 1)
#define EPOLLPRI                (1U << 2)
#define EPOLLRDNORM             EPOLLIN
#define EPOLLWRNORM             EPOLLOUT
#define EPOLLRDBAND             (1U << 3)
#define EPOLLWRBAND             (1U << 4)

#define EPOLLERR                (1U << 5)
#define EPOLLHUP                (1U << 6)
#define EPOLLRDHUP              (1U << 7)

#define EPOLLET                 (1U << 30)
#define EPOLLONESHOT            (1U << 31)

enum {
        EPOLL_CTL_ADD,
        EPOLL_CTL_DEL,
        EPOLL_CTL_MOD
};


typedef union epoll_data {
        void *ptr;
        int fd;
        uint32_t u32;
        uint64_t u64;
} epoll_data_t;

struct epoll_event {
        uint32_t events;
        epoll_data_t data;
} __attribute__((packed));

int __must_check __attribute__((weak)) epoll_create(int size);
int __must_check __attribute__((weak)) epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
int __must_check __attribute__((weak)) epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);

#ifdef __cplusplus
}
#endif

#endif /* _TZSL_SYS_EPOLL_H_ */
