Add PCQ_MAXLEN constant.

This commit is contained in:
rmind 2014-06-09 12:44:06 +00:00
parent 34662ef23f
commit 190a99cba8
2 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_pcq.c,v 1.7 2014/02/06 03:47:16 riastradh Exp $ */
/* $NetBSD: subr_pcq.c,v 1.8 2014/06/09 12:44:06 rmind Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.7 2014/02/06 03:47:16 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.8 2014/06/09 12:44:06 rmind Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -60,6 +60,7 @@ struct pcq {
* Consumer (c) - in the higher 16 bits.
*
* We have a limitation of 16 bits i.e. 0xffff items in the queue.
* The PCQ_MAXLEN constant is set accordingly.
*/
static inline void
@ -197,7 +198,7 @@ pcq_create(size_t nitems, km_flag_t kmflags)
{
pcq_t *pcq;
KASSERT(nitems > 0 || nitems <= 0xffff);
KASSERT(nitems > 0 || nitems <= PCQ_MAXLEN);
pcq = kmem_zalloc(offsetof(pcq_t, pcq_items[nitems]), kmflags);
if (pcq == NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcq.h,v 1.1 2008/11/11 20:17:27 matt Exp $ */
/* $NetBSD: pcq.h,v 1.2 2014/06/09 12:44:06 rmind Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -37,12 +37,16 @@
typedef struct pcq pcq_t;
#ifdef _KERNEL
#define PCQ_MAXLEN (0xffffU)
bool pcq_put(pcq_t *, void *);
void * pcq_peek(pcq_t *);
void * pcq_get(pcq_t *);
size_t pcq_maxitems(pcq_t *);
pcq_t * pcq_create(size_t, km_flag_t);
void pcq_destroy(pcq_t *);
#endif /* _KERNEL */
#endif /* _SYS_PCQ_H_ */