rem: int32 position = buffer->first + buffer->in;
add: int32 position = (buffer->first + buffer->in) % buffer->size;
context: write_to_buffer(struct ring_buffer *buffer, const uint8 *data, ssize_t length,	bool user){	int32 left = space_left_in_buffer(buffer);	if (length > left)		length = left;	if (length == 0)		return 0;	ssize_t bytesWritten = length;	int32 position = buffer->first + buffer->in;	if (position + length <= buffer->size) {		// simple copy		if (user) {			if (user_memcpy(buffer->buffer + position, data, length) < B_OK)				return B_BAD_ADDRESS;		} else			memcpy(buffer->buffer + position, data, length);	} else {		// need to copy both ends		size_t upper = buffer->size - position;		size_t lower = length - upper;		if (user) {			if (user_memcpy(buffer->buffer + position, data, upper) < B_OK				|| user_memcpy(buffer->buffer, data + upper, lower) < B_OK)				return B_BAD_ADDRESS;		} else {			memcpy(buffer->buffer + position, data, upper);			memcpy(buffer->buffer, data + upper, lower);		}	}	buffer->in += bytesWritten;	return bytesWritten;}