X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fpoll.h;h=e2a424abe132d564769d69de28aba40b50512324;hb=a0377dfefe40662ba7d68617bce6ff467114136c;hp=4b2fc5036843c5863047125a8c1d79085405b34f;hpb=5a12931eca4ae292cc659222d5da12b9b7480808;p=lttng-tools.git diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h index 4b2fc5036..e2a424abe 100644 --- a/src/common/compat/poll.h +++ b/src/common/compat/poll.h @@ -1,43 +1,18 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _LTT_POLL_H #define _LTT_POLL_H -#include #include #include #include -/* - * Maximum number of fd we can monitor. - * - * For epoll(7), /proc/sys/fs/epoll/max_user_watches (since Linux 2.6.28) will - * be used for the maximum size of the poll set. If this interface is not - * available, according to the manpage, the max_user_watches value is 1/25 (4%) - * of the available low memory divided by the registration cost in bytes which - * is 90 bytes on a 32-bit kernel and 160 bytes on a 64-bit kernel. - * - * For poll(2), the max fds must not exceed RLIMIT_NOFILE given by - * getrlimit(2). - */ -extern unsigned int poll_max_size; - /* * Used by lttng_poll_clean to free the events structure in a lttng_poll_event. */ @@ -98,8 +73,8 @@ struct compat_epoll_event { static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events, int index, uint32_t nb_fd) { - assert(events); - assert(index != nb_fd); + LTTNG_ASSERT(events); + LTTNG_ASSERT(index != nb_fd); if (index == 0 || nb_fd == 0) { return -1; @@ -141,7 +116,7 @@ static inline int compat_glibc_epoll_create(int size, int flags) * fcntl(..). */ int efd = epoll_create(size); - assert(fcntl(efd, F_SETFD, flags) != -1); + LTTNG_ASSERT(fcntl(efd, F_SETFD, flags) != -1); return efd; } #endif @@ -150,9 +125,12 @@ static inline int compat_glibc_epoll_create(int size, int flags) * Wait on epoll set with the number of fd registered to the lttng_poll_event * data structure (events). */ -extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout); +extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout, + bool interruptible); #define lttng_poll_wait(events, timeout) \ - compat_epoll_wait(events, timeout) + compat_epoll_wait(events, timeout, false) +#define lttng_poll_wait_interruptible(events, timeout) \ + compat_epoll_wait(events, timeout, true) /* * Add a fd to the epoll set and resize the epoll_event structure if needed. @@ -300,8 +278,8 @@ struct compat_poll_event { static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events, int index, uint32_t nb_fd) { - assert(events); - assert(index != nb_fd); + LTTNG_ASSERT(events); + LTTNG_ASSERT(index != nb_fd); if (index == 0 || nb_fd == 0) { return -1; @@ -334,9 +312,12 @@ extern int compat_poll_create(struct lttng_poll_event *events, int size); * Wait on poll(2) event with nb_fd registered to the lttng_poll_event data * structure. */ -extern int compat_poll_wait(struct lttng_poll_event *events, int timeout); +extern int compat_poll_wait(struct lttng_poll_event *events, int timeout, + bool interruptible); #define lttng_poll_wait(events, timeout) \ - compat_poll_wait(events, timeout) + compat_poll_wait(events, timeout, false) +#define lttng_poll_wait_interruptible(events, timeout) \ + compat_poll_wait(events, timeout, true) /* * Add the fd to the pollfd structure. Resize if needed.