Fix: libcompat is now part of libcommon
[lttng-tools.git] / src / common / compat / compat-poll.c
index cc280c7640ce4d011904da27fac43712ce1df272..11149f4d46f04b9b55cee2f87c41dd530138ab56 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <sys/resource.h>
 #include <sys/time.h>
+#include <stdbool.h>
 
 #include <common/defaults.h>
 #include <common/error.h>
@@ -101,6 +102,7 @@ error:
 /*
  * Create pollfd data structure.
  */
+LTTNG_HIDDEN
 int compat_poll_create(struct lttng_poll_event *events, int size)
 {
        struct compat_poll_event_array *current, *wait;
@@ -111,8 +113,9 @@ int compat_poll_create(struct lttng_poll_event *events, int size)
        }
 
        if (!poll_max_size) {
-               ERR("poll_max_size not initialized yet");
-               goto error;
+               if (lttng_poll_set_max_size()) {
+                       goto error;
+               }
        }
 
        /* Don't bust the limit here */
@@ -195,9 +198,47 @@ error:
        return -1;
 }
 
+/*
+ * Modify an fd's events..
+ */
+LTTNG_HIDDEN
+int compat_poll_mod(struct lttng_poll_event *events, int fd,
+               uint32_t req_events)
+{
+       int i;
+       bool fd_found = false;
+       struct compat_poll_event_array *current;
+
+       if (events == NULL || events->current.events == NULL || fd < 0) {
+               ERR("Bad compat poll mod arguments");
+               goto error;
+       }
+
+       current = &events->current;
+
+       for (i = 0; i < current->nb_fd; i++) {
+               if (current->events[i].fd == fd) {
+                       fd_found = true;
+                       current->events[i].events = req_events;
+                       events->need_update = 1;
+                       break;
+               }
+       }
+
+       if (!fd_found) {
+               goto error;
+       }
+
+       return 0;
+
+error:
+       return -1;
+}
+
 /*
  * Remove a fd from the pollfd structure.
  */
+LTTNG_HIDDEN
 int compat_poll_del(struct lttng_poll_event *events, int fd)
 {
        int new_size, i, count = 0, ret;
@@ -243,6 +284,7 @@ error:
 /*
  * Wait on poll() with timeout. Blocking call.
  */
+LTTNG_HIDDEN
 int compat_poll_wait(struct lttng_poll_event *events, int timeout)
 {
        int ret;
@@ -290,6 +332,7 @@ error:
 /*
  * Setup poll set maximum size.
  */
+LTTNG_HIDDEN
 int compat_poll_set_max_size(void)
 {
        int ret, retval = 0;
This page took 0.026664 seconds and 5 git commands to generate.