1 /* 2 * queue.h, queue 3 * 4 * Copyright (c) 2009-2010 Wind River Systems, Inc. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef __QUEUE_H 20 #define __QUEUE_H 21 22 #include "list.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 struct queue { 29 struct list *head; 30 struct list *tail; 31 int length; 32 }; 33 34 void __queue_init(struct queue *queue); 35 struct queue *queue_alloc(void); 36 /* FIXME */ 37 inline void __queue_free(struct queue *queue); 38 /* FIXME */ 39 void queue_free_all(struct queue *queue); 40 41 void __queue_push_head(struct queue *queue, struct list *entry); 42 int queue_push_head(struct queue *queue, void *data); 43 void __queue_push_tail(struct queue *queue, struct list *entry); 44 int queue_push_tail(struct queue *queue, void *data); 45 46 struct list *__queue_pop_head(struct queue *queue); 47 void *queue_pop_head(struct queue *queue); 48 struct list *__queue_pop_tail(struct queue *queue); 49 void *queue_pop_tail(struct queue *queue); 50 51 inline struct list *__queue_peek_head(struct queue *queue); 52 inline struct list *__queue_peek_tail(struct queue *queue); 53 inline void *queue_peek_head(struct queue *queue); 54 inline void *queue_peek_tail(struct queue *queue); 55 56 int queue_length(struct queue *queue); 57 58 #ifdef __cplusplus 59 } /* extern "C" */ 60 #endif 61 62 #endif /* __QUEUE_H */ 63