James Kuszmaul | 82f6c04 | 2021-01-17 11:30:16 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file epoll.c epoll specific routines |
| 3 | * |
| 4 | * Copyright (C) 2010 Creytiv.com |
| 5 | */ |
| 6 | #include <unistd.h> |
| 7 | #include <sys/epoll.h> |
| 8 | #include <re_types.h> |
| 9 | #include <re_mbuf.h> |
| 10 | #include <re_sys.h> |
| 11 | #include "main.h" |
| 12 | |
| 13 | |
| 14 | #define DEBUG_MODULE "epoll" |
| 15 | #define DEBUG_LEVEL 5 |
| 16 | #include <re_dbg.h> |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * Check for working epoll() kernel support |
| 21 | * |
| 22 | * @return true if support, false if not |
| 23 | */ |
| 24 | bool epoll_check(void) |
| 25 | { |
| 26 | uint32_t osrel; |
| 27 | int err, epfd; |
| 28 | |
| 29 | err = sys_rel_get(&osrel, NULL, NULL, NULL); |
| 30 | if (err) |
| 31 | return false; |
| 32 | |
| 33 | if (osrel < 0x020542) { |
| 34 | DEBUG_INFO("epoll not supported in osrel=0x%08x\n", osrel); |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | #ifdef OPENWRT |
| 39 | /* epoll is working again with 2.6.25.7 */ |
| 40 | if (osrel < 0x020619) { |
| 41 | DEBUG_NOTICE("epoll is broken in osrel=0x%08x\n", osrel); |
| 42 | return false; |
| 43 | } |
| 44 | #endif |
| 45 | |
| 46 | epfd = epoll_create(64); |
| 47 | if (-1 == epfd) { |
| 48 | DEBUG_NOTICE("epoll_create: %m\n", errno); |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | (void)close(epfd); |
| 53 | |
| 54 | return true; |
| 55 | } |