Commit 6f043843 authored by thomas's avatar thomas
Browse files

tried to separate single-, multi-threading and shared builds by class naming...

tried to separate single-, multi-threading and shared builds by class naming to avoid name clashes for linux flat linker namespace


git-svn-id: https://svn.grrrr.org/ext/trunk@667 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent cab06520
......@@ -16,7 +16,7 @@ Version history:
0.5.0:
- added some more SIMD functions
- fixed wrong returned result of flext::buffer::set function
- fix for linux static exported function name-clash (flext::Setup() single- vs. multi-threading)
- fix for linux static exported function name-clash (individual linker namings for exported flext base classes)
- made message queue stuff global (static) for all flext objects
- added flext_base::DumpAttrib to send an attribute value to the attribute outlet
- added "getmethods" message (for attribute-enabled externals) to list methods for a specified inlet (default = 0)
......@@ -25,6 +25,7 @@ Version history:
- added flext::post() and flext::error() console printing (thread-safe)
- added flext::CmpAtom and AtomList::operator < methods ... useful for using lists as keys for STL
- make use of new PD thread locking (PD functions sys_lock() and sys_unlock())
- better FLEXT_OSAPI resolution
0.4.4:
- fixed deadly bug for Max/MSP method-to-symbol-binding proxies
......@@ -266,6 +267,8 @@ general:
- add log messages for debugging version
- use PD's t_float and t_int types (or comparable for 32-Bit safety)
- make links flext.a -> libflext.a for compatibility
bugs:
- 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
......
......@@ -5,8 +5,9 @@
# where is PD?
PDPATH=c:\programme\audio\pd
# where is MS VC++?
MSVCPATH="c:\programme\prog\microsoft visual studio\VC98"
# where is MS VC++?
# (should be commented out when called from the Visual Studio Command prompt)
# MSVCPATH="c:\programme\prog\microsoft visual studio\VC98"
# where is the SndObj include directory?
# (leave blank or comment out to disable SndObj support)
......
......@@ -24,7 +24,7 @@ INCPATH=$(INCPATH) /I$(STK)
# compiler definitions and flags
DEFS=/DFLEXT_SYS=2 $(UFLAGS)
CFLAGS=/GX /GD /G6
CFLAGS=/GX /GD /G6 /arch:SSE
OFLAGS=/Ox
DFLAGS=/Od /Zi
......
......@@ -37,7 +37,7 @@ void flext_obj::ProcessAttributes(bool attr) { process_attributes = attr; }
// Constructor
//
/////////////////////////////////////////////////////////
flext_obj :: flext_obj()
flext_obj :: FLEXT_CLASSDEF(flext_obj)()
: x_obj(m_holder)
, procattr(m_holdattr)
, init_ok(true)
......@@ -55,7 +55,7 @@ flext_obj :: flext_obj()
// Destructor
//
/////////////////////////////////////////////////////////
flext_obj :: ~flext_obj() {
flext_obj :: ~FLEXT_CLASSDEF(flext_obj)() {
x_obj = NULL;
}
......
......@@ -20,7 +20,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flstdc.h"
#include "flsupport.h"
class FLEXT_SHARE flext_obj;
class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj);
typedef class FLEXT_CLASSDEF(flext_obj) flext_obj;
// ----------------------------------------------------------------------------
/*! \brief The obligatory PD or Max/MSP object header
......@@ -56,7 +58,7 @@ struct FLEXT_SHARE flext_hdr
/*! \brief This points to the actual polymorphic C++ class
*/
flext_obj *data;
FLEXT_CLASSDEF(flext_obj) *data;
//! @} FLEXT_OBJHEADER
};
......@@ -85,7 +87,7 @@ struct FLEXT_SHARE flext_hdr
*/
// ----------------------------------------------------------------------------
class FLEXT_SHARE flext_obj:
class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj):
public flext
{
public:
......@@ -100,10 +102,10 @@ class FLEXT_SHARE flext_obj:
*/
//! Constructor
flext_obj();
FLEXT_CLASSDEF(flext_obj)();
//! Destructor
virtual ~flext_obj() = 0;
virtual ~FLEXT_CLASSDEF(flext_obj)() = 0;
/*! \brief Signal a construction problem
\note This should only be used in the constructor. Object creation will be aborted.
......@@ -221,7 +223,7 @@ class FLEXT_SHARE flext_obj:
public:
//! Creation callback
static void __setup__(t_classid) { flext::FLEXT_SETUPFUNC(); }
static void __setup__(t_classid) { flext::Setup(); }
/*! \brief This is a temporary holder
\warning don't touch it!
......@@ -243,7 +245,7 @@ class FLEXT_SHARE flext_obj:
// Definitions for library objects
static void lib_init(const char *name,void setupfun(),bool attr);
static void obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),flext_obj *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...);
static void obj_add(bool lib,bool dsp,bool attr,const char *idname,const char *names,void setupfun(t_classid),FLEXT_CLASSDEF(flext_obj) *(*newfun)(int,t_atom *),void (*freefun)(flext_hdr *),int argtp1,...);
#if FLEXT_SYS == FLEXT_SYS_JMAX
static void obj_new(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at);
static void obj_free(fts_object_t *o, int winlet, fts_symbol_t s, int ac, const fts_atom_t *at);
......@@ -293,9 +295,9 @@ class FLEXT_SHARE flext_obj:
#define FLEXT_REALHDR(NEW_CLASS, PARENT_CLASS) \
public: \
typedef NEW_CLASS thisType; \
static flext_obj *__init__(int argc,t_atom *argv); \
static FLEXT_CLASSDEF(flext_obj) *__init__(int argc,t_atom *argv); \
static void __free__(flext_hdr *hdr) \
{ flext_obj *mydata = hdr->data; delete mydata; \
{ FLEXT_CLASSDEF(flext_obj) *mydata = hdr->data; delete mydata; \
hdr->flext_hdr::~flext_hdr(); } \
static void __setup__(t_classid classid) { \
PARENT_CLASS::__setup__(classid); } \
......@@ -306,9 +308,9 @@ static inline NEW_CLASS *thisObject(void *c) { return FLEXT_CAST<NEW_CLASS *>(((
#define FLEXT_REALHDR_S(NEW_CLASS, PARENT_CLASS,SETUPFUN) \
public: \
typedef NEW_CLASS thisType; \
static flext_obj *__init__(int argc,t_atom *argv); \
static FLEXT_CLASSDEF(flext_obj) *__init__(int argc,t_atom *argv); \
static void __free__(flext_hdr *hdr) \
{ flext_obj *mydata = hdr->data; delete mydata; \
{ FLEXT_CLASSDEF(flext_obj) *mydata = hdr->data; delete mydata; \
hdr->flext_hdr::~flext_hdr(); } \
static void __setup__(t_classid classid) \
{ PARENT_CLASS::__setup__(classid); \
......
......@@ -36,9 +36,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
/*! \brief Flext message only base object
This is the base class from which typical external object derive.
This is the base class from which typical external objects derive.
DSP objects should use the flext_dsp class which inherits from flext_base and
provides the needed functionality.
provides the necessary functionality.
For a valid external object class you would also need FLEXT_HEADER, also if it's only
a base class without instantiated objects again.
......@@ -49,12 +49,15 @@ WARRANTIES, see the file, "license.txt," in this distribution.
*/
class FLEXT_SHARE flext_base:
class FLEXT_SHARE FLEXT_CLASSDEF(flext_base);
typedef class FLEXT_SHARE FLEXT_CLASSDEF(flext_base) flext_base;
class FLEXT_SHARE FLEXT_CLASSDEF(flext_base):
public flext_obj
{
FLEXT_HEADER_S(flext_base,flext_obj,Setup)
FLEXT_HEADER_S(FLEXT_CLASSDEF(flext_base),flext_obj,Setup)
friend class flext_obj;
friend class FLEXT_SHARE FLEXT_CLASSDEF(flext_obj);
/*! \defgroup FLEXT_CLASS Flext base class
@{
......@@ -469,8 +472,8 @@ public:
protected:
flext_base();
virtual ~flext_base();
FLEXT_CLASSDEF(flext_base)();
virtual ~FLEXT_CLASSDEF(flext_base)();
/*! \brief Set up inlets and outlets, method and attribute lists
*/
......
......@@ -43,7 +43,7 @@ void flext_dsp::Setup(t_classid id)
#endif
}
flext_dsp::flext_dsp():
flext_dsp::FLEXT_CLASSDEF(flext_dsp)():
#if FLEXT_SYS == FLEXT_SYS_JMAX
srate(fts_dsp_get_sample_rate()), // should we set it?
blksz(fts_dsp_get_tick_size()),
......@@ -74,7 +74,7 @@ flext_dsp::flext_dsp():
}
flext_dsp::~flext_dsp()
flext_dsp::~FLEXT_CLASSDEF(flext_dsp)()
{
#if FLEXT_SYS == FLEXT_SYS_JMAX
fts_dsp_object_delete(thisHdr());
......
......@@ -22,12 +22,16 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// === flext_dsp ==================================================
class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp);
typedef class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp) flext_dsp;
/*! \brief Flext dsp enabled base object
*/
class FLEXT_SHARE flext_dsp:
class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp):
public flext_base
{
FLEXT_HEADER_S(flext_dsp,flext_base,Setup)
FLEXT_HEADER_S(FLEXT_CLASSDEF(flext_dsp),flext_base,Setup)
public:
......@@ -132,8 +136,8 @@ public:
protected:
flext_dsp();
virtual ~flext_dsp();
FLEXT_CLASSDEF(flext_dsp)();
virtual ~FLEXT_CLASSDEF(flext_dsp)();
private:
......
......@@ -20,7 +20,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
bool flext_base::compatibility = true;
flext_base::flext_base():
flext_base::FLEXT_CLASSDEF(flext_base)():
inlist(NULL),outlist(NULL),
curtag(NULL),
incnt(0),outcnt(0),
......@@ -49,7 +49,7 @@ flext_base::flext_base():
attrhead = clattrhead = NULL;
}
flext_base::~flext_base()
flext_base::~FLEXT_CLASSDEF(flext_base)()
{
#if FLEXT_SYS == FLEXT_SYS_MAX
// according to David Z. one should do that first...
......
......@@ -194,7 +194,7 @@ t_class *flext_obj::getClass(t_classid id) { return reinterpret_cast<libclass *>
void flext_obj::lib_init(const char *name,void setupfun(),bool attr)
{
flext::FLEXT_SETUPFUNC();
flext::Setup();
#if FLEXT_SYS == FLEXT_SYS_MAX
lib_name = MakeSymbol(name);
......
......@@ -54,9 +54,15 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// --- definitions for FLEXT_OS_API ---------------------
#define FLEXT_OSAPI_UNKNOWN 0
#define FLEXT_OSAPI_MAC_CLASSIC 1
#define FLEXT_OSAPI_MAC_CARBON 2
#define FLEXT_OSAPI_MAC_OSX 3
#define FLEXT_OSAPI_UNIX_POSIX 1
#define FLEXT_OSAPI_MAC_CLASSIC 2
#define FLEXT_OSAPI_MAC_CARBON 3
#define FLEXT_OSAPI_MAC_OSX 4
#define FLEXT_OSAPI_WIN_NATIVE 5 // WIN32 Platform
#define FLEXT_OSAPI_WIN_POSIX 6 // POSIX API (e.g. cygwin)
// --- definitions for FLEXT_CPU ---------------------
#define FLEXT_CPU_UNKNOWN 0
......@@ -120,12 +126,13 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef FLEXT_OS
#if defined(_WIN32)
#define FLEXT_OS FLEXT_OS_WIN
#define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE
#else
#define FLEXT_OS FLEXT_OS_UNKNOWN
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#endif
#endif
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#elif defined(__BORLANDC__)
// Borland C++
......@@ -135,9 +142,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
#ifndef FLEXT_OS
#define FLEXT_OS FLEXT_OS_WIN
#define FLEXT_OSAPI FLEXT_OSAPI_WIN_NATIVE
#else
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#endif
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#elif defined(__MWERKS__)
// Metrowerks CodeWarrior
......@@ -224,14 +233,21 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
#endif
#if FLEXT_OS == FLEXT_OS_MAC
#define FLEXT_OSAPI FLEXT_OSAPI_MAC_OSX
#else
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#ifndef FLEXT_OSAPI
#if FLEXT_OS == FLEXT_OS_MAC
#define FLEXT_OSAPI FLEXT_OSAPI_MAC_OSX
#elif FLEXT_OS == FLEXT_OS_WIN
#define FLEXT_OSAPI FLEXT_OSAPI_WIN_POSIX
#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX
#define FLEXT_OSAPI FLEXT_OSAPI_UNIX_POSIX
#else
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#endif
#endif
#elif defined(__MRC__) && defined(MPW_CPLUS)
// Apple MPW MrCpp
#if __MRC__ < 0x500
#error Apple MPW MrCpp v.5.0.0 or better compiler required
#endif
......@@ -252,10 +268,17 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
#endif
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#ifndef FLEXT_OSAPI
#if FLEXT_OS == FLEXT_OS_MAC
#define FLEXT_OSAPI FLEXT_OSAPI_MAC_CLASSIC
#else
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
#endif
#endif
#endif
#if FLEXT_OS == FLEXT_OS_WIN
// #pragma message("Compiling for Windows")
......@@ -334,6 +357,16 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
#endif
// ----- macros for class names -----
#if defined(FLEXT_SHARED)
#define FLEXT_CLASSDEF(CL) CL##_shared
#elif defined(FLEXT_THREADS)
#define FLEXT_CLASSDEF(CL) CL##_multi
#else
#define FLEXT_CLASSDEF(CL) CL##_single
#endif
// std namespace
#ifdef __MWERKS__
#define STD std
......
......@@ -35,7 +35,7 @@ const t_symbol *flext::sym_signal = NULL;
int flext::Version() { return FLEXT_VERSION; }
const char *flext::VersionStr() { return FLEXT_VERSTR; }
void flext::FLEXT_SETUPFUNC()
void flext::Setup()
{
static bool issetup = false;
if(issetup)
......
......@@ -18,7 +18,10 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "flstdc.h"
class FLEXT_SHARE flext_base;
class FLEXT_SHARE FLEXT_CLASSDEF(flext);
typedef class FLEXT_CLASSDEF(flext) flext;
class FLEXT_SHARE FLEXT_CLASSDEF(flext_base);
/*! \brief Flext support class
......@@ -31,7 +34,8 @@ class FLEXT_SHARE flext_base;
This class can also be used for a non-object class (not representing an external object)
and won't give any extra burden to it.
*/
class FLEXT_SHARE flext {
class FLEXT_SHARE FLEXT_CLASSDEF(flext) {
/*! \defgroup FLEXT_SUPPORT Flext support class
@{
......@@ -644,7 +648,7 @@ public:
void set_any(const t_symbol *s,int argc,const t_atom *argv);
void set_list(int argc,const t_atom *argv);
flext_base *cl;
FLEXT_CLASSDEF(flext_base) *cl;
union _data {
bool _bool;
float _float;
......@@ -667,10 +671,10 @@ public:
//! \brief Check if this class represents the current thread
bool Is(thrid_t id = GetThreadId()) const { return IsThread(thrid,id); }
flext_base *This() const { return th; }
FLEXT_CLASSDEF(flext_base) *This() const { return th; }
thrid_t Id() const { return thrid; }
flext_base *th;
FLEXT_CLASSDEF(flext_base) *th;
void (*meth)(thr_params *);
thr_params *params;
thrid_t thrid;
......@@ -913,7 +917,7 @@ public:
//! Set timer callback function.
void SetCallback(void (*cb)(void *data)) { clss = NULL,cback = cb; }
//! Set timer callback function (with class pointer).
void SetCallback(flext_base &th,bool (*cb)(flext_base *th,void *data)) { clss = &th,cback = (void (*)(void *))cb; }
void SetCallback(FLEXT_CLASSDEF(flext_base) &th,bool (*cb)(FLEXT_CLASSDEF(flext_base) *th,void *data)) { clss = &th,cback = (void (*)(void *))cb; }
//! Clear timer.
bool Reset();
......@@ -944,7 +948,7 @@ public:
const bool queued;
void (*cback)(void *data);
flext_base *clss;
FLEXT_CLASSDEF(flext_base) *clss;
void *userdata;
double period;
};
......@@ -990,12 +994,16 @@ protected:
As single- and multi-threaded to different initializations the function names have
to be different as well.
*/
/*
#ifdef FLEXT_THREADS
#define FLEXT_SETUPFUNC SetupMulti
#else
#define FLEXT_SETUPFUNC SetupSingle
#endif
static void FLEXT_SETUPFUNC();
*/
static void Setup();
static bool chktilde(const char *objname);
......@@ -1004,12 +1012,12 @@ protected:
// 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; }
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; }
......
......@@ -20,11 +20,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <time.h>
#if FLEXT_OS == FLEXT_OS_WIN
#include <sys/timeb.h>
#elif FLEXT_OS == FLEXT_OS_LINUX
#if FLEXT_OSAPI == FLEXT_OSAPI_UNIX_POSIX || FLEXT_OSAPI == FLEXT_OSAPI_WIN_POSIX
#include <sys/time.h>
#include <unistd.h>
#elif FLEXT_OS == FLEXT_OS_WIN
#include <sys/timeb.h>
#endif
#include <errno.h>
......@@ -514,12 +514,12 @@ bool flext::ThrCond::Wait() {
bool flext::ThrCond::TimedWait(double ftime)
{
timespec tm;
#if FLEXT_OS == FLEXT_OS_WIN
#if FLEXT_OS == FLEXT_OS_WIN && FLEXT_OSAPI == FLEXT_OSAPI_WIN_NATIVE
_timeb tmb;
_ftime(&tmb);
tm.tv_nsec = tmb.millitm*1000000;
tm.tv_sec = tmb.time;
#else
#else // POSIX
#if 0 // find out when the following is defined
clock_gettime(CLOCK_REALTIME,tm);
#else
......@@ -529,6 +529,7 @@ bool flext::ThrCond::TimedWait(double ftime)
tm.tv_sec = tp.tv_sec;
#endif
#endif
tm.tv_nsec += (long)((ftime-(long)ftime)*1.e9);
long nns = tm.tv_nsec%1000000000;
tm.tv_sec += (long)ftime+(tm.tv_nsec-nns)/1000000000;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment