From f26399eba6ee6ce9eb7bae9a4b60a90dc2ebca94 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 31 Jan 2004 03:31:16 +0000 Subject: "" svn path=/trunk/; revision=1300 --- externals/grill/flext/flext.vcproj | 2 +- externals/grill/flext/source/flsupport.cpp | 72 ++++++++++++++++++------------ 2 files changed, 44 insertions(+), 30 deletions(-) (limited to 'externals') diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj index 7387aca2..9dc85a0c 100644 --- a/externals/grill/flext/flext.vcproj +++ b/externals/grill/flext/flext.vcproj @@ -174,7 +174,7 @@ #include +#include const t_symbol *flext::sym_float = NULL; const t_symbol *flext::sym_symbol = NULL; @@ -115,12 +116,13 @@ void flext::Setup() } -#if defined(FLEXT_THREADED) && defined(FLEXT_PDLOCK) +#if FLEXT_SYS == FLEXT_SYS_PD && defined(FLEXT_THREADED) && defined(FLEXT_PDLOCK) +#error #define SYSLOCK() sys_lock() #define SYSUNLOCK() sys_unlock() #else -#define SYSLOCK(on) (void)0 -#define SYSUNLOCK(on) (void)0 +#define SYSLOCK() (void)0 +#define SYSUNLOCK() (void)0 #endif @@ -136,21 +138,24 @@ void *flext_root::operator new(size_t bytes) bytes += sizeof(size_t); char *blk; -#ifdef FLEXT_NOGLOBALNEW if(bytes >= LARGEALLOC) { +#if FLEXT_SYS == FLEXT_SYS_MAX + blk = (char *)::sysmem_newptr(bytes); +#else // use C library function for large memory blocks - blk = (char *)::operator new(bytes); - } - else + blk = (char *)::malloc(bytes); #endif - { - //! \todo We need system locking here for secondary threads! + } + else { + //! We need system locking here for secondary threads! + SYSLOCK(); #if FLEXT_SYS == FLEXT_SYS_JMAX blk = (char *)::fts_malloc(bytes); #else blk = (char *)::getbytes(bytes); #endif + SYSUNLOCK(); } *(size_t *)blk = bytes; @@ -162,21 +167,24 @@ void flext_root::operator delete(void *blk) char *ori = (char *)blk-sizeof(size_t); size_t bytes = *(size_t *)ori; -#ifdef FLEXT_NOGLOBALNEW if(bytes >= LARGEALLOC) { +#if FLEXT_SYS == FLEXT_SYS_MAX + ::sysmem_freeptr(ori); +#else // use C library function for large memory blocks - ::operator delete(ori); - } - else + ::free(ori); #endif - { - //! \todo We need system locking here for secondary threads! + } + else { + //! We need system locking here for secondary threads! + SYSLOCK(); #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_free(ori); + ::fts_free(ori); #else ::freebytes(ori,bytes); #endif + SYSUNLOCK(); } } @@ -187,21 +195,24 @@ void *flext_root::NewAligned(size_t bytes,int bitalign) bytes += ovh+alignovh; char *blk; -#ifdef FLEXT_NOGLOBALNEW if(bytes >= LARGEALLOC) { +#if FLEXT_SYS == FLEXT_SYS_MAX + blk = (char *)::sysmem_newptr(bytes); +#else // use C library function for large memory blocks - blk = (char *)::operator new(bytes); - } - else + blk = (char *)::malloc(bytes); #endif - { - //! \todo We need system locking here for secondary threads! + } + else { + //! We need system locking here for secondary threads! + SYSLOCK(); #if FLEXT_SYS == FLEXT_SYS_JMAX blk = (char *)::fts_malloc(bytes); #else blk = (char *)::getbytes(bytes); #endif + SYSUNLOCK(); } char *ablk = reinterpret_cast((reinterpret_cast(blk)+ovh+alignovh) & ~alignovh); @@ -215,21 +226,24 @@ 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)); -#ifdef FLEXT_NOGLOBALNEW if(bytes >= LARGEALLOC) { +#if FLEXT_SYS == FLEXT_SYS_MAX + ::sysmem_freeptr(ori); +#else // use C library function for large memory blocks - ::operator delete(ori); - } - else + ::free(ori); #endif - { - //! \todo We need system locking here for secondary threads! + } + else { + //! We need system locking here for secondary threads! + SYSLOCK(); #if FLEXT_SYS == FLEXT_SYS_JMAX - fts_free(ori); + ::fts_free(ori); #else ::freebytes(ori,bytes); #endif + SYSUNLOCK(); } } -- cgit v1.2.1