From ca9d60702f11c00f6e04bf47a024279e91aa4729 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 16 Mar 2011 18:51:50 +0000 Subject: [PATCH] shm: Allow ShmPipe to save a data pointer for applications --- sys/shm/shmpipe.c | 13 +++++++++++++ sys/shm/shmpipe.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c index cf3be94..209a13b 100644 --- a/sys/shm/shmpipe.c +++ b/sys/shm/shmpipe.c @@ -120,6 +120,7 @@ struct _ShmPipe int main_socket; char *socket_path; int use_count; + void *data; ShmArea *shm_area; @@ -374,6 +375,18 @@ sp_shm_area_dec (ShmPipe * self, ShmArea * area) } } +void * +sp_get_data (ShmPipe * self) +{ + return self->data; +} + +void +sp_set_data (ShmPipe * self, void *data) +{ + self->data = data; +} + static void sp_inc (ShmPipe * self) { diff --git a/sys/shm/shmpipe.h b/sys/shm/shmpipe.h index a6e092f..c4475b8 100644 --- a/sys/shm/shmpipe.h +++ b/sys/shm/shmpipe.h @@ -75,6 +75,8 @@ typedef struct _ShmBlock ShmBlock; ShmPipe *sp_writer_create (const char *path, size_t size, mode_t perms); const char *sp_writer_get_path (ShmPipe *pipe); void sp_close (ShmPipe * self); +void *sp_get_data (ShmPipe * self); +void sp_set_data (ShmPipe * self, void *data); int sp_writer_setperms_shm (ShmPipe * self, mode_t perms); int sp_writer_resize (ShmPipe * self, size_t size); @@ -86,6 +88,7 @@ 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); char *sp_writer_block_get_buf (ShmBlock *block); +ShmPipe *sp_writer_block_get_pipe (ShmBlock *block); ShmClient * sp_writer_accept_client (ShmPipe * self); void sp_writer_close_client (ShmPipe *self, ShmClient * client); -- 2.7.4