Angband
z-queue.h
Go to the documentation of this file.
1 
19 #ifndef INCLUDED_Z_QUEUE_H
20 #define INCLUDED_Z_QUEUE_H
21 
22 #include "h-basic.h"
23 
24 #if (!defined(HAVE_STDINT_H))
25 /* MSVC doesn't have stdint.h (which is C99), so we'll just
26  * create the right pointer manually. */
27 #ifndef _UINTPTR_T_DEFINED
28 #ifdef UINT_PTR
29 typedef UINT_PTR uintptr_t;
30 #else
31 /* an integer type with enough bits to hold a pointer */
32 typedef unsigned long uintptr_t;
33 #endif
34 #endif
35 #endif
36 
37 struct queue {
39  size_t size;
40  int head;
41  int tail;
42 };
43 
44 struct queue *q_new(size_t size);
45 int q_len(struct queue *q);
46 
47 void q_push(struct queue *q, uintptr_t item);
48 uintptr_t q_pop(struct queue *q);
49 
50 void q_free(struct queue *q);
51 
52 #define q_push_ptr(q, ptr) q_push((q), (uintptr_t)(ptr))
53 #define q_pop_ptr(q) ((void *)(q_pop((q))))
54 
55 #define q_push_int(q, i) q_push((q), (uintptr_t)(i))
56 #define q_pop_int(q) ((int)(q_pop((q))))
57 
58 #endif /* INCLUDED_Z_QUEUE_H */
Definition: z-queue.h:37
void q_push(struct queue *q, uintptr_t item)
Definition: z-queue.c:41
The lowest level header.
int q_len(struct queue *q)
Definition: z-queue.c:31
int tail
Definition: z-queue.h:41
int head
Definition: z-queue.h:40
void q_free(struct queue *q)
Definition: z-queue.c:54
uintptr_t q_pop(struct queue *q)
Definition: z-queue.c:47
struct queue * q_new(size_t size)
Definition: z-queue.c:22
uintptr_t * data
Definition: z-queue.h:38
png_uint_32 size
Definition: libpng12/png.h:1546
size_t size
Definition: z-queue.h:39
unsigned long uintptr_t
Definition: z-queue.h:32