forked from nicupavel/emlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emlog.h
51 lines (42 loc) · 1.9 KB
/
emlog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* EMLOG: the EMbedded-device LOGger
*
* Jeremy Elson <[email protected]>
* USC/Information Sciences Institute
*
* Modified By:
* Andreas Neustifter <andreas.neustifter at gmail.com>
* Andriy Stepanov <stanv at altlinux.ru>
* Nicu Pavel <npavel at mini-box.com>
* Darien Kindlund <kindlund at mitre.org>
* This code is released under the GPL
*
* This is emlog version 0.41, released 13 August 2001, modified 21 February 2005
* For more information see http://www.circlemud.org/~jelson/software/emlog
*
* $Id: emlog.h,v 1.6 2001/08/13 21:29:20 jelson Exp $
*/
#define EMLOG_MAX_SIZE 8192 /* max size in kilobytes of a buffer */
#define DEVICE_NAME "emlog"
#define EMLOG_VERSION "0.52"
/************************ Private Definitions *****************************/
struct emlog_info {
wait_queue_head_t read_q;
unsigned long i_ino; /* Inode number of this emlog buffer */
dev_t i_rdev; /* Device number of this emlog buffer */
char *data; /* The circular buffer data */
size_t size; /* Size of the buffer pointed to by 'data' */
int refcount; /* Files that have this buffer open */
size_t read_point; /* Offset in circ. buffer of oldest data */
size_t write_point; /* Offset in circ. buffer of newest data */
loff_t offset; /* Byte number of read_point in the stream */
struct emlog_info *next;
};
/* amount of data in the queue */
#define EMLOG_QLEN(einfo) ( (einfo)->write_point >= (einfo)->read_point ? \
(einfo)->write_point - (einfo)->read_point : \
(einfo)->size - (einfo)->read_point + (einfo)->write_point)
/* byte number of the last byte in the queue */
#define EMLOG_FIRST_EMPTY_BYTE(einfo) ((einfo)->offset + EMLOG_QLEN(einfo))
/* macro to make it more convenient to access the wait q */
#define EMLOG_READQ(einfo) (&((einfo)->read_q))