Imported Upstream version 3.2.2
[debian/gnuradio] / gcell / include / gcell / gc_jd_stack.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef INCLUDED_GCELL_GC_JD_STACK_H
23 #define INCLUDED_GCELL_GC_JD_STACK_H
24
25 #include <gcell/gc_types.h>
26 #include <gcell/gc_job_desc.h>
27
28 __GC_BEGIN_DECLS
29
30 /*!
31  * \brief Lock free stack for job descriptors (used for free list)
32  *
33  * This is aligned to a cache line, and fills the cache line,
34  * to avoid inadvertently losing reservations created with
35  * the load-and-reserve instructions.
36  */
37
38 typedef struct gc_jd_stack
39 {
40   gc_eaddr_t    top;
41
42   // pad out to a full cache line
43   uint8_t       _pad[128 - sizeof(gc_eaddr_t)];
44 } _AL128 gc_jd_stack_t;
45
46
47 /*!
48  * \brief Initialize the stack to empty.
49  */
50 void 
51 gc_jd_stack_init(gc_jd_stack_t *stack);
52   
53
54 /*!
55  * \brief Add \p item to the top of \p stack.
56  */
57 void 
58 gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item);
59
60
61 /*!
62  * \brief pop and return top item on stack, or 0 if stack is empty
63  */
64 gc_job_desc_t *
65 gc_jd_stack_pop(gc_jd_stack_t *stack);
66
67 __GC_END_DECLS
68
69
70 #endif /* INCLUDED_GCELL_GC_JD_STACK_H */