From 3e90874e5d63137c195c3b3c1ce90b542deb8a51 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sun, 27 Feb 2005 04:56:10 +0000 Subject: small name change and reuse of Fifo cells fixed eol-style new lock-free lifo and fifo fixes for linux eliminated ChannelsIn/ChannelsOut updated docs build system: added profiler mode, more fixes fix for linux autodetection of build platform fix for flext_dsp @ Max svn path=/trunk/; revision=2584 --- externals/grill/flext/source/flcontainers.h | 46 +++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'externals/grill/flext/source/flcontainers.h') diff --git a/externals/grill/flext/source/flcontainers.h b/externals/grill/flext/source/flcontainers.h index 562bbf64..14d793de 100644 --- a/externals/grill/flext/source/flcontainers.h +++ b/externals/grill/flext/source/flcontainers.h @@ -21,15 +21,6 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flprefix.h" -class Cell -{ - friend class Lifo; - friend class Fifo; -private: - Cell *link; -}; - - #if 1 //def __Pentium__ #define VTYPE volatile #else @@ -42,6 +33,14 @@ private: class FLEXT_SHARE Lifo { public: + class Cell + { + friend class Lifo; + friend class Fifo; + private: + Cell *link; + }; + inline Lifo() { Init(); } inline void Init() { ic = oc = 0; top = NULL; } @@ -113,7 +112,7 @@ public: } inline size_t Size() const { return ic-oc; } -#elif defined(__GNUC__) && defined(__) +#elif defined(__GNUC__) && (defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__)) #ifndef SMPLOCK # ifdef __SMP__ # define SMPLOCK "lock ; " @@ -145,7 +144,7 @@ public: inline Cell *Pop() { - cell* v=0; + Cell *v=0; __asm__ __volatile__ ( "# LFPOP \n\t" "pushl %%ebx \n\t" @@ -171,7 +170,7 @@ public: return v; } - inline size_t Size() + inline size_t Size() const { size_t n; __asm__ __volatile__ ( @@ -258,10 +257,22 @@ private: #endif }; +template +class TypedLifo + : public Lifo +{ +public: + inline T *Avail() { return static_cast(Lifo::Avail()); } + inline void Push(T *c) { Lifo::Push(static_cast(c)); } + inline T *Pop() { return static_cast(Lifo::Pop()); } +}; + class FLEXT_SHARE Fifo { public: + typedef Lifo::Cell Cell; + void Init() { in.Init(); out.Init(); } inline size_t Size() const { return in.Size()+out.Size(); } @@ -311,5 +322,16 @@ public: Lifo in,out; }; +template +class TypedFifo + : public Fifo +{ +public: + inline T *Avail() { return static_cast(Fifo::Avail()); } + inline void Put(T *c) { Fifo::Put(static_cast(c)); } + inline T *Get() { return static_cast(Fifo::Get()); } + inline T *Clear() { return static_cast(Fifo::Clear()); } +}; + #endif -- cgit v1.2.1