|
@@ -67,9 +67,13 @@ struct io_buffer {
|
67
|
67
|
static inline void * iob_reserve ( struct io_buffer *iobuf, size_t len ) {
|
68
|
68
|
iobuf->data += len;
|
69
|
69
|
iobuf->tail += len;
|
70
|
|
- assert ( iobuf->tail <= iobuf->end );
|
71
|
70
|
return iobuf->data;
|
72
|
71
|
}
|
|
72
|
+#define iob_reserve( iobuf, len ) ( { \
|
|
73
|
+ void *__result; \
|
|
74
|
+ __result = iob_reserve ( (iobuf), (len) ); \
|
|
75
|
+ assert ( (iobuf)->tail <= (iobuf)->end ); \
|
|
76
|
+ __result; } )
|
73
|
77
|
|
74
|
78
|
/**
|
75
|
79
|
* Add data to start of I/O buffer
|
|
@@ -80,9 +84,13 @@ static inline void * iob_reserve ( struct io_buffer *iobuf, size_t len ) {
|
80
|
84
|
*/
|
81
|
85
|
static inline void * iob_push ( struct io_buffer *iobuf, size_t len ) {
|
82
|
86
|
iobuf->data -= len;
|
83
|
|
- assert ( iobuf->data >= iobuf->head );
|
84
|
87
|
return iobuf->data;
|
85
|
88
|
}
|
|
89
|
+#define iob_push( iobuf, len ) ( { \
|
|
90
|
+ void *__result; \
|
|
91
|
+ __result = iob_push ( (iobuf), (len) ); \
|
|
92
|
+ assert ( (iobuf)->data >= (iobuf)->head ); \
|
|
93
|
+ __result; } )
|
86
|
94
|
|
87
|
95
|
/**
|
88
|
96
|
* Remove data from start of I/O buffer
|
|
@@ -96,6 +104,11 @@ static inline void * iob_pull ( struct io_buffer *iobuf, size_t len ) {
|
96
|
104
|
assert ( iobuf->data <= iobuf->tail );
|
97
|
105
|
return iobuf->data;
|
98
|
106
|
}
|
|
107
|
+#define iob_pull( iobuf, len ) ( { \
|
|
108
|
+ void *__result; \
|
|
109
|
+ __result = iob_pull ( (iobuf), (len) ); \
|
|
110
|
+ assert ( (iobuf)->data <= (iobuf)->tail ); \
|
|
111
|
+ __result; } )
|
99
|
112
|
|
100
|
113
|
/**
|
101
|
114
|
* Add data to end of I/O buffer
|
|
@@ -107,9 +120,13 @@ static inline void * iob_pull ( struct io_buffer *iobuf, size_t len ) {
|
107
|
120
|
static inline void * iob_put ( struct io_buffer *iobuf, size_t len ) {
|
108
|
121
|
void *old_tail = iobuf->tail;
|
109
|
122
|
iobuf->tail += len;
|
110
|
|
- assert ( iobuf->tail <= iobuf->end );
|
111
|
123
|
return old_tail;
|
112
|
124
|
}
|
|
125
|
+#define iob_put( iobuf, len ) ( { \
|
|
126
|
+ void *__result; \
|
|
127
|
+ __result = iob_put ( (iobuf), (len) ); \
|
|
128
|
+ assert ( (iobuf)->tail <= (iobuf)->end ); \
|
|
129
|
+ __result; } )
|
113
|
130
|
|
114
|
131
|
/**
|
115
|
132
|
* Remove data from end of I/O buffer
|
|
@@ -119,8 +136,11 @@ static inline void * iob_put ( struct io_buffer *iobuf, size_t len ) {
|
119
|
136
|
*/
|
120
|
137
|
static inline void iob_unput ( struct io_buffer *iobuf, size_t len ) {
|
121
|
138
|
iobuf->tail -= len;
|
122
|
|
- assert ( iobuf->tail >= iobuf->data );
|
123
|
139
|
}
|
|
140
|
+#define iob_unput( iobuf, len ) do { \
|
|
141
|
+ iob_unput ( (iobuf), (len) ); \
|
|
142
|
+ assert ( (iobuf)->tail >= (iobuf)->data ); \
|
|
143
|
+ } while ( 0 )
|
124
|
144
|
|
125
|
145
|
/**
|
126
|
146
|
* Empty an I/O buffer
|