]> git.sur5r.net Git - i3/i3/blob - include/shmlog.h
Make comment style more consistent
[i3/i3] / include / shmlog.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * The format of the shmlog data structure which i3 development versions use by
8  * default (ringbuffer for storing the debug log).
9  *
10  */
11 #pragma once
12
13 #include <config.h>
14
15 #include <stdint.h>
16 #if !defined(__OpenBSD__)
17 #include <pthread.h>
18 #endif
19
20 /* Default shmlog size if not set by user. */
21 extern const int default_shmlog_size;
22
23 /**
24  * Header of the shmlog file. Used by i3/src/log.c and i3/i3-dump-log/main.c.
25  *
26  */
27 typedef struct i3_shmlog_header {
28     /* Byte offset where the next line will be written to. */
29     uint32_t offset_next_write;
30
31     /* Byte offset where the last wrap occurred. */
32     uint32_t offset_last_wrap;
33
34     /* The size of the logfile in bytes. Since the size is limited to 25 MiB
35      * an uint32_t is sufficient. */
36     uint32_t size;
37
38     /* wrap counter. We need it to reliably signal to clients that we just
39      * wrapped (clients cannot use offset_last_wrap because that might
40      * coincidentally be exactly the same as previously). Overflows can happen
41      * and don’t matter — clients use an equality check (==). */
42     uint32_t wrap_count;
43
44 #if !defined(__OpenBSD__)
45     /* pthread condvar which will be broadcasted whenever there is a new
46      * message in the log. i3-dump-log uses this to implement -f (follow, like
47      * tail -f) in an efficient way. */
48     pthread_cond_t condvar;
49 #endif
50 } i3_shmlog_header;