Fix: liblttng-ctl: poll compatibility symbols inadvertently exported
[lttng-tools.git] / src / common / compat / poll.h
index 699901848dc14bc52abd22d778b2f55cb189ee57..622f5bde41d04e648507c1b3f03233c67c703cd6 100644 (file)
 
 #include <common/common.h>
 
-/*
- * 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.
  */
@@ -73,7 +59,7 @@ enum {
        LPOLLNVAL = EPOLLHUP,
        LPOLLRDHUP = EPOLLRDHUP,
        /* Close on exec feature of epoll */
-#if __GLIBC_PREREQ(2, 9)
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
        LTTNG_CLOEXEC = EPOLL_CLOEXEC,
 #else
        /*
@@ -119,15 +105,13 @@ static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events,
 #define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
        __lttng_epoll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
 
-/*
- * Create the epoll set. No memory allocation is done here.
- */
+/* Create the epoll set. */
 extern int compat_epoll_create(struct lttng_poll_event *events,
                int size, int flags);
 #define lttng_poll_create(events, size, flags) \
        compat_epoll_create(events, size, flags)
 
-#if __GLIBC_PREREQ(2, 9)
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
 static inline int compat_glibc_epoll_create(int size __attribute__((unused)),
                int flags)
 {
@@ -152,9 +136,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.
@@ -171,6 +158,14 @@ extern int compat_epoll_del(struct lttng_poll_event *events, int fd);
 #define lttng_poll_del(events, fd) \
        compat_epoll_del(events, fd)
 
+/*
+ * Modify an fd's events in the epoll set.
+ */
+extern int compat_epoll_mod(struct lttng_poll_event *events,
+               int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+       compat_epoll_mod(events, fd, req_events)
+
 /*
  * Set up the poll set limits variable poll_max_size
  */
@@ -254,7 +249,7 @@ enum {
 #if __linux__
        LPOLLMSG = POLLMSG,
        LPOLLRDHUP = POLLRDHUP,
-#elif (defined(__FreeBSD__) || defined(__CYGWIN__))
+#elif (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
        LPOLLMSG = 0,
        LPOLLRDHUP = 0,
 #else
@@ -307,10 +302,12 @@ static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,
 /*
  * For the following calls, consider 'e' to be a lttng_poll_event pointer and i
  * being the index of the events array.
+ * LTTNG_POLL_GETNB is always used after lttng_poll_wait, thus we can use the
+ * current list for test compatibility purposes.
  */
 #define LTTNG_POLL_GETFD(e, i) LTTNG_REF(e)->wait.events[i].fd
 #define LTTNG_POLL_GETEV(e, i) LTTNG_REF(e)->wait.events[i].revents
-#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->wait.nb_fd
+#define LTTNG_POLL_GETNB(e) LTTNG_REF(e)->current.nb_fd
 #define LTTNG_POLL_GETSZ(e) LTTNG_REF(e)->wait.events_size
 #define LTTNG_POLL_GET_PREV_FD(e, i, nb_fd) \
        __lttng_poll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
@@ -326,9 +323,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.
@@ -347,6 +347,14 @@ extern int compat_poll_del(struct lttng_poll_event *events, int fd);
 #define lttng_poll_del(events, fd) \
        compat_poll_del(events, fd)
 
+/*
+ * Modify an fd's events in the poll set.
+ */
+extern int compat_poll_mod(struct lttng_poll_event *events,
+               int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+       compat_poll_mod(events, fd, req_events)
+
 /*
  * Set up the poll set limits variable poll_max_size
  */
This page took 0.028359 seconds and 5 git commands to generate.