Update of /cvsroot/pure-data/externals/grill/flext/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12862/source
Modified Files:
flatom.cpp flstdc.h flsupport.h
Removed Files:
flatom_app.cpp
Log Message:
optimized AtomList functions
no more static assignment of symbols (problems with Metrowerks)
fixed bugs in SIMD code for non-power-of-2 lengths
install flcontainers.h
small update of linkage styles etc.
new: FLEXT_WARN, FLEXT_ERROR macros
Index: flatom.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flatom.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** flatom.cpp 15 Mar 2005 04:56:34 -0000 1.13
--- flatom.cpp 22 Mar 2005 04:56:28 -0000 1.14
***************
*** 49,61 ****
}
! void flext::AtomList::Alloc(int sz)
{
if(lst) {
if(cnt == sz) return; // no change
delete[] lst;
}
! else
FLEXT_ASSERT(cnt == 0);
! lst = new t_atom[cnt = sz];
}
--- 49,78 ----
}
! static void copyatoms(int cnt,t_atom *dst,const t_atom *src)
! {
! if(dst < src)
! // forward
! memcpy(dst,src,cnt*sizeof(t_atom));
! else
! // backwards
! while(cnt--) dst[cnt] = src[cnt];
! }
!
! void flext::AtomList::Alloc(int sz,int keepix,int keeplen,int keepto)
{
if(lst) {
if(cnt == sz) return; // no change
+
+ t_atom *l = new t_atom[sz];
+ if(keepix >= 0)
+ // keep contents
+ copyatoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),l+keepto,lst+keepix);
delete[] lst;
+ lst = l,cnt = sz;
}
! else {
FLEXT_ASSERT(cnt == 0);
! lst = new t_atom[cnt = sz];
! }
}
***************
*** 77,84 ****
if(resize) Alloc(ncnt);
! // argv can be NULL indepently from argc
! if(argv)
! for(int i = 0; i < argc; ++i)
! SetAtom(lst[offs+i],argv[i]);
return *this;
--- 94,99 ----
if(resize) Alloc(ncnt);
! // argv can be NULL independently from argc
! if(argv) copyatoms(argc,lst+offs,argv);
return *this;
***************
*** 89,93 ****
if(Count() == a.Count()) {
for(int i = 0; i < Count(); ++i) {
! int cmp = CmpAtom((*this)[i],a[i]);
if(cmp) return cmp;
}
--- 104,108 ----
if(Count() == a.Count()) {
for(int i = 0; i < Count(); ++i) {
! int cmp = CmpAtom(lst[i],a[i]);
if(cmp) return cmp;
}
***************
*** 100,107 ****
flext::AtomListStaticBase::~AtomListStaticBase() { Free(); }
! void flext::AtomListStaticBase::Alloc(int sz)
{
! if(sz < precnt) lst = predata,cnt = sz;
! else AtomList::Alloc(sz);
}
--- 115,131 ----
flext::AtomListStaticBase::~AtomListStaticBase() { Free(); }
! void flext::AtomListStaticBase::Alloc(int sz,int keepix,int keeplen,int keepto)
{
! if(sz < precnt) {
! if(lst != predata && lst) {
! if(keepix >= 0)
! // keep contents
! copyatoms(keeplen >= 0?keeplen:(cnt > sz?sz:cnt),predata+keepto,lst+keepix);
! AtomList::Free();
! }
! lst = predata,cnt = sz;
! }
! else
! AtomList::Alloc(sz,keepix,keeplen,keepto);
}
Index: flstdc.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flstdc.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** flstdc.h 8 Jan 2005 04:58:31 -0000 1.32
--- flstdc.h 22 Mar 2005 04:56:28 -0000 1.33
***************
*** 27,30 ****
--- 27,36 ----
#endif
+ #ifdef FLEXT_DEBUG
+ #if FLEXT_OS == FLEXT_OS_WIN
+ #include <crtdbg.h>
+ #endif
+ #endif
+
// PD stuff
***************
*** 224,229 ****
#ifdef FLEXT_LOGGING
-
/* If FLEXT_LOGGING is defined implement logging */
#define FLEXT_LOG(s) post(s)
#define FLEXT_LOG1(s,v1) post(s,v1)
--- 230,247 ----
#ifdef FLEXT_LOGGING
/* If FLEXT_LOGGING is defined implement logging */
+
+ #if FLEXT_OS == FLEXT_OS_WIN
+ #define FLEXT_LOG(s) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s)
+ #define FLEXT_LOG1(s,v1) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1)
+ #define FLEXT_LOG2(s,v1,v2) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2)
+ #define FLEXT_LOG3(s,v1,v2,v3) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3)
+ #define FLEXT_LOG4(s,v1,v2,v3,v4) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4)
+ #define FLEXT_LOG5(s,v1,v2,v3,v4,v5) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5)
+ #define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6)
+ #define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7)
+ #define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7,v8)
+ #define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",s,v1,v2,v3,v4,v5,v6,v7,v8,v9)
+ #else
#define FLEXT_LOG(s) post(s)
#define FLEXT_LOG1(s,v1) post(s,v1)
***************
*** 232,236 ****
#define FLEXT_LOG4(s,v1,v2,v3,v4) post(s,v1,v2,v3,v4)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) post(s,v1,v2,v3,v4,v5)
!
#else
--- 250,258 ----
#define FLEXT_LOG4(s,v1,v2,v3,v4) post(s,v1,v2,v3,v4)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) post(s,v1,v2,v3,v4,v5)
! #define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) post(s,v1,v2,v3,v4,v5,v6)
! #define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) post(s,v1,v2,v3,v4,v5,v6,v7)
! #define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) post(s,v1,v2,v3,v4,v5,v6,v7,v8)
! #define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) post(s,v1,v2,v3,v4,v5,v6,v7,v8,v9)
! #endif
#else
***************
*** 243,253 ****
--- 265,289 ----
#define FLEXT_LOG4(s,v1,v2,v3,v4) ((void)0)
#define FLEXT_LOG5(s,v1,v2,v3,v4,v5) ((void)0)
+ #define FLEXT_LOG6(s,v1,v2,v3,v4,v5,v6) ((void)0)
+ #define FLEXT_LOG7(s,v1,v2,v3,v4,v5,v6,v7) ((void)0)
+ #define FLEXT_LOG8(s,v1,v2,v3,v4,v5,v6,v7,v8) ((void)0)
+ #define FLEXT_LOG9(s,v1,v2,v3,v4,v5,v6,v7,v8,v9) ((void)0)
#endif
#ifdef FLEXT_DEBUG
+ #if FLEXT_OS == FLEXT_OS_WIN
+ #define FLEXT_ASSERT(b) (!(b)?_CrtDbgReport(_CRT_ASSERT,__FILE__,__LINE__,"flext",#b):1)
+ #define FLEXT_WARN(str) _CrtDbgReport(_CRT_WARN,__FILE__,__LINE__,"flext",NULL)
+ #define FLEXT_ERROR(str) _CrtDbgReport(_CRT_ERROR,__FILE__,__LINE__,"flext",NULL)
+ #else
#define FLEXT_ASSERT(b) (!(b)?(error("Assertion failed: " #b " - in " __FILE__ " line %i",(int)__LINE__),0):1)
+ #define FLEXT_WARN(str) error("Warning: in " __FILE__ " line %i",(int)__LINE__)
+ #define FLEXT_ERROR(str) error("Error: in " __FILE__ " line %i",(int)__LINE__)
+ #endif
#else
#define FLEXT_ASSERT(b) (1)
+ #define FLEXT_WARN(str) (1)
+ #define FLEXT_ERROR(str) error("Error: in " __FILE__ " line %i",(int)__LINE__)
#endif
--- flatom_app.cpp DELETED ---
Index: flsupport.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/flext/source/flsupport.h,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** flsupport.h 18 Mar 2005 04:56:27 -0000 1.84
--- flsupport.h 22 Mar 2005 04:56:29 -0000 1.85
***************
*** 35,42 ****
// --- console output -----------------------------------------------
! //! post message to console, with line feed (limited to 1k chars!)
! static void post(const char *fmt,...);
! //! post error message to console (limited to 1k chars!)
! static void error(const char *fmt,...);
// --- memory -------------------------------------------------------
--- 35,42 ----
// --- console output -----------------------------------------------
! //! post message to console, with line feed (limited to 1k chars!)
! static void post(const char *fmt,...);
! //! post error message to console (limited to 1k chars!)
! static void error(const char *fmt,...);
// --- memory -------------------------------------------------------
***************
*** 46,76 ****
*/
! /*! Overloaded new memory allocation method
! \note this uses a fast allocation method of the real-time system
! \warning Max/MSP (or MacOS) allows only 32K in overdrive mode!
! */
! void *operator new(size_t bytes);
! //! Overloaded delete method
! void operator delete(void *blk);
! inline void *operator new(size_t,void *p) { return p; }
! inline void operator delete(void *,void *) {}
! #ifndef __MRC__ // doesn't allow new[] overloading?!
! inline void *operator new[](size_t bytes) { return operator new(bytes); }
! inline void operator delete[](void *blk) { operator delete(blk); }
! inline void *operator new[](size_t,void *p) { return p; }
! inline void operator delete[](void *,void *) {}
! #endif
! //! Get an aligned memory block
! static void *NewAligned(size_t bytes,int bitalign = 128);
! //! Free an aligned memory block
! static void FreeAligned(void *blk);
! //! Test for alignment
! static bool IsAligned(void *ptr,int bitalign = 128) {
! return (reinterpret_cast<size_t>(ptr)&(bitalign-1)) == 0;
! }
//! @} FLEXT_S_MEMORY
};
--- 46,76 ----
*/
! /*! Overloaded new memory allocation method
! \note this uses a fast allocation method of the real-time system
! \warning Max/MSP (or MacOS) allows only 32K in overdrive mode!
! */
! void *operator new(size_t bytes);
! //! Overloaded delete method
! void operator delete(void *blk);
! inline void *operator new(size_t,void *p) { return p; }
! inline void operator delete(void *,void *) {}
! #ifndef __MRC__ // doesn't allow new[] overloading?!
! inline void *operator new[](size_t bytes) { return operator new(bytes); }
! inline void operator delete[](void *blk) { operator delete(blk); }
! inline void *operator new[](size_t,void *p) { return p; }
! inline void operator delete[](void *,void *) {}
! #endif
! //! Get an aligned memory block
! static void *NewAligned(size_t bytes,int bitalign = 128);
! //! Free an aligned memory block
! static void FreeAligned(void *blk);
! //! Test for alignment
! static bool IsAligned(void *ptr,int bitalign = 128) {
! return (reinterpret_cast<size_t>(ptr)&(bitalign-1)) == 0;
! }
//! @} FLEXT_S_MEMORY
};
***************
*** 141,144 ****
--- 141,152 ----
static const char *VersionStr();
+ // --- special typedefs ---------------------------------------------
+
+ typedef t_float Float;
+ typedef t_int Int;
+ typedef t_sample Sample;
+ typedef const t_symbol *Symbol;
+ typedef t_atom Atom;
+
// --- buffer/array stuff -----------------------------------------
***************
*** 594,607 ****
const t_atom *Atoms() const { return lst; }
- //! Append an atom to the list
- AtomList &Append(const t_atom &a);
- //! Append an atom list to the list
- AtomList &Append(int argc,const t_atom *argv = NULL);
//! Append an atom list to the list
AtomList &Append(const AtomList &a) { return Append(a.Count(),a.Atoms()); }
//! Prepend an atom to the list
! AtomList &Prepend(const t_atom &a);
! //! Prepend an atom list to the list
! AtomList &Prepend(int argc,const t_atom *argv = NULL);
//! Prepend an atom list to the list
AtomList &Prepend(const AtomList &a) { return Prepend(a.Count(),a.Atoms()); }
--- 602,629 ----
const t_atom *Atoms() const { return lst; }
//! Append an atom list to the list
+ AtomList &Append(int argc,const t_atom *argv = NULL)
+ {
+ int c = Count();
+ Alloc(c+argc,0,c);
+ Set(argc,argv,c);
+ return *this;
+ }
+
+ //! Prepend an atom list to the list
+ AtomList &Prepend(int argc,const t_atom *argv = NULL)
+ {
+ int c = Count();
+ Alloc(c+argc,0,c,argc);
+ Set(argc,argv);
+ return *this;
+ }
+
+ //! Append an atom to the list
+ AtomList &Append(const t_atom &a) { return Append(1,&a); }
+ //! Append an atom list to the list
AtomList &Append(const AtomList &a) { return Append(a.Count(),a.Atoms()); }
//! Prepend an atom to the list
! AtomList &Prepend(const t_atom &a) { return Prepend(1,&a); }
//! Prepend an atom list to the list
AtomList &Prepend(const AtomList &a) { return Prepend(a.Count(),a.Atoms()); }
***************
*** 616,620 ****
protected:
! virtual void Alloc(int sz);
virtual void Free();
--- 638,642 ----
protected:
! virtual void Alloc(int sz,int keepix = -1,int keeplen = -1,int keepto = 0);
virtual void Free();
***************
*** 629,633 ****
AtomListStaticBase(int pc,t_atom *dt): precnt(pc),predata(dt) {}
virtual ~AtomListStaticBase();
! virtual void Alloc(int sz);
virtual void Free();
--- 651,655 ----
AtomListStaticBase(int pc,t_atom *dt): precnt(pc),predata(dt) {}
virtual ~AtomListStaticBase();
! virtual void Alloc(int sz,int keepix = -1,int keeplen = -1,int keepto = 0);
virtual void Free();
***************
*** 1196,1205 ****
// gcc doesn't like these to be included into the flext class (even if static)
! inline bool operator ==(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) == 0; }
! inline bool operator !=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) != 0; }
! inline bool operator <(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) < 0; }
! inline bool operator <=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) <= 0; }
! inline bool operator >(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) > 0; }
! inline bool operator >=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) >= 0; }
//! @} // FLEXT_SUPPORT
--- 1218,1227 ----
// gcc doesn't like these to be included into the flext class (even if static)
! inline bool operator ==(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) == 0; }
! inline bool operator !=(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) != 0; }
! inline bool operator <(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) < 0; }
! inline bool operator <=(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) <= 0; }
! inline bool operator >(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) > 0; }
! inline bool operator >=(const t_atom &a,const t_atom &b) { return flext::CmpAtom(a,b) >= 0; }
//! @} // FLEXT_SUPPORT