Path: blob/master/src/java.base/windows/native/libnio/ch/wepoll.h
41134 views
/*1* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/*26* This file is available under and governed by the GNU General Public27* License version 2 only, as published by the Free Software Foundation.28* However, the following notice accompanied the original version of this29* file and, per its terms, should not be removed:30*31* wepoll - epoll for Windows32* https://github.com/piscisaureus/wepoll33*34* Copyright 2012-2020, Bert Belder <[email protected]>35* All rights reserved.36*37* Redistribution and use in source and binary forms, with or without38* modification, are permitted provided that the following conditions are39* met:40*41* * Redistributions of source code must retain the above copyright42* notice, this list of conditions and the following disclaimer.43*44* * Redistributions in binary form must reproduce the above copyright45* notice, this list of conditions and the following disclaimer in the46* documentation and/or other materials provided with the distribution.47*48* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS49* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT50* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR51* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT52* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,53* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT54* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,55* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY56* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT57* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE58* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.59*/6061#ifndef WEPOLL_H_62#define WEPOLL_H_6364#ifndef WEPOLL_EXPORT65#define WEPOLL_EXPORT66#endif6768#include <stdint.h>6970enum EPOLL_EVENTS {71EPOLLIN = (int) (1U << 0),72EPOLLPRI = (int) (1U << 1),73EPOLLOUT = (int) (1U << 2),74EPOLLERR = (int) (1U << 3),75EPOLLHUP = (int) (1U << 4),76EPOLLRDNORM = (int) (1U << 6),77EPOLLRDBAND = (int) (1U << 7),78EPOLLWRNORM = (int) (1U << 8),79EPOLLWRBAND = (int) (1U << 9),80EPOLLMSG = (int) (1U << 10), /* Never reported. */81EPOLLRDHUP = (int) (1U << 13),82EPOLLONESHOT = (int) (1U << 31)83};8485#define EPOLLIN (1U << 0)86#define EPOLLPRI (1U << 1)87#define EPOLLOUT (1U << 2)88#define EPOLLERR (1U << 3)89#define EPOLLHUP (1U << 4)90#define EPOLLRDNORM (1U << 6)91#define EPOLLRDBAND (1U << 7)92#define EPOLLWRNORM (1U << 8)93#define EPOLLWRBAND (1U << 9)94#define EPOLLMSG (1U << 10)95#define EPOLLRDHUP (1U << 13)96#define EPOLLONESHOT (1U << 31)9798#define EPOLL_CTL_ADD 199#define EPOLL_CTL_MOD 2100#define EPOLL_CTL_DEL 3101102typedef void* HANDLE;103typedef uintptr_t SOCKET;104105typedef union epoll_data {106void* ptr;107int fd;108uint32_t u32;109uint64_t u64;110SOCKET sock; /* Windows specific */111HANDLE hnd; /* Windows specific */112} epoll_data_t;113114struct epoll_event {115uint32_t events; /* Epoll events and flags */116epoll_data_t data; /* User data variable */117};118119#ifdef __cplusplus120extern "C" {121#endif122123WEPOLL_EXPORT HANDLE epoll_create(int size);124WEPOLL_EXPORT HANDLE epoll_create1(int flags);125126WEPOLL_EXPORT int epoll_close(HANDLE ephnd);127128WEPOLL_EXPORT int epoll_ctl(HANDLE ephnd,129int op,130SOCKET sock,131struct epoll_event* event);132133WEPOLL_EXPORT int epoll_wait(HANDLE ephnd,134struct epoll_event* events,135int maxevents,136int timeout);137138#ifdef __cplusplus139} /* extern "C" */140#endif141142#endif /* WEPOLL_H_ */143144145