Update of /cvsroot/pure-data/externals/grill/flext/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10955/source
Modified Files: flcontainers.h Log Message: introduce compile time error reporting for architectures not supported Lifos and Fifos with reservoir
Index: flcontainers.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/flext/source/flcontainers.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** flcontainers.h 27 Feb 2005 04:56:10 -0000 1.2 --- flcontainers.h 6 Mar 2005 04:56:00 -0000 1.3 *************** *** 13,16 **** --- 13,17 ----
This code has been adapted from the MidiShare project (c)Grame + http://midishare.sourceforge.net */
*************** *** 22,31 ****
! #if 1 //def __Pentium__ ! #define VTYPE volatile ! #else ! #define VTYPE ! #endif ! #define __SMP__
--- 23,28 ----
! // define that precautiously... ! // it's faster without that but we can't really know... #define __SMP__
*************** *** 48,52 **** inline Cell *Avail() { return (Cell *)top; }
! #if defined(_WIN32) && defined(_MSC_VER) #ifdef __SMP__ #define LOCK lock --- 45,49 ---- inline Cell *Avail() { return (Cell *)top; }
! #if defined(_MSC_VER) && (defined(_WIN32)) #ifdef __SMP__ #define LOCK lock *************** *** 113,117 ****
inline size_t Size() const { return ic-oc; } ! #elif defined(__GNUC__) && (defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__)) #ifndef SMPLOCK # ifdef __SMP__ --- 110,114 ----
inline size_t Size() const { return ic-oc; } ! #elif defined(__GNUC__) && (defined(_X86_) || defined(__i386__)) #ifndef SMPLOCK # ifdef __SMP__ *************** *** 184,187 **** --- 181,188 ---- return n; } + #elif defined(__GNUC__) && defined(__x86_64__) + + #error x86-64 architecture not supported yet + #elif defined(__GNUC__) && defined(__POWERPC__) inline void Push(register Cell *cl) *************** *** 245,255 ****
inline size_t Size() const { return oc; } #endif
private: // don't change order! ! VTYPE size_t ic; // input (push) count ! VTYPE Cell *top; // top of the stack ! VTYPE size_t oc; // output (pop) count #ifdef __POWERPC__ size_t unused[5]; // lifo size must be at least 32 bytes --- 246,258 ----
inline size_t Size() const { return oc; } + #else + #error Platform not supported #endif
private: // don't change order! ! volatile size_t ic; // input (push) count ! volatile Cell *top; // top of the stack ! volatile size_t oc; // output (pop) count #ifdef __POWERPC__ size_t unused[5]; // lifo size must be at least 32 bytes *************** *** 268,271 **** --- 271,285 ---- };
+ template <typename T> + class PooledLifo + : public TypedLifo<T> + { + public: + inline T *New() { T *n = reuse.Pop(); return n?n:new T; } + inline Free(T *p) { if(reuse.Size() < Size()) reuse.Push(p); else delete p; } + private: + TypedLifo<T> reuse; + }; +
class FLEXT_SHARE Fifo *************** *** 334,337 **** --- 348,361 ---- };
+ template <typename T> + class PooledFifo + : public TypedFifo<T> + { + public: + inline T *New() { T *n = reuse.Pop(); return n?n:new T; } + inline Free(T *p) { if(reuse.Size() < Size()) reuse.Push(p); else delete p; } + private: + TypedLifo<T> reuse; + };
#endif