/**
 * Gets up to size bytes from the ring buffer and puts the data into
 * the given buffer.
 * @param buff Buffer to put the data copied out.  If NULL, the data is
 * simply discarded from the buffer.
 * @param size The maximum amount of data to copy out.  Note that if
 * the data is a string it will not be NULL terminated.  Caller is
 * responsible for that.
 */
size_t ring_buffer_get(struct ring_buff *rb, void *buff,
                       const size_t size)
{
        const size_t bytes = ring_buffer_peek(rb, buff, size);
        rb->tail = get_new_ptr_val(rb, rb->tail, bytes);
        return bytes;
}
Beispiel #2
0
inline ssize_t
RingBuffer::Peek(size_t offset, void* buffer, size_t length) const
{
	if (fBuffer == NULL)
		return B_NO_MEMORY;

	return ring_buffer_peek(fBuffer, offset, (uint8*)buffer, length);
}
Beispiel #3
0
static struct ring_buffer_event *
_stp_peek_next_event(struct _stp_iterator *iter, int cpu, u64 *ts)
{
	struct ring_buffer_event *event;

	_stp_ring_buffer_disable_cpu();
	if (iter->buffer_iter[cpu])
		event = ring_buffer_iter_peek(iter->buffer_iter[cpu], ts);
	else
#ifdef STAPCONF_RING_BUFFER_LOST_EVENTS
		event = ring_buffer_peek(_stp_relay_data.rb, cpu, ts, NULL);
#else
		event = ring_buffer_peek(_stp_relay_data.rb, cpu, ts);
#endif
	_stp_ring_buffer_enable_cpu();
	return event;
}
static PyObject *
Buffer_peek_read(Buffer *self, PyObject *args, PyObject *kwargs)
{
    int count_bytes;
    char *kwlist[] = {"length", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &count_bytes))
        return NULL;

    int bytes_available_for_read = ring_buffer_count_bytes (self->buffer);
    if (bytes_available_for_read < count_bytes) {
        PyErr_SetString (InsufficientDataError, "Not enough data to read from");
        return NULL;
    }

    PyObject *datagram = PyString_FromStringAndSize(NULL, count_bytes);
    ring_buffer_peek (self->buffer, PyString_AsString(datagram), count_bytes);

    return datagram;
}
struct ring_buffer_event *autoconf_test(void)
{
    /* last field is not always there */
    return ring_buffer_peek(NULL, 1, NULL, NULL);
}
Beispiel #6
0
		virtual size_t Read(size_t offset, void* buffer, size_t size) const
		{
			return ring_buffer_peek(fBuffer, offset, buffer, size);
		}
Beispiel #7
0
char ring_buffer_pop(struct RingBuffer *ring_buffer) {
  char result = ring_buffer_peek(ring_buffer);
  ring_buffer->head++;
  ring_buffer->head %= ring_buffer->size;
  return result;
}