projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tests: Introduce test_ust_constructor
[lttng-tools.git]
/
src
/
common
/
compat
/
poll.cpp
diff --git
a/src/common/compat/poll.cpp
b/src/common/compat/poll.cpp
index 0617905a6ee65e37656956b650a41838cb9e1393..52ff0467681e45c416c028715c379b3397084ee9 100644
(file)
--- a/
src/common/compat/poll.cpp
+++ b/
src/common/compat/poll.cpp
@@
-7,22
+7,22
@@
*/
#define _LGPL_SOURCE
*/
#define _LGPL_SOURCE
-#include <stdlib.h>
-#include <stdbool.h>
+#include "poll.hpp"
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/utils.hpp>
#include <common/defaults.hpp>
#include <common/error.hpp>
#include <common/macros.hpp>
#include <common/utils.hpp>
-#include "poll.hpp"
+#include <stdbool.h>
+#include <stdlib.h>
#ifdef HAVE_EPOLL
#include <fcntl.h>
#include <limits.h>
#ifdef HAVE_EPOLL
#include <fcntl.h>
#include <limits.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
/*
#include <unistd.h>
/*
@@
-42,22
+42,20
@@
static unsigned int poll_max_size;
*
* Return 0 on success or else -1 with the current events pointer untouched.
*/
*
* Return 0 on success or else -1 with the current events pointer untouched.
*/
-static int resize_poll_event(struct lttng_poll_event *events,
- uint32_t new_size)
+static int resize_poll_event(struct lttng_poll_event *events, uint32_t new_size)
{
struct epoll_event *ptr;
LTTNG_ASSERT(events);
ptr = (epoll_event *) realloc(events->events, new_size * sizeof(*ptr));
{
struct epoll_event *ptr;
LTTNG_ASSERT(events);
ptr = (epoll_event *) realloc(events->events, new_size * sizeof(*ptr));
- if (ptr ==
NULL
) {
+ if (ptr ==
nullptr
) {
PERROR("realloc epoll add");
goto error;
}
if (new_size > events->alloc_size) {
/* Zero newly allocated memory */
PERROR("realloc epoll add");
goto error;
}
if (new_size > events->alloc_size) {
/* Zero newly allocated memory */
- memset(ptr + events->alloc_size, 0,
- (new_size - events->alloc_size) * sizeof(*ptr));
+ memset(ptr + events->alloc_size, 0, (new_size - events->alloc_size) * sizeof(*ptr));
}
events->events = ptr;
events->alloc_size = new_size;
}
events->events = ptr;
events->alloc_size = new_size;
@@
-75,7
+73,7
@@
int compat_epoll_create(struct lttng_poll_event *events, int count, int flags)
{
int ret;
{
int ret;
- if (events ==
NULL
|| count <= 0) {
+ if (events ==
nullptr
|| count <= 0) {
goto error;
}
goto error;
}
@@
-101,7
+99,7
@@
int compat_epoll_create(struct lttng_poll_event *events, int count, int flags)
/* This *must* be freed by using lttng_poll_free() */
events->events = calloc<epoll_event>(count);
/* This *must* be freed by using lttng_poll_free() */
events->events = calloc<epoll_event>(count);
- if (events->events ==
NULL
) {
+ if (events->events ==
nullptr
) {
PERROR("zmalloc epoll set");
goto error_close;
}
PERROR("zmalloc epoll set");
goto error_close;
}
@@
-128,7
+126,7
@@
int compat_epoll_add(struct lttng_poll_event *events, int fd, uint32_t req_event
int ret;
struct epoll_event ev;
int ret;
struct epoll_event ev;
- if (events ==
NULL || events->events == NULL
|| fd < 0) {
+ if (events ==
nullptr || events->events == nullptr
|| fd < 0) {
ERR("Bad compat epoll add arguments");
goto error;
}
ERR("Bad compat epoll add arguments");
goto error;
}
@@
-174,11
+172,11
@@
int compat_epoll_del(struct lttng_poll_event *events, int fd)
{
int ret;
{
int ret;
- if (events ==
NULL
|| fd < 0 || events->nb_fd == 0) {
+ if (events ==
nullptr
|| fd < 0 || events->nb_fd == 0) {
goto error;
}
goto error;
}
- ret = epoll_ctl(events->epfd, EPOLL_CTL_DEL, fd,
NULL
);
+ ret = epoll_ctl(events->epfd, EPOLL_CTL_DEL, fd,
nullptr
);
if (ret < 0) {
switch (errno) {
case ENOENT:
if (ret < 0) {
switch (errno) {
case ENOENT:
@@
-209,7
+207,7
@@
int compat_epoll_mod(struct lttng_poll_event *events, int fd, uint32_t req_event
int ret;
struct epoll_event ev;
int ret;
struct epoll_event ev;
- if (events ==
NULL
|| fd < 0 || events->nb_fd == 0) {
+ if (events ==
nullptr
|| fd < 0 || events->nb_fd == 0) {
goto error;
}
goto error;
}
@@
-245,13
+243,12
@@
error:
/*
* Wait on epoll set. This is a blocking call of timeout value.
*/
/*
* Wait on epoll set. This is a blocking call of timeout value.
*/
-int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
- bool interruptible)
+int compat_epoll_wait(struct lttng_poll_event *events, int timeout, bool interruptible)
{
int ret;
uint32_t new_size;
{
int ret;
uint32_t new_size;
- if (events ==
NULL || events->events == NULL
) {
+ if (events ==
nullptr || events->events == nullptr
) {
ERR("Wrong arguments in compat_epoll_wait");
goto error;
}
ERR("Wrong arguments in compat_epoll_wait");
goto error;
}
@@
-299,7
+296,7
@@
error:
/*
* Setup poll set maximum size.
*/
/*
* Setup poll set maximum size.
*/
-int compat_epoll_set_max_size(
void
)
+int compat_epoll_set_max_size()
{
int ret, fd, retval = 0;
ssize_t size_ret;
{
int ret, fd, retval = 0;
ssize_t size_ret;
@@
-362,8
+359,7
@@
static unsigned int poll_max_size;
*
* Return 0 on success or else -1 with the current events pointer untouched.
*/
*
* Return 0 on success or else -1 with the current events pointer untouched.
*/
-static int resize_poll_event(struct compat_poll_event_array *array,
- uint32_t new_size)
+static int resize_poll_event(struct compat_poll_event_array *array, uint32_t new_size)
{
struct pollfd *ptr;
{
struct pollfd *ptr;
@@
-381,8
+377,7
@@
static int resize_poll_event(struct compat_poll_event_array *array,
}
if (new_size > array->alloc_size) {
/* Zero newly allocated memory */
}
if (new_size > array->alloc_size) {
/* Zero newly allocated memory */
- memset(ptr + array->alloc_size, 0,
- (new_size - array->alloc_size) * sizeof(*ptr));
+ memset(ptr + array->alloc_size, 0, (new_size - array->alloc_size) * sizeof(*ptr));
}
array->events = ptr;
array->alloc_size = new_size;
}
array->events = ptr;
array->alloc_size = new_size;
@@
-413,8
+408,7
@@
static int update_current_events(struct lttng_poll_event *events)
goto error;
}
}
goto error;
}
}
- memcpy(wait->events, current->events,
- current->nb_fd * sizeof(*current->events));
+ memcpy(wait->events, current->events, current->nb_fd * sizeof(*current->events));
/* Update is done. */
events->need_update = 0;
/* Update is done. */
events->need_update = 0;
@@
-455,17
+449,17
@@
int compat_poll_create(struct lttng_poll_event *events, int size)
wait = &events->wait;
/* This *must* be freed by using lttng_poll_free() */
wait = &events->wait;
/* This *must* be freed by using lttng_poll_free() */
- wait->events =
(struct pollfd *) zmalloc(size * sizeof(struct pollfd)
);
+ wait->events =
calloc<struct pollfd>(size
);
if (wait->events == NULL) {
if (wait->events == NULL) {
- PERROR("
zmalloc struct pollfd
");
+ PERROR("
Failed to allocate wait events array during poll initialization
");
goto error;
}
wait->alloc_size = wait->init_size = size;
goto error;
}
wait->alloc_size = wait->init_size = size;
- current->events =
(struct pollfd *) zmalloc(size * sizeof(struct pollfd)
);
+ current->events =
calloc<struct pollfd>(size
);
if (current->events == NULL) {
if (current->events == NULL) {
- PERROR("
zmalloc struct current pollfd
");
+ PERROR("
Failed to allocate current events array during poll initialization
");
goto error;
}
goto error;
}
@@
-480,8
+474,7
@@
error:
/*
* Add fd to pollfd data structure with requested events.
*/
/*
* Add fd to pollfd data structure with requested events.
*/
-int compat_poll_add(struct lttng_poll_event *events, int fd,
- uint32_t req_events)
+int compat_poll_add(struct lttng_poll_event *events, int fd, uint32_t req_events)
{
int new_size, ret, i;
struct compat_poll_event_array *current;
{
int new_size, ret, i;
struct compat_poll_event_array *current;
@@
-526,14
+519,13
@@
error:
/*
* Modify an fd's events..
*/
/*
* Modify an fd's events..
*/
-int compat_poll_mod(struct lttng_poll_event *events, int fd,
- uint32_t req_events)
+int compat_poll_mod(struct lttng_poll_event *events, int fd, uint32_t req_events)
{
int i;
struct compat_poll_event_array *current;
{
int i;
struct compat_poll_event_array *current;
- if (events == NULL || events->current.nb_fd == 0 ||
-
events->current.events == NULL ||
fd < 0) {
+ if (events == NULL || events->current.nb_fd == 0 ||
events->current.events == NULL ||
+ fd < 0) {
ERR("Bad compat poll mod arguments");
goto error;
}
ERR("Bad compat poll mod arguments");
goto error;
}
@@
-568,8
+560,8
@@
int compat_poll_del(struct lttng_poll_event *events, int fd)
uint32_t new_size;
struct compat_poll_event_array *current;
uint32_t new_size;
struct compat_poll_event_array *current;
- if (events == NULL || events->current.nb_fd == 0 ||
-
events->current.events == NULL ||
fd < 0) {
+ if (events == NULL || events->current.nb_fd == 0 ||
events->current.events == NULL ||
+ fd < 0) {
goto error;
}
goto error;
}
@@
-596,8
+588,8
@@
int compat_poll_del(struct lttng_poll_event *events, int fd)
/* Resize array if needed. */
new_size = 1U << utils_get_count_order_u32(current->nb_fd);
/* Resize array if needed. */
new_size = 1U << utils_get_count_order_u32(current->nb_fd);
- if (new_size != current->alloc_size && new_size >= current->init_size
-
&&
current->nb_fd != 0) {
+ if (new_size != current->alloc_size && new_size >= current->init_size
&&
+ current->nb_fd != 0) {
ret = resize_poll_event(current, new_size);
if (ret < 0) {
goto error;
ret = resize_poll_event(current, new_size);
if (ret < 0) {
goto error;
@@
-616,8
+608,7
@@
error:
/*
* Wait on poll() with timeout. Blocking call.
*/
/*
* Wait on poll() with timeout. Blocking call.
*/
-int compat_poll_wait(struct lttng_poll_event *events, int timeout,
- bool interruptible)
+int compat_poll_wait(struct lttng_poll_event *events, int timeout, bool interruptible)
{
int ret, active_fd_count;
size_t pos = 0, consecutive_entries = 0, non_idle_pos;
{
int ret, active_fd_count;
size_t pos = 0, consecutive_entries = 0, non_idle_pos;
@@
-675,7
+666,8
@@
int compat_poll_wait(struct lttng_poll_event *events, int timeout,
non_idle_pos = pos;
/* Look for next non-idle entry. */
non_idle_pos = pos;
/* Look for next non-idle entry. */
- while (events->wait.events[++non_idle_pos].revents == 0);
+ while (events->wait.events[++non_idle_pos].revents == 0)
+ ;
/* Swap idle and non-idle entries. */
idle_entry = *current;
/* Swap idle and non-idle entries. */
idle_entry = *current;
This page took
0.026984 seconds
and
4
git commands to generate.