Skip to content

Commit 7b65f06

Browse files
sheeazadeemar
authored andcommitted
move msg_head related to fifo.h
struct msg_head related are specific to fifo so move them to fifo.h Signed-off-by: sheeaza <winsdenny@outlook.com>
1 parent c7b940e commit 7b65f06

2 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/fifo.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
#include <stdatomic.h>
55
#include <stdio.h>
66

7+
enum msg_head_flag {
8+
MSG_HEAD_FLAG_RESERVED = 1,
9+
MSG_HEAD_FLAG_COMMITED,
10+
MSG_HEAD_FLAG_DISCARDED,
11+
};
12+
13+
struct msg_head {
14+
unsigned total_size;
15+
atomic_uint flags;
16+
17+
char data[];
18+
};
19+
720
/* todo: optimize page size macro */
821
#define PAGE_SIZE 4096
922

@@ -62,4 +75,9 @@ static inline unsigned int fifo_unused(struct fifo *fifo)
6275
return fifo_size(fifo) - fifo_used(fifo);
6376
}
6477

78+
static inline unsigned int msg_head_size(void)
79+
{
80+
return sizeof(struct msg_head);
81+
}
82+
6583
#endif

src/misc.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <pthread.h>
55
#include <stdalign.h>
6-
#include <stdatomic.h>
76
#include <stddef.h>
87

98
#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
@@ -26,19 +25,6 @@ enum _msg_cmd {
2625
MSG_CMD_FLUSH,
2726
};
2827

29-
enum msg_head_flag {
30-
MSG_HEAD_FLAG_RESERVED = 1,
31-
MSG_HEAD_FLAG_COMMITED,
32-
MSG_HEAD_FLAG_DISCARDED,
33-
};
34-
35-
struct msg_head {
36-
unsigned total_size;
37-
atomic_uint flags;
38-
39-
char data[];
40-
};
41-
4228
struct msg_type {
4329
unsigned long val;
4430
};
@@ -83,11 +69,6 @@ struct zlog_output_data {
8369
} time_str;
8470
};
8571

86-
static inline unsigned int msg_head_size(void)
87-
{
88-
return sizeof(struct msg_head);
89-
}
90-
9172
static inline unsigned int msg_usr_str_size(void)
9273
{
9374
return sizeof(struct msg_usr_str);

0 commit comments

Comments
 (0)