X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fpoll.h;h=75de9ba5fcf0a3ea60cbc086c9c60df3d680f0be;hb=7966af5763c4aaca39df9bbfa9277ff15715c720;hp=0b3cb324341a225ab6ab33c588a170e6d9cc23c4;hpb=9f32e9bf43a6438c55f35d3c5ed1c378d0c715c4;p=lttng-tools.git diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h index 0b3cb3243..75de9ba5f 100644 --- a/src/common/compat/poll.h +++ b/src/common/compat/poll.h @@ -1,42 +1,21 @@ /* - * 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; +#ifdef __cplusplus +extern "C" { +#endif /* * Used by lttng_poll_clean to free the events structure in a lttng_poll_event. @@ -46,6 +25,10 @@ static inline void __lttng_poll_free(void *events) free(events); } +#ifdef __cplusplus +} +#endif + /* * epoll(7) implementation. */ @@ -55,6 +38,10 @@ static inline void __lttng_poll_free(void *events) #include #include +#ifdef __cplusplus +extern "C" { +#endif + /* See man epoll(7) for this define path */ #define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches" @@ -98,8 +85,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 +128,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 @@ -233,6 +220,10 @@ static inline void lttng_poll_clean(struct lttng_poll_event *events) __lttng_poll_free((void *) events->events); } +#ifdef __cplusplus +} +#endif + #else /* HAVE_EPOLL */ /* * Fallback on poll(2) API @@ -251,6 +242,10 @@ static inline void lttng_poll_clean(struct lttng_poll_event *events) #include #include +#ifdef __cplusplus +extern "C" { +#endif + enum { /* Polling variables compatibility for poll */ LPOLLIN = POLLIN, @@ -303,8 +298,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; @@ -402,6 +397,10 @@ static inline void lttng_poll_clean(struct lttng_poll_event *events) } } +#ifdef __cplusplus +} +#endif + #endif /* HAVE_EPOLL */ #endif /* _LTT_POLL_H */