Use shm handle, fix allocation space, take care of alignment
[lttng-ust.git] / libringbuffer / shm.h
index 390a5b26bc2890f996577ebbda3d0dc0303cb726..4e9ced198755809cdf63f8140180eeecfb4ff5bd 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <stdint.h>
 #include "ust/core.h"
+#include "usterr_signal_safe.h"
 
 #define SHM_MAGIC      0x54335433
 #define SHM_MAJOR      0
@@ -39,6 +40,11 @@ struct shm_header {
        DECLARE_SHMP(struct channel, chan);
 };
 
+struct shm_handle {
+       struct shm_header *header;      /* beginning of mapping */
+       int shmfd;                      /* process-local file descriptor */
+};
+
 #define shmp(shm_offset)               \
        ((__typeof__(****(shm_offset))) (((char *) &(shm_offset)) + (ptrdiff_t) (shm_offset)))
 
@@ -68,4 +74,11 @@ void *zalloc_shm(struct shm_header *shm_header, size_t len)
        return ret;
 }
 
+static inline
+void align_shm(struct shm_header *shm_header, size_t align)
+{
+       size_t offset_len = offset_align(shm_header->shm_allocated, align);
+       shm_header->shm_allocated += offset_len;
+}
+
 #endif /* _LIBRINGBUFFER_SHM_H */
This page took 0.02552 seconds and 4 git commands to generate.