-/* Copyright (c) 2008, 2009 Nicira, Inc.
+/* Copyright (c) 2008, 2009, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <config.h>
#include "byteq.h"
-#include <assert.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
void
byteq_put(struct byteq *q, uint8_t c)
{
- assert(!byteq_is_full(q));
+ ovs_assert(!byteq_is_full(q));
*byteq_head(q) = c;
q->head++;
}
byteq_putn(struct byteq *q, const void *p_, size_t n)
{
const uint8_t *p = p_;
- assert(byteq_avail(q) >= n);
+ ovs_assert(byteq_avail(q) >= n);
while (n > 0) {
size_t chunk = MIN(n, byteq_headroom(q));
memcpy(byteq_head(q), p, chunk);
byteq_get(struct byteq *q)
{
uint8_t c;
- assert(!byteq_is_empty(q));
+ ovs_assert(!byteq_is_empty(q));
c = *byteq_tail(q);
q->tail++;
return c;
if (n > 0) {
byteq_advance_tail(q, n);
} else {
- assert(n < 0);
+ ovs_assert(n < 0);
return errno;
}
}
void
byteq_advance_tail(struct byteq *q, unsigned int n)
{
- assert(byteq_tailroom(q) >= n);
+ ovs_assert(byteq_tailroom(q) >= n);
q->tail += n;
}
void
byteq_advance_head(struct byteq *q, unsigned int n)
{
- assert(byteq_headroom(q) >= n);
+ ovs_assert(byteq_headroom(q) >= n);
q->head += n;
}