diff options
-rw-r--r-- | externals/grill/flext/changes.txt | 1 | ||||
-rw-r--r-- | externals/grill/flext/readme.txt | 2 | ||||
-rw-r--r-- | externals/grill/flext/source/fldsp.cpp | 2 | ||||
-rw-r--r-- | externals/grill/flext/source/flmap.h | 8 | ||||
-rwxr-xr-x | externals/grill/flext/source/flmsg.cpp | 4 | ||||
-rw-r--r-- | externals/grill/flext/source/flout.cpp | 8 | ||||
-rwxr-xr-x | externals/grill/flext/source/flprefix.h | 9 | ||||
-rwxr-xr-x | externals/grill/flext/source/flqueue.cpp | 10 | ||||
-rw-r--r-- | externals/grill/flext/source/flsupport.cpp | 8 | ||||
-rwxr-xr-x | externals/grill/flext/source/flxlet.cpp | 8 | ||||
-rw-r--r-- | externals/grill/flext/tutorial/pd/ex-adv2.pd | 18 | ||||
-rw-r--r-- | externals/grill/flext/tutorial/pd/ex-simple3.pd | 44 |
12 files changed, 66 insertions, 56 deletions
diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index ae67cbf4..469c9ab1 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -38,6 +38,7 @@ Version history: - added new FLEXT_HEADER macros to enable class templates - more ToOut/Sys* methods - fixed help name definition at class setup +- added gcc branch hinting 0.5.0: - fixes for 64 bit builds (size_t is integer type of pointer size) diff --git a/externals/grill/flext/readme.txt b/externals/grill/flext/readme.txt index f821981c..30d55aba 100644 --- a/externals/grill/flext/readme.txt +++ b/externals/grill/flext/readme.txt @@ -1,6 +1,6 @@ flext - C++ layer for Max/MSP and pd (pure data) externals -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 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. diff --git a/externals/grill/flext/source/fldsp.cpp b/externals/grill/flext/source/fldsp.cpp index 5eb81ea7..e741c22a 100644 --- a/externals/grill/flext/source/fldsp.cpp +++ b/externals/grill/flext/source/fldsp.cpp @@ -49,7 +49,7 @@ t_int *flext_dsp::dspmeth(t_int *w) #if FLEXT_SYS == FLEXT_SYS_MAX if(!obj->thisHdr()->z_disabled) #else - if(obj->dspon) + if(LIKELY(obj->dspon)) #endif { flext_base::indsp = true; diff --git a/externals/grill/flext/source/flmap.h b/externals/grill/flext/source/flmap.h index 69204e2e..796e9549 100644 --- a/externals/grill/flext/source/flmap.h +++ b/externals/grill/flext/source/flmap.h @@ -58,7 +58,7 @@ public: void *insert(int tsize,size_t k,void *t) { void *r; - if(n) + if(LIKELY(n)) r = _set(tsize,k,t); else { data[n++](k,t); @@ -68,11 +68,11 @@ public: return r; } - void *find(int tsize,size_t k) const { return n?_find(tsize,k):0; } + void *find(int tsize,size_t k) const { return LIKELY(n)?_find(tsize,k):0; } void *remove(int tsize,size_t k) { - void *r = n?_remove(tsize,k):0; + void *r = LIKELY(n)?_remove(tsize,k):0; // check(tsize); return r; } @@ -213,7 +213,7 @@ public: inline T remove(K k) { void *d = TableAnyMap::remove(N,*(size_t *)&k); - if(d) --count; + if(LIKELY(d)) --count; return (T)d; } diff --git a/externals/grill/flext/source/flmsg.cpp b/externals/grill/flext/source/flmsg.cpp index ffde9bf2..9d8d8250 100755 --- a/externals/grill/flext/source/flmsg.cpp +++ b/externals/grill/flext/source/flmsg.cpp @@ -127,7 +127,7 @@ bool flext_base::FindMeth(int inlet,const t_symbol *s,int argc,const t_atom *arg ItemCont *clmethhead = ClMeths(thisClassId()); // search for exactly matching tag - if(methhead && (lst = methhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; + if(UNLIKELY(methhead) && (lst = methhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; if((lst = clmethhead->FindList(s,inlet)) != NULL && TryMethTag(lst,s,argc,argv)) return true; // if nothing found try any inlet @@ -142,7 +142,7 @@ bool flext_base::FindMethAny(int inlet,const t_symbol *s,int argc,const t_atom * Item *lst; ItemCont *clmethhead = ClMeths(thisClassId()); - if(methhead && (lst = methhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; + if(UNLIKELY(methhead) && (lst = methhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; if((lst = clmethhead->FindList(sym_anything,inlet)) != NULL && TryMethAny(lst,s,argc,argv)) return true; // if nothing found try any inlet diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp index 3933d5f1..dae256a7 100644 --- a/externals/grill/flext/source/flout.cpp +++ b/externals/grill/flext/source/flout.cpp @@ -20,7 +20,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. void flext_base::ToSysAtom(int n,const t_atom &at) const { outlet *o = GetOut(n); - if(o) { + if(LIKELY(o)) { CRITON(); if(IsSymbol(at)) outlet_symbol((t_outlet *)o,const_cast<t_symbol *>(GetSymbol(at))); @@ -45,12 +45,12 @@ void flext_base::ToSysAtom(int n,const t_atom &at) const #if defined(FLEXT_THREADS) #if FLEXT_QMODE == 2 - #define CHKTHR() ((IsSystemThread() || IsThread(flext::thrmsgid)) && !InDSP()) + #define CHKTHR() (LIKELY((IsSystemThread() || IsThread(flext::thrmsgid)) && !InDSP())) #else - #define CHKTHR() (IsSystemThread() && !InDSP()) + #define CHKTHR() (LIKELY(IsSystemThread() && !InDSP())) #endif #else - #define CHKTHR() (!InDSP()) + #define CHKTHR() (LIKELY(!InDSP())) #endif void flext_base::ToOutBang(int n) const { if(CHKTHR()) ToSysBang(n); else ToQueueBang(n); } diff --git a/externals/grill/flext/source/flprefix.h b/externals/grill/flext/source/flprefix.h index 4568a1cc..0855f73d 100755 --- a/externals/grill/flext/source/flprefix.h +++ b/externals/grill/flext/source/flprefix.h @@ -412,5 +412,14 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define STD #endif +// branching hints +#ifdef __GNUC__ +#define LIKELY(expression) (__builtin_expect(!!(expression), 1)) +#define UNLIKELY(expression) (__builtin_expect(!!(expression), 0)) +#else +#define LIKELY(expression) (expression) +#define UNLIKELY(expression) (expression) +#endif + #endif // __FLEXT_PREFIX_H diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index 2053c4de..c3abbc52 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -208,7 +208,7 @@ private: void Send() const { if(th) { - if(out < 0) + if(UNLIKELY(out < 0)) // message to self th->CbMethodHandler(-1-out,sym,argc,argc > STATSIZE?argv:argl); else @@ -238,7 +238,7 @@ private: { sym = s; argc = cnt; - if(cnt > STATSIZE) { + if(UNLIKELY(cnt > STATSIZE)) { argv = new t_atom[cnt]; flext::CopyAtoms(cnt,argv,lst); } @@ -251,7 +251,7 @@ private: Msg *Get() { Msg *m = &msg; - if(m->Ok()) { + if(LIKELY(m->Ok())) { for(; m->nxt; m = m->nxt) {} m = m->nxt = new Msg; m->Init(); @@ -262,7 +262,7 @@ private: inline void Queue::Push(MsgBundle *m) { - if(m) { + if(LIKELY(m)) { Put(m); Trigger(); } @@ -531,7 +531,7 @@ void flext_base::MsgAddAnything(MsgBundle *m,int n,const t_symbol *s,int argc,co bool flext::SysForward(const t_symbol *recv,const t_symbol *s,int argc,const t_atom *argv) { void *cl = recv->s_thing; - if(!cl) return false; + if(UNLIKELY(!cl)) return false; #if FLEXT_SYS == FLEXT_SYS_PD pd_typedmess((t_class **)cl,(t_symbol *)s,argc,(t_atom *)argv); diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp index eaa27a60..b77729e6 100644 --- a/externals/grill/flext/source/flsupport.cpp +++ b/externals/grill/flext/source/flsupport.cpp @@ -119,7 +119,7 @@ void *flext_root::operator new(size_t bytes) bytes += sizeof(memtest)*2; #endif char *blk; - if(bytes >= LARGEALLOC) { + if(UNLIKELY(bytes >= LARGEALLOC)) { #if FLEXT_SYS == FLEXT_SYS_MAX && defined(_SYSMEM_H_) blk = (char *)::sysmem_newptr(bytes); #else @@ -163,7 +163,7 @@ void flext_root::operator delete(void *blk) #endif size_t bytes = *(size_t *)ori; - if(bytes >= LARGEALLOC) { + if(UNLIKELY(bytes >= LARGEALLOC)) { #if FLEXT_SYS == FLEXT_SYS_MAX && defined(_SYSMEM_H_) ::sysmem_freeptr(ori); #else @@ -205,7 +205,7 @@ void *flext_root::NewAligned(size_t bytes,int bitalign) bytes += ovh+alignovh; char *blk; - if(bytes >= LARGEALLOC) { + if(UNLIKELY(bytes >= LARGEALLOC)) { #if FLEXT_SYS == FLEXT_SYS_MAX && defined(_SYSMEM_H_) blk = (char *)::sysmem_newptr(bytes); #else @@ -239,7 +239,7 @@ void flext_root::FreeAligned(void *blk) char *ori = *(char **)((char *)blk-sizeof(size_t)-sizeof(char *)); size_t bytes = *(size_t *)((char *)blk-sizeof(size_t)); - if(bytes >= LARGEALLOC) { + if(UNLIKELY(bytes >= LARGEALLOC)) { #if FLEXT_SYS == FLEXT_SYS_MAX && defined(_SYSMEM_H_) ::sysmem_freeptr(ori); #else diff --git a/externals/grill/flext/source/flxlet.cpp b/externals/grill/flext/source/flxlet.cpp index 6aeea303..9fa9486a 100755 --- a/externals/grill/flext/source/flxlet.cpp +++ b/externals/grill/flext/source/flxlet.cpp @@ -38,7 +38,7 @@ void flext_base::xlet::Desc(const char *c) void flext_base::AddInlet(xlettype tp,int mult,const char *desc) { - if(incnt+mult >= MAXLETS) + if(UNLIKELY(incnt+mult >= MAXLETS)) post("%s - too many inlets",thisName()); else for(int i = 0; i < mult; ++i) { @@ -50,7 +50,7 @@ void flext_base::AddInlet(xlettype tp,int mult,const char *desc) void flext_base::AddOutlet(xlettype tp,int mult,const char *desc) { - if(outcnt+mult >= MAXLETS) + if(UNLIKELY(outcnt+mult >= MAXLETS)) post("%s - too many outlets",thisName()); else for(int i = 0; i < mult; ++i) { @@ -62,7 +62,7 @@ void flext_base::AddOutlet(xlettype tp,int mult,const char *desc) void flext_base::DescInlet(int ix,const char *d) { - if(ix >= incnt) + if(UNLIKELY(ix >= incnt)) post("%s - inlet %i not found",thisName(),ix); else inlist[ix].Desc(d); @@ -70,7 +70,7 @@ void flext_base::DescInlet(int ix,const char *d) void flext_base::DescOutlet(int ix,const char *d) { - if(ix >= outcnt) + if(UNLIKELY(ix >= incnt)) post("%s - outlet %i not found",thisName(),ix); else outlist[ix].Desc(d); diff --git a/externals/grill/flext/tutorial/pd/ex-adv2.pd b/externals/grill/flext/tutorial/pd/ex-adv2.pd index f9673cb9..b4fa1ce4 100644 --- a/externals/grill/flext/tutorial/pd/ex-adv2.pd +++ b/externals/grill/flext/tutorial/pd/ex-adv2.pd @@ -1,11 +1,9 @@ -#N canvas 329 97 591 352 12; +#N canvas 329 97 595 356 12; #X msg 26 97 help; #X msg 123 146 born; #X msg 172 147 to; #X msg 214 149 hula; -#X msg 228 230 yeah; #X msg 228 192 hula 1; -#X text 280 231 other symbol; #X text 261 150 tag without argument; #X text 297 190 tag and argument; #X text 72 97 print a help message; @@ -15,9 +13,11 @@ #X obj 148 293 adv2; #X text 21 49 this is identical to the simple3 example; #X text 145 9 flext tutorial \, (C)2002-2006 Thomas Grill; -#X connect 0 0 12 0; -#X connect 1 0 12 0; -#X connect 2 0 12 0; -#X connect 3 0 12 0; -#X connect 4 0 12 0; -#X connect 5 0 12 0; +#X text 345 231 symbol message; +#X msg 228 230 symbol yeah; +#X connect 0 0 10 0; +#X connect 1 0 10 0; +#X connect 2 0 10 0; +#X connect 3 0 10 0; +#X connect 4 0 10 0; +#X connect 14 0 10 0; diff --git a/externals/grill/flext/tutorial/pd/ex-simple3.pd b/externals/grill/flext/tutorial/pd/ex-simple3.pd index 7e0749f8..fbdafca5 100644 --- a/externals/grill/flext/tutorial/pd/ex-simple3.pd +++ b/externals/grill/flext/tutorial/pd/ex-simple3.pd @@ -1,22 +1,22 @@ -#N canvas 329 97 589 350 12;
-#X msg 22 87 help;
-#X msg 119 136 born;
-#X msg 168 137 to;
-#X msg 210 139 hula;
-#X msg 224 220 yeah;
-#X msg 224 182 hula 1;
-#X text 276 221 other symbol;
-#X obj 144 283 simple3;
-#X text 257 140 tag without argument;
-#X text 293 180 tag and argument;
-#X text 68 87 print a help message;
-#X obj 16 8 cnv 15 550 40 empty empty simple3 10 22 0 24 -260818 -1
-0;
-#X text 174 28 http://grrrr.org;
-#X text 174 10 flext tutorial \, (C)2002-2006 Thomas Grill;
-#X connect 0 0 7 0;
-#X connect 1 0 7 0;
-#X connect 2 0 7 0;
-#X connect 3 0 7 0;
-#X connect 4 0 7 0;
-#X connect 5 0 7 0;
+#N canvas 329 97 593 354 12; +#X msg 22 87 help; +#X msg 119 136 born; +#X msg 168 137 to; +#X msg 210 139 hula; +#X msg 224 182 hula 1; +#X obj 144 283 simple3; +#X text 257 140 tag without argument; +#X text 293 180 tag and argument; +#X text 68 87 print a help message; +#X obj 16 8 cnv 15 550 40 empty empty simple3 10 22 0 24 -260818 -1 +0; +#X text 174 28 http://grrrr.org; +#X text 174 10 flext tutorial \, (C)2002-2006 Thomas Grill; +#X msg 224 220 symbol yeah; +#X text 350 219 symbol message; +#X connect 0 0 5 0; +#X connect 1 0 5 0; +#X connect 2 0 5 0; +#X connect 3 0 5 0; +#X connect 4 0 5 0; +#X connect 12 0 5 0; |