diff options
author | Dimitri Staessens <dimitri.staessens@ugent.be> | 2017-11-08 19:25:48 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-11-08 21:40:28 +0100 |
commit | 35c43358a110758090b48dd18628bb285ffddfc6 (patch) | |
tree | 9746475ac579e516e86f720a3bcb107bf6e36784 /src/lib/shm_rdrbuff.c | |
parent | c59053040ce927f2926e5a569b19bdd129c354a7 (diff) | |
download | ouroboros-35c43358a110758090b48dd18628bb285ffddfc6.tar.gz ouroboros-35c43358a110758090b48dd18628bb285ffddfc6.zip |
lib: Use packed struct for FRCT header access
This replaces the variable FRCT header with a packed struct, which
significantly simplifies the implementation. The shm_du_buff calls to
release the head/tail are updated to return a pointer to the original
head or the new tail (in symmetry to the alloc calls, which return a
pointer to the new head and old tail), so that it immediately points
to the structure that is needed.
The frct_pci sources are removed and frct is now fully in the frct.c
source file.
Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be>
Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/lib/shm_rdrbuff.c')
-rw-r--r-- | src/lib/shm_rdrbuff.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c index a3333a35..2853d5bb 100644 --- a/src/lib/shm_rdrbuff.c +++ b/src/lib/shm_rdrbuff.c @@ -602,8 +602,6 @@ uint8_t * shm_du_buff_tail(struct shm_du_buff * sdb) uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb, size_t size) { - uint8_t * buf = NULL; - assert(sdb); if (sdb->du_head < size) @@ -611,15 +609,13 @@ uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb, sdb->du_head -= size; - buf = (uint8_t *) (sdb + 1) + sdb->du_head; - - return buf; + return (uint8_t *) (sdb + 1) + sdb->du_head; } uint8_t * shm_du_buff_tail_alloc(struct shm_du_buff * sdb, size_t size) { - uint8_t * buf = NULL; + uint8_t * buf; assert(sdb); @@ -633,22 +629,30 @@ uint8_t * shm_du_buff_tail_alloc(struct shm_du_buff * sdb, return buf; } -void shm_du_buff_head_release(struct shm_du_buff * sdb, - size_t size) +uint8_t * shm_du_buff_head_release(struct shm_du_buff * sdb, + size_t size) { + uint8_t * buf; + assert(sdb); assert(!(size > sdb->du_tail - sdb->du_head)); + buf = (uint8_t *) (sdb + 1) + sdb->du_head; + sdb->du_head += size; + + return buf; } -void shm_du_buff_tail_release(struct shm_du_buff * sdb, +uint8_t * shm_du_buff_tail_release(struct shm_du_buff * sdb, size_t size) { assert(sdb); assert(!(size > sdb->du_tail - sdb->du_head)); sdb->du_tail -= size; + + return (uint8_t *) (sdb + 1) + sdb->du_tail; } void shm_du_buff_truncate(struct shm_du_buff * sdb, |