return right - left;
}
-/* Return the amount of bytes that can be written into the buffer at once,
- * excluding the amount of reserved space passed in <res>, which is
- * preserved.
- */
-static inline int buffer_contig_space_with_res(const struct buffer *buf, int res)
-{
- /* Proceed differently if the buffer is full, partially used or empty.
- * The hard situation is when it's partially used and either data or
- * reserved space wraps at the end.
- */
- int spare = buf->size - res;
-
- if (buffer_len(buf) >= spare)
- spare = 0;
- else if (buffer_len(buf)) {
- spare = buffer_contig_space(buf) - res;
- if (spare < 0)
- spare = 0;
- }
- return spare;
-}
-
-
/* Normalizes a pointer which is supposed to be relative to the beginning of a
* buffer, so that wrapping is correctly handled. The intent is to use this
* when increasing a pointer. Note that the wrapping test is only performed
return chn->buf->size - buffer_reserved(chn);
}
-/* Return the amount of bytes that can be written into the buffer at once,
- * excluding reserved space, which is preserved.
- */
-static inline int buffer_contig_space_res(const struct channel *chn)
-{
- return buffer_contig_space_with_res(chn->buf, buffer_reserved(chn));
-}
-
/* Returns the amount of space available at the input of the buffer, taking the
* reserved space into account if ->to_forward indicates that an end of transfer
* is close to happen. The test is optimized to avoid as many operations as