i3
shmlog.h
Go to the documentation of this file.
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009-2012 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 #ifndef I3_I3_SHMLOG_H
12 #define I3_I3_SHMLOG_H
13 
14 #include <stdint.h>
15 #include <pthread.h>
16 
17 /* Default shmlog size if not set by user. */
18 extern const int default_shmlog_size;
19 
20 /*
21  * Header of the shmlog file. Used by i3/src/log.c and i3/i3-dump-log/main.c.
22  *
23  */
24 typedef struct i3_shmlog_header {
25  /* Byte offset where the next line will be written to. */
27 
28  /* Byte offset where the last wrap occured. */
29  uint32_t offset_last_wrap;
30 
31  /* The size of the logfile in bytes. Since the size is limited to 25 MiB
32  * an uint32_t is sufficient. */
33  uint32_t size;
34 
35  /* wrap counter. We need it to reliably signal to clients that we just
36  * wrapped (clients cannot use offset_last_wrap because that might
37  * coincidentally be exactly the same as previously). Overflows can happen
38  * and don’t matter — clients use an equality check (==). */
39  uint32_t wrap_count;
40 
41  /* pthread condvar which will be broadcasted whenever there is a new
42  * message in the log. i3-dump-log uses this to implement -f (follow, like
43  * tail -f) in an efficient way. */
44  pthread_cond_t condvar;
46 
47 #endif
uint32_t size
Definition: shmlog.h:33
uint32_t wrap_count
Definition: shmlog.h:39
uint32_t offset_last_wrap
Definition: shmlog.h:29
uint32_t offset_next_write
Definition: shmlog.h:26
struct i3_shmlog_header i3_shmlog_header
const int default_shmlog_size
Definition: main.c:72
pthread_cond_t condvar
Definition: shmlog.h:44