From 214066a139e6c680e8517c89a07431a9649321a0 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Fri, 27 Oct 2006 13:34:56 +0000 Subject: fix for Codewarrior compilation update docs fixed anything/symbol message mixup (thanks to Stefano Papetti) fixed typos, dates, contact info added gcc branch hinting svn path=/trunk/; revision=6170 --- externals/grill/flext/source/fldsp.cpp | 2 +- externals/grill/flext/source/flmap.h | 8 ++++---- externals/grill/flext/source/flmsg.cpp | 4 ++-- externals/grill/flext/source/flout.cpp | 8 ++++---- externals/grill/flext/source/flprefix.h | 9 +++++++++ externals/grill/flext/source/flqueue.cpp | 10 +++++----- externals/grill/flext/source/flsupport.cpp | 8 ++++---- externals/grill/flext/source/flxlet.cpp | 8 ++++---- 8 files changed, 33 insertions(+), 24 deletions(-) (limited to 'externals/grill/flext/source') 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(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); -- cgit v1.2.1