Browse Source

Add iob_ensure_headroom() placeholder.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
564ac70a42
1 changed files with 19 additions and 0 deletions
  1. 19
    0
      src/include/gpxe/iobuf.h

+ 19
- 0
src/include/gpxe/iobuf.h View File

9
 
9
 
10
 #include <stdint.h>
10
 #include <stdint.h>
11
 #include <assert.h>
11
 #include <assert.h>
12
+#include <errno.h>
12
 #include <gpxe/list.h>
13
 #include <gpxe/list.h>
13
 
14
 
14
 /**
15
 /**
161
 	return ( iobuf->end - iobuf->tail );
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
 extern struct io_buffer * alloc_iob ( size_t len );
183
 extern struct io_buffer * alloc_iob ( size_t len );
165
 extern void free_iob ( struct io_buffer *iobuf );
184
 extern void free_iob ( struct io_buffer *iobuf );
166
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
185
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );

Loading…
Cancel
Save