Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
nunojsa committed Feb 5, 2025
1 parent a4437a1 commit 7381971
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <errno.h>
#include <iio/iio-lock.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

struct iio_block {
Expand Down Expand Up @@ -169,6 +170,15 @@ int iio_block_enqueue(struct iio_block *block, size_t bytes_used, bool cyclic)
int iio_block_dequeue(struct iio_block *block, bool nonblock)
{
struct iio_buffer *buffer = block->buffer;

if (!buffer)
printf("buffer is NULL\n");
else if (!buffer->dev)
printf("buffer->dev is NULL\n");
else if (!buffer->dev->ctx)
printf("buffer->dev->ctx is NULL\n");
else if (!buffer->dev->ctx->ops)
printf("buffer->dev->ctx->ops is NULL\n");
const struct iio_backend_ops *ops = buffer->dev->ctx->ops;
struct iio_task_token *token;

Expand Down
3 changes: 3 additions & 0 deletions buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <errno.h>
#include <iio/iio-debug.h>
#include <iio/iio-lock.h>
#include <pthread.h>
#include <string.h>

void iio_buffer_set_data(struct iio_buffer *buf, void *data)
Expand Down Expand Up @@ -187,6 +188,8 @@ void iio_buffer_destroy(struct iio_buffer *buf)
{
const struct iio_backend_ops *ops = buf->dev->ctx->ops;

printf("Destroying buffer tsk(%lu)\n", pthread_self());

iio_buffer_cancel(buf);

if (ops->free_buffer)
Expand Down
2 changes: 2 additions & 0 deletions include/iio/iio-lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ __api void iio_task_stop(struct iio_task *task);

__api struct iio_task_token * iio_task_enqueue(struct iio_task *task, void *elm);
__api int iio_task_enqueue_autoclear(struct iio_task *task, void *elm);
__api int iio_task_getname(struct iio_task *task, char *name, size_t size);

__api _Bool iio_task_is_done(struct iio_task_token *token);
__api int iio_task_sync(struct iio_task_token *token, unsigned int timeout_ms);
__api void iio_task_cancel(struct iio_task_token *token);
__api int iio_thread_getname(struct iio_thrd *thrd, char *name, size_t size);

#undef __api

Expand Down
7 changes: 6 additions & 1 deletion lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct iio_thrd * iio_thrd_create(int (*thrd)(void *),
return iio_ptr(ret);
}


printf("Created thread %s(%lu)\n", name, iio_thrd->thid);

return iio_thrd;
}
Expand All @@ -175,3 +175,8 @@ int iio_thrd_join_and_destroy(struct iio_thrd *thrd)

return (int)(intptr_t) retval;
}

int iio_thread_getname(struct iio_thrd *thrd, char *name, size_t size)
{
return pthread_getname_np(thrd->thid, name, size);
}
6 changes: 6 additions & 0 deletions task.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <iio/iio-lock.h>

#include <errno.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdlib.h>

Expand Down Expand Up @@ -205,6 +206,11 @@ int iio_task_enqueue_autoclear(struct iio_task *task, void *elm)
return iio_err(iio_task_do_enqueue(task, elm, true));
}

int iio_task_getname(struct iio_task *task, char *name, size_t size)
{
return iio_thread_getname(task->thrd, name, size);
}

int iio_task_sync(struct iio_task_token *token, unsigned int timeout_ms)
{
int ret;
Expand Down

0 comments on commit 7381971

Please sign in to comment.