Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/util/circular.h need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef _CIRCULAR_H_
0019 #define _CIRCULAR_H_
0020 #include "types.h"
0021 #include "smp/spinlock.h"
0022 #include "util/circular-defs.h"
0023 
0024 struct _circular 
0025 {
0026   void *buffer, *insert_ptr, *remove_ptr, *buffer_end;
0027   sint32 num_elts, elt_size, cur_count;
0028   sint32 (*insert)(struct _circular *, void *, uint32);
0029   sint32 (*remove)(struct _circular *, void *, uint32);
0030   spinlock lock;
0031   uint16 ins_waitq, rem_waitq;
0032 };
0033 
0034 typedef struct _circular circular;
0035 
0036 static inline sint32
0037 circular_insert (circular *c, void *elt)
0038 {
0039   return c->insert (c, elt, 0);
0040 }
0041 
0042 static inline sint32
0043 circular_insert_nowait (circular *c, void *elt)
0044 {
0045   return c->insert (c, elt, CIRCULAR_FLAG_NOWAIT);
0046 }
0047 
0048 static inline sint32
0049 circular_remove (circular *c, void *out_elt)
0050 {
0051   return c->remove (c, out_elt, 0);
0052 }
0053 
0054 void circular_init (circular *c, void *buffer, sint32 num_elts, sint32 elt_size);
0055 
0056 #endif
0057 
0058 /* 
0059  * Local Variables:
0060  * indent-tabs-mode: nil
0061  * mode: C
0062  * c-file-style: "gnu"
0063  * c-basic-offset: 2
0064  * End: 
0065  */
0066 
0067 /* vi: set et sw=2 sts=2: */