Fix: libcompat is now part of libcommon
[lttng-tools.git] / src / common / compat / poll.h
index f892c832333eb10bdfcc4cf64d66918c17d3ab02..5379c806aa8e1e3947f98c7b058ca32ad7113cbc 100644 (file)
@@ -73,7 +73,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
        /*
@@ -122,12 +122,13 @@ static inline int __lttng_epoll_get_prev_fd(struct lttng_poll_event *events,
 /*
  * Create the epoll set. No memory allocation is done here.
  */
-extern int compat_epoll_create(struct lttng_poll_event *events,
+LTTNG_HIDDEN
+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,14 +153,16 @@ 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);
+LTTNG_HIDDEN
+int compat_epoll_wait(struct lttng_poll_event *events, int timeout);
 #define lttng_poll_wait(events, timeout) \
        compat_epoll_wait(events, timeout)
 
 /*
  * Add a fd to the epoll set and resize the epoll_event structure if needed.
  */
-extern int compat_epoll_add(struct lttng_poll_event *events,
+LTTNG_HIDDEN
+int compat_epoll_add(struct lttng_poll_event *events,
                int fd, uint32_t req_events);
 #define lttng_poll_add(events, fd, req_events) \
        compat_epoll_add(events, fd, req_events)
@@ -167,14 +170,25 @@ extern int compat_epoll_add(struct lttng_poll_event *events,
 /*
  * Remove a fd from the epoll set.
  */
-extern int compat_epoll_del(struct lttng_poll_event *events, int fd);
+LTTNG_HIDDEN
+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.
+ */
+LTTNG_HIDDEN
+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_add(events, fd, req_events)
+
 /*
  * Set up the poll set limits variable poll_max_size
  */
-extern void compat_epoll_set_max_size(void);
+LTTNG_HIDDEN
+int compat_epoll_set_max_size(void);
 #define lttng_poll_set_max_size() \
        compat_epoll_set_max_size()
 
@@ -217,7 +231,7 @@ static inline void lttng_poll_clean(struct lttng_poll_event *events)
        if (events->epfd >= 0) {
                ret = close(events->epfd);
                if (ret) {
-                       perror("close");
+                       PERROR("close");
                }
        }
 
@@ -254,7 +268,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
@@ -285,8 +299,7 @@ struct compat_poll_event {
         * execution before a poll wait is done.
         */
        struct compat_poll_event_array current;
-       /* Indicate if wait.events needs to be realloc. */
-       int need_realloc:1;
+
        /* Indicate if wait.events need to be updated from current. */
        int need_update:1;
 };
@@ -319,7 +332,8 @@ static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,
 /*
  * Create a pollfd structure of size 'size'.
  */
-extern int compat_poll_create(struct lttng_poll_event *events, int size);
+LTTNG_HIDDEN
+int compat_poll_create(struct lttng_poll_event *events, int size);
 #define lttng_poll_create(events, size, flags) \
        compat_poll_create(events, size)
 
@@ -327,14 +341,16 @@ 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);
+LTTNG_HIDDEN
+int compat_poll_wait(struct lttng_poll_event *events, int timeout);
 #define lttng_poll_wait(events, timeout) \
        compat_poll_wait(events, timeout)
 
 /*
  * Add the fd to the pollfd structure. Resize if needed.
  */
-extern int compat_poll_add(struct lttng_poll_event *events,
+LTTNG_HIDDEN
+int compat_poll_add(struct lttng_poll_event *events,
                int fd, uint32_t req_events);
 #define lttng_poll_add(events, fd, req_events) \
        compat_poll_add(events, fd, req_events)
@@ -344,14 +360,25 @@ extern int compat_poll_add(struct lttng_poll_event *events,
  * pollfd, data is copied from the old pollfd to the new and, finally, the old
  * one is freed().
  */
-extern int compat_poll_del(struct lttng_poll_event *events, int fd);
+LTTNG_HIDDEN
+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 epoll set.
+ */
+LTTNG_HIDDEN
+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_add(events, fd, req_events)
+
 /*
  * Set up the poll set limits variable poll_max_size
  */
-extern void compat_poll_set_max_size(void);
+LTTNG_HIDDEN
+int compat_poll_set_max_size(void);
 #define lttng_poll_set_max_size() \
        compat_poll_set_max_size()
 
This page took 0.028455 seconds and 5 git commands to generate.