From 52a7d015cd2a0dc7b97b2a28964f5f9dffdc528f Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 7 Aug 2011 16:36:32 +0200 Subject: [PATCH] shm: Add ability to add uint64 tags on buffers --- sys/shm/shmpipe.c | 24 ++++++++++++++++++++++-- sys/shm/shmpipe.h | 8 +++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c index c629ea05c2..583aa3846a 100644 --- a/sys/shm/shmpipe.c +++ b/sys/shm/shmpipe.c @@ -78,7 +78,6 @@ enum }; typedef struct _ShmArea ShmArea; -typedef struct _ShmBuffer ShmBuffer; struct _ShmArea { @@ -112,6 +111,8 @@ struct _ShmBuffer int num_clients; int clients[0]; + + uint64_t tag; }; @@ -542,7 +543,7 @@ sp_writer_free_block (ShmBlock * block) /* Returns the number of client this has successfully been sent to */ int -sp_writer_send_buf (ShmPipe * self, char *buf, size_t size) +sp_writer_send_buf (ShmPipe * self, char *buf, size_t size, uint64_t tag) { ShmArea *area = NULL; unsigned long offset = 0; @@ -577,6 +578,7 @@ sp_writer_send_buf (ShmPipe * self, char *buf, size_t size) sb->size = size; sb->num_clients = self->num_clients; sb->ablock = ablock; + sb->tag = tag; for (client = self->clients; client; client = client->next) { struct CommandBuffer cb = { 0 }; @@ -892,3 +894,21 @@ sp_writer_get_path (ShmPipe * pipe) { return pipe->socket_path; } + +ShmBuffer * +sp_writer_get_pending_buffers (ShmPipe * self) +{ + return self->buffers; +} + +ShmBuffer * +sp_writer_get_next_buffer (ShmBuffer * buffer) +{ + return buffer->next; +} + +uint64_t +sp_writer_buf_get_tag (ShmBuffer * buffer) +{ + return buffer->tag; +} diff --git a/sys/shm/shmpipe.h b/sys/shm/shmpipe.h index 9cf0d6c61c..eef8877d14 100644 --- a/sys/shm/shmpipe.h +++ b/sys/shm/shmpipe.h @@ -63,6 +63,7 @@ #define __SHMPIPE_H__ #include +#include #include #include #include @@ -75,6 +76,7 @@ extern "C" { typedef struct _ShmClient ShmClient; typedef struct _ShmPipe ShmPipe; typedef struct _ShmBlock ShmBlock; +typedef struct _ShmBuffer ShmBuffer; ShmPipe *sp_writer_create (const char *path, size_t size, mode_t perms); const char *sp_writer_get_path (ShmPipe *pipe); @@ -90,7 +92,7 @@ int sp_writer_get_client_fd (ShmClient * client); ShmBlock *sp_writer_alloc_block (ShmPipe * self, size_t size); void sp_writer_free_block (ShmBlock *block); -int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size); +int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size, uint64_t tag); char *sp_writer_block_get_buf (ShmBlock *block); ShmPipe *sp_writer_block_get_pipe (ShmBlock *block); @@ -104,6 +106,10 @@ ShmPipe *sp_client_open (const char *path); long int sp_client_recv (ShmPipe * self, char **buf); int sp_client_recv_finish (ShmPipe * self, char *buf); +ShmBuffer *sp_writer_get_pending_buffers (ShmPipe * self); +ShmBuffer *sp_writer_get_next_buffer (ShmBuffer * buffer); +uint64_t sp_writer_buf_get_tag (ShmBuffer * buffer); + #ifdef __cplusplus } #endif