|
@@ -9,6 +9,7 @@
|
9
|
9
|
|
10
|
10
|
#include <stdint.h>
|
11
|
11
|
#include <assert.h>
|
|
12
|
+#include <errno.h>
|
12
|
13
|
#include <gpxe/list.h>
|
13
|
14
|
|
14
|
15
|
/**
|
|
@@ -161,6 +162,24 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) {
|
161
|
162
|
return ( iobuf->end - iobuf->tail );
|
162
|
163
|
}
|
163
|
164
|
|
|
165
|
+/**
|
|
166
|
+ * Ensure I/O buffer has sufficient headroom
|
|
167
|
+ *
|
|
168
|
+ * @v iobuf I/O buffer
|
|
169
|
+ * @v len Required headroom
|
|
170
|
+ *
|
|
171
|
+ * This function currently only checks for the required headroom; it
|
|
172
|
+ * does not reallocate the I/O buffer if required. If we ever have a
|
|
173
|
+ * code path that requires this functionality, it's a fairly trivial
|
|
174
|
+ * change to make.
|
|
175
|
+ */
|
|
176
|
+static inline __attribute__ (( always_inline )) int
|
|
177
|
+iob_ensure_headroom ( struct io_buffer *iobuf, size_t len ) {
|
|
178
|
+ if ( iob_headroom ( iobuf ) >= len )
|
|
179
|
+ return 0;
|
|
180
|
+ return -ENOBUFS;
|
|
181
|
+}
|
|
182
|
+
|
164
|
183
|
extern struct io_buffer * alloc_iob ( size_t len );
|
165
|
184
|
extern void free_iob ( struct io_buffer *iobuf );
|
166
|
185
|
extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
|