diff options
-rw-r--r-- | externals/grill/flext/build.bat | 22 | ||||
-rw-r--r-- | externals/grill/flext/build.sh | 30 | ||||
-rw-r--r-- | externals/grill/flext/build.txt | 39 | ||||
-rw-r--r-- | externals/grill/flext/changes.txt | 1 | ||||
-rw-r--r-- | externals/grill/flext/notes.txt | 130 | ||||
-rw-r--r-- | externals/grill/flext/source/flcontainers.h | 46 | ||||
-rwxr-xr-x | externals/grill/flext/source/flqueue.cpp | 57 |
7 files changed, 189 insertions, 136 deletions
diff --git a/externals/grill/flext/build.bat b/externals/grill/flext/build.bat index d2fd2fc0..4f97f0cd 100644 --- a/externals/grill/flext/build.bat +++ b/externals/grill/flext/build.bat @@ -18,15 +18,14 @@ rem ------------------------------------------------------------------------ set flext=%~dp0 rem Arguments: -rem %1 - platform (win/lnx/mac) -rem %2 - system (pd/max) -rem %3 - compiler (msvc/gcc/mingw/cygwin/bcc/icc) -rem %4 - target (build/clean/install) +rem %1 - system (pd/max) +rem %2 - compiler (msvc/gcc/mingw/cygwin/bcc/icc) +rem %3 - target (build/clean/install) -set platform=%1 -set rtsys=%2 -set compiler=%3 -set target=%4 +set platform=win +set rtsys=%1 +set compiler=%2 +set target=%3 rem --- The subbatch knowns which make utility to use --- set subbatch=%flext%buildsys\build-%compiler%.bat @@ -37,7 +36,7 @@ if "%compiler%"=="" goto syntax if not exist %subbatch% goto syntax -call %subpatch% %subbatch% %platform% %rtsys% %target% %5 %6 %7 %8 %9 +call %subpatch% %subbatch% %platform% %rtsys% %target% %4 %5 %6 %7 %8 %9 goto end @@ -45,8 +44,7 @@ rem ----------------------------------------- :syntax echo . -echo SYNTAX: build [platform] [system] [compiler] {target} -echo platform ... win / lnx / mac +echo SYNTAX: build [system] [compiler] {target} echo system ... pd / max echo compiler ... msvc / gcc / mingw / cygwin / bcc / icc echo target ... all (default) / clean / install @@ -54,5 +52,7 @@ echo . echo Please make sure that your make program and compiler can be accessed with the echo system path and that all relevant environment variables are properly set. echo . +echo For further information read flext/build.txt +echo . :end diff --git a/externals/grill/flext/build.sh b/externals/grill/flext/build.sh index 307108a4..157ca384 100644 --- a/externals/grill/flext/build.sh +++ b/externals/grill/flext/build.sh @@ -18,15 +18,22 @@ flext=${0%/*}/ if [ "$flext" = "$0"/ ]; then flext=./ ; fi # Arguments: -# $1 - platform (win/lnx/mac) -# $2 - system (pd/max) -# $3 - compiler (msvc/gcc/mingw/cygwin/bcc/icc) -# $4 - target (build/clean/install) +# $1 - system (pd/max) +# $2 - compiler (msvc/gcc/mingw/cygwin/bcc/icc) +# $3 - target (build/clean/install) -platform=$1 -rtsys=$2 -compiler=$3 -target=$4 +unamesys=$(uname -s) + +case $unamesys in + Linux) platform=lnx;; + Darwin) platform=mac;; + CYGWIN*) platform=win;; + *) echo Platform $unamesys not supported; exit;; +esac + +rtsys=$1 +compiler=$2 +target=$3 # --- The subbatch knowns which make utility to use --- subbatch=${flext}buildsys/build-${compiler}.sh @@ -34,11 +41,10 @@ subbatch=${flext}buildsys/build-${compiler}.sh if [ -n "$platform" -a -n "$rtsys" -a -n "$compiler" -a -f $subbatch ] then - bash $subbatch $platform $rtsys $target $5 $6 $7 $8 $9 + bash $subbatch $platform $rtsys $target $4 $5 $6 $7 $8 $9 else echo - echo SYNTAX: build.sh [platform] [system] [compiler] {target} - echo platform ... win / lnx / mac + echo SYNTAX: build.sh [system] [compiler] {target} echo system ..... pd / max echo compiler ... msvc / gcc / mingw / cygwin / bcc / icc echo target ..... build \(default\) / clean / install @@ -46,4 +52,6 @@ else echo Please make sure that your make program and compiler can be accessed with the echo system path and that all relevant environment variables are properly set. echo + echo For further information read flext/build.txt + echo fi diff --git a/externals/grill/flext/build.txt b/externals/grill/flext/build.txt index 56762948..e489a085 100644 --- a/externals/grill/flext/build.txt +++ b/externals/grill/flext/build.txt @@ -42,13 +42,18 @@ flext provides a universal build system which supports Useful combinations of the above are -win pd msvc, using nmake -win pd cygwin, using gnumake -win pd mingw, using gnumake -win max msvc, using nmake -win pd bcc, using bmake -mac pd gcc, using gnumake -mac max gcc, using gnumake - Mach-O externals only (Max 4.5 upwards) +under Windows: +pd msvc, using nmake +pd cygwin, using gnumake +pd mingw, using gnumake +max msvc, using nmake +pd bcc, using bmake + +under Linux or MacOSX: +pd gcc, using gnumake + +under MacOSX: +max gcc, using gnumake - Mach-O externals only (Max 4.5 upwards) There are two central scripts in the flext folder which invoke the building process: @@ -79,18 +84,18 @@ Flext can build itself using the build system. From the flext main directory, run the build script e.g. under Windows - build win pd msvc + build pd msvc or under unix with - bash build.sh lnx pd gcc + bash build.sh pd gcc When you run it for the first time, one or more configuration files will be created from templates - you will get a message on the console. You should edit the files to adapt it to your system. Then install flext with (under Windows) - build win pd msvc install + build pd msvc install or (under unix) - bash build.sh lnx pd gcc install + bash build.sh pd gcc install 1.2) Building externals @@ -103,18 +108,18 @@ In the shell, change to the project folder. Then, simply run the flext build script, e.g. under Windows - ..\flext\build win pd msvc + ..\flext\build pd msvc Then install your newly built external with - ..\flext\build win pd msvc install + ..\flext\build pd msvc install You can clean up the intermediate build folders with - ..\flext\build win pd msvc clean + ..\flext\build pd msvc clean or under unix with - bash ../flext/build.sh lnx pd gcc + bash ../flext/build.sh pd gcc Then install your external with - bash ../flext/build.sh lnx pd gcc install + bash ../flext/build.sh pd gcc install You can clean up the intermediate build folders with - bash ../flext/build.sh lnx pd gcc clean + bash ../flext/build.sh pd gcc clean 1.3) Building externals diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index 75b663b0..e1248969 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -33,6 +33,7 @@ Version history: - added some more SIMD functionality - fixes to flext::Timer::At method - eliminated misleading flext_dsp::ChannelsIn and ChannelsOut +- added lock-free Lifo and Fifo structures and used it with message queueing 0.4.7: - added flext::GetBool (just because flext::GetInt has been there for a while) diff --git a/externals/grill/flext/notes.txt b/externals/grill/flext/notes.txt index 3538ca5f..4833b7e6 100644 --- a/externals/grill/flext/notes.txt +++ b/externals/grill/flext/notes.txt @@ -1,64 +1,66 @@ -flext - C++ layer for Max/MSP and pd (pure data) externals - -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) -For information on usage and redistribution, and for a DISCLAIMER OF ALL -WARRANTIES, see the file, "license.txt," in this distribution. - ----------------------------------------------------------------------------- - -VARIOUS NOTES: - -Platform specific: -- PD does not allow signal and message to go into the same inlet (except leftmost inlet) -- PD: with DSP objects all float messages to the leftmost inlet are converted to signal - -Restrictions in compatibility mode: -- Max allows only 9 float/int inlets - -Porting to new compilers/platforms: -- enums must be int-sized!!! -- compiler must support bool type -- an STL implementation must exist -- C++ exceptions and RTTI must be enabled - ----------------------------------------------------------------------------- - -KNOWN BUGS: -- can't use MFC libraries because of global new and delete overloadings -- MaxMSP Mach-O DSP externals cannot be the first externals loaded (e.g. in Max Runtime) - there must be a CFM signal external loaded beforehand!!! (Max will crash otherwise) - ----------------------------------------------------------------------------- - -TODO LIST: - -- optimizations for object initialization and messaging -- SIMD for gcc - -- update documentation -- add log messages for debugging version -- use PD's t_float and t_int types (or comparable for 32-bit safety) - -- add double handlers -- add signal in/out connection query function - -- support for Max qelem style - -- flext::post and flext::error should print via a worker thread (and should be unlimited in characters) - -- manage running threads individually (stop, isrunning?, priority etc.) - ----------------------------------------------------------------------------- - -TESTS TO DO: - -- PD: problems with timed buffer redrawing (takes a lot of cpu time) -- hard thread termination upon object destruction doesn't seem to work properly -> crash -- Max rounding bug ... buffer resize could be one sample less! - -- PD: figure out what "pointer" messages do and whether they are correctly implemented in flext - -- Max buffer~ resize: flext_base::buffer::Frames(): must we use buffer or system sample rate? - -- check whether m_dsp gets called upon deletion of a used buffer (PD and MaxMSP may behave differently). - -> PD does call m_dsp, Max/MSP does not +flext - C++ layer for Max/MSP and pd (pure data) externals
+
+Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+----------------------------------------------------------------------------
+
+VARIOUS NOTES:
+
+Platform specific:
+- PD does not allow signal and message to go into the same inlet (except leftmost inlet)
+- PD: with DSP objects all float messages to the leftmost inlet are converted to signal
+
+Restrictions in compatibility mode:
+- Max allows only 9 float/int inlets
+
+Porting to new compilers/platforms:
+- enums must be int-sized!!!
+- compiler must support bool type
+- an STL implementation must exist
+- C++ exceptions and RTTI must be enabled
+
+----------------------------------------------------------------------------
+
+KNOWN BUGS:
+- can't use MFC libraries because of global new and delete overloadings
+
+- MaxMSP Mach-O DSP externals cannot be the first externals loaded (e.g. in Max Runtime)
+ there must be a CFM signal external loaded beforehand!!! (Max will crash otherwise)
+ -> i think this is fixed in Max in the meantime!
+
+----------------------------------------------------------------------------
+
+TODO LIST:
+
+- optimizations for object initialization and messaging
+- SIMD for gcc
+
+- update documentation
+- add log messages for debugging version
+- use PD's t_float and t_int types (or comparable for 32-bit safety)
+
+- add double handlers
+- add signal in/out connection query function
+
+- support for Max qelem style
+
+- flext::post and flext::error should print via a worker thread (and should be unlimited in characters)
+
+- manage running threads individually (stop, isrunning?, priority etc.)
+
+----------------------------------------------------------------------------
+
+TESTS TO DO:
+
+- PD: problems with timed buffer redrawing (takes a lot of cpu time)
+- hard thread termination upon object destruction doesn't seem to work properly -> crash
+- Max rounding bug ... buffer resize could be one sample less!
+
+- PD: figure out what "pointer" messages do and whether they are correctly implemented in flext
+
+- Max buffer~ resize: flext_base::buffer::Frames(): must we use buffer or system sample rate?
+
+- check whether m_dsp gets called upon deletion of a used buffer (PD and MaxMSP may behave differently).
+ -> PD does call m_dsp, Max/MSP does not
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 <typename T>
+class TypedLifo
+ : public Lifo
+{
+public:
+ inline T *Avail() { return static_cast<T *>(Lifo::Avail()); }
+ inline void Push(T *c) { Lifo::Push(static_cast<T *>(c)); }
+ inline T *Pop() { return static_cast<T *>(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 <typename T>
+class TypedFifo
+ : public Fifo
+{
+public:
+ inline T *Avail() { return static_cast<T *>(Fifo::Avail()); }
+ inline void Put(T *c) { Fifo::Put(static_cast<T *>(c)); }
+ inline T *Get() { return static_cast<T *>(Fifo::Get()); }
+ inline T *Clear() { return static_cast<T *>(Fifo::Clear()); }
+};
+
#endif
diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 62a8b35a..75f7842e 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -29,7 +29,7 @@ flext::thrid_t flext::thrmsgid = 0; class qmsg: public flext, - public Cell + public Fifo::Cell { public: qmsg(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) @@ -37,6 +37,13 @@ public: , th(t),out(o) {} + void Set(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) + { + th = t; + out = o; + msg(s,ac,av); + } + // \note PD sys lock must already be held by caller void Send() const { @@ -59,28 +66,26 @@ private: */ class Queue: public flext, - public Fifo + public TypedFifo<qmsg> { public: inline bool Empty() const { return Size() == 0; } - inline void Push(qmsg *q) { Fifo::Put(q); } - - inline qmsg *Pop() { return static_cast<qmsg *>(Fifo::Get()); } + void New(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av); - void Push(flext_base *th,int o) // bang + inline void Push(flext_base *th,int o) // bang { - Put(new qmsg(th,o,sym_bang,0,NULL)); + New(th,o,sym_bang,0,NULL); } - void Push(flext_base *th,int o,float dt) + inline void Push(flext_base *th,int o,float dt) { t_atom at; SetFloat(at,dt); - Put(new qmsg(th,o,sym_float,1,&at)); + New(th,o,sym_float,1,&at); } - void Push(flext_base *th,int o,int dt) + inline void Push(flext_base *th,int o,int dt) { t_atom at; SetInt(at,dt); @@ -92,14 +97,14 @@ public: #else #error Not implemented! #endif - Put(new qmsg(th,o,sym,1,&at)); + New(th,o,sym,1,&at); } - void Push(flext_base *th,int o,const t_symbol *dt) + inline void Push(flext_base *th,int o,const t_symbol *dt) { t_atom at; SetSymbol(at,dt); - Put(new qmsg(th,o,sym_symbol,1,&at)); + New(th,o,sym_symbol,1,&at); } void Push(flext_base *th,int o,const t_atom &a) @@ -121,21 +126,31 @@ public: error("atom type not supported"); return; } - Put(new qmsg(th,o,sym,1,&a)); + New(th,o,sym,1,&a); } - void Push(flext_base *th,int o,int argc,const t_atom *argv) + inline void Push(flext_base *th,int o,int argc,const t_atom *argv) { - Put(new qmsg(th,o,sym_list,argc,argv)); + New(th,o,sym_list,argc,argv); } - void Push(flext_base *th,int o,const t_symbol *sym,int argc,const t_atom *argv) + inline void Push(flext_base *th,int o,const t_symbol *sym,int argc,const t_atom *argv) { - Put(new qmsg(th,o,sym,argc,argv)); + New(th,o,sym,argc,argv); } }; -static Queue queue; +static Queue queue,requeue; + +void Queue::New(flext_base *t,int o,const t_symbol *s,int ac,const t_atom *av) +{ + qmsg *m = requeue.Get(); + if(m) + m->Set(t,o,s,ac,av); + else + m = new qmsg(t,o,s,ac,av); + Put(m); +} #if FLEXT_QMODE == 2 @@ -163,9 +178,9 @@ static void QWork(bool syslock) #endif qmsg *q; - while((q = queue.Pop()) != NULL) { + while((q = queue.Get()) != NULL) { q->Send(); - delete q; + requeue.Put(q); } #if FLEXT_QMODE == 2 |