Line data Source code
1 : /* 2 : * vr_queue.c -- queue implementation for vrouter 3 : * 4 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 5 : */ 6 : #include <vr_os.h> 7 : #include "vr_queue.h" 8 : 9 : void 10 0 : vr_queue_init(struct vr_qhead *head) 11 : { 12 0 : head->q_first = NULL; 13 0 : return; 14 : } 15 : 16 : void 17 2863 : vr_queue_enqueue(struct vr_qhead *head, struct vr_qelem *p) 18 : { 19 2863 : struct vr_qelem *elem = head->q_first; 20 : 21 2863 : p->q_next = NULL; 22 : 23 2863 : if (!elem) { 24 2862 : head->q_first = p; 25 2862 : return; 26 : } 27 : 28 1 : while (elem && elem->q_next) 29 0 : elem = elem->q_next; 30 : 31 1 : elem->q_next = p; 32 1 : return; 33 : } 34 : 35 : struct vr_qelem * 36 5725 : vr_queue_dequeue(struct vr_qhead *head) 37 : { 38 5725 : struct vr_qelem *elem = head->q_first; 39 : 40 5725 : if (elem) 41 2863 : head->q_first = elem->q_next; 42 : 43 5725 : return elem; 44 : } 45 : 46 : bool 47 5726 : vr_queue_empty(struct vr_qhead *head) 48 : { 49 5726 : if (head->q_first) 50 1 : return false; 51 5725 : return true; 52 : }