diff --git a/dtool/Config.FreeBSD.pp b/dtool/Config.FreeBSD.pp index 43f09629dc..27bb52cbe7 100644 --- a/dtool/Config.FreeBSD.pp +++ b/dtool/Config.FreeBSD.pp @@ -137,9 +137,9 @@ // Must global operator new and delete functions throw exceptions? #define GLOBAL_OPERATOR_NEW_EXCEPTIONS 1 -// What is the syntax of the STL allocator declaration? See -// LocalSetup.pp for allowable values. -#define STL_ALLOCATOR MODERN +// Modern versions of gcc do support the latest STL allocator +// definitions. +#define USE_STL_ALLOCATOR 1 // The dynamic library file extension (usually .so .dll or .dylib): #define DYNAMIC_LIB_EXT .so diff --git a/dtool/Config.Irix.pp b/dtool/Config.Irix.pp index 8da9e2f877..f91f0e95e1 100644 --- a/dtool/Config.Irix.pp +++ b/dtool/Config.Irix.pp @@ -130,9 +130,8 @@ // Must global operator new and delete functions throw exceptions? #define GLOBAL_OPERATOR_NEW_EXCEPTIONS -// What is the syntax of the STL allocator declaration? See -// LocalSetup.pp for allowable values. -#define STL_ALLOCATOR OLD +// The Irix compiler doesn't support the modern STL allocator. +#define USE_STL_ALLOCATOR // The dynamic library file extension (usually .so .dll or .dylib): #define DYNAMIC_LIB_EXT .so diff --git a/dtool/Config.Linux.pp b/dtool/Config.Linux.pp index 5dc7acf90b..0a8c8c152e 100644 --- a/dtool/Config.Linux.pp +++ b/dtool/Config.Linux.pp @@ -7,7 +7,7 @@ // // What additional flags should we pass to interrogate? -#define SYSTEM_IGATE_FLAGS -D__i386__ -D__const=const +#define SYSTEM_IGATE_FLAGS -D__i386__ -D__const=const -Dvolatile= // Is the platform big-endian (like an SGI workstation) or // little-endian (like a PC)? Define this to the empty string to @@ -136,9 +136,9 @@ // Must global operator new and delete functions throw exceptions? #define GLOBAL_OPERATOR_NEW_EXCEPTIONS 1 -// What is the syntax of the STL allocator declaration? See -// LocalSetup.pp for allowable values. -#define STL_ALLOCATOR MODERN +// Modern versions of gcc do support the latest STL allocator +// definitions. +#define USE_STL_ALLOCATOR 1 // The dynamic library file extension (usually .so .dll or .dylib): #define DYNAMIC_LIB_EXT .so diff --git a/dtool/Config.osx.pp b/dtool/Config.osx.pp index 2b0d1d0f52..b4e1e5043b 100644 --- a/dtool/Config.osx.pp +++ b/dtool/Config.osx.pp @@ -173,9 +173,9 @@ // Must global operator new and delete functions throw exceptions? #define GLOBAL_OPERATOR_NEW_EXCEPTIONS 1 -// What is the syntax of the STL allocator declaration? See -// LocalSetup.pp for allowable values. -#define STL_ALLOCATOR MODERN +// Modern versions of gcc do support the latest STL allocator +// definitions. +#define USE_STL_ALLOCATOR 1 // The dynamic library file extension (usually .so .dll or .dylib): #define DYNAMIC_LIB_EXT .dylib diff --git a/dtool/Config.pp b/dtool/Config.pp index 1dbd17cddb..84999d3c55 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -122,10 +122,9 @@ // What level of compiler optimization/debug symbols should we build? // The various optimize levels are defined as follows: // -// 1 - No compiler optimizations, full debug symbols -// 2 - Full compiler optimizations, full debug symbols -// (if the compiler supports this) -// 3 - Full compiler optimizations, no debug symbols +// 1 - No compiler optimizations, debug symbols, debug heap, lots of checks +// 2 - Full compiler optimizations, debug symbols, debug heap, lots of checks +// 3 - Full compiler optimizations, full debug symbols, fewer checks // 4 - Full optimizations, no debug symbols, and asserts removed // #define OPTIMIZE 3 @@ -571,6 +570,13 @@ // (pthread_create(), etc.), define this true. #define HAVE_POSIX_THREADS $[and $[isfile /usr/include/pthread.h],$[not $[WINDOWS_PLATFORM]]] +// If you're building for an i386 Linux machine, kernel version 2.6 or +// higher, and you want to use native Linux threading operations +// instead of Posix threads, define this. Warning: this is highly +// experimental code, is likely to crash, and will probably be removed +// in the future. Use Posix threads instead; they're much better. +#define HAVE_LINUX_NATIVE_THREADS + // Do you want to build in support for threading (multiprocessing)? // Building in support for threading will enable Panda to take // advantage of multiple CPU's if you have them (and if the OS @@ -628,6 +634,14 @@ // Do you want to build the audio interface? #define HAVE_AUDIO 1 +// The Tau profiler provides a multiplatform, thread-aware profiler. +// To use it, define TAU_MAKEFILE appropriately, define USE_TAU to 1, +// and rebuild the code with ppremake; make install. +#define TAU_MAKEFILE /usr/local/tau/i386_linux/lib/Makefile.tau-pthread-pdt +#define TAU_OPTS -optKeepFiles +#define TAU_CFLAGS -D_GNU_SOURCE +#define USE_TAU + // Info for the RAD game tools, Miles Sound System // note this may be overwritten in wintools Config.pp #define RAD_MSS_IPATH /usr/include/Miles6/include @@ -837,7 +851,7 @@ // relevant flags. #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] -Wall -g #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] -Wall -g $[OPTFLAGS] -#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[OPTFLAGS] +#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] -g $[OPTFLAGS] #defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[OPTFLAGS] // What additional flags should be passed to both compilers when @@ -891,8 +905,8 @@ #defer SHARED_LIB_C++ $[cxx_ld] -undefined dynamic_lookup -dynamic -dynamiclib -o $[target] -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]] #defer BUNDLE_LIB_C++ $[cxx_ld] -undefined dynamic_lookup -bundle -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]] #else - #defer SHARED_LIB_C $[cc_ld] -shared -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] - #defer SHARED_LIB_C++ $[cxx_ld] -shared -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] + #defer SHARED_LIB_C $[cc_ld] -shared $[LFLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] + #defer SHARED_LIB_C++ $[cxx_ld] -shared $[LFLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] #define BUNDLE_LIB_C++ #endif diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index d97965797d..cd789476fa 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -459,6 +459,12 @@ $[cdefine HAVE_RTTI] /* Do we have Posix threads? */ $[cdefine HAVE_POSIX_THREADS] +/* Do we want to build for Linux native threads? */ +$[cdefine HAVE_LINUX_NATIVE_THREADS] + +/* Is the code being compiled with the Tau profiler's instrumentor? */ +$[cdefine USE_TAU] + /* Must global operator new and delete functions throw exceptions? */ $[cdefine GLOBAL_OPERATOR_NEW_EXCEPTIONS] @@ -490,38 +496,8 @@ $[cdefine USE_MEMORY_PTMALLOC2] $[cdefine USE_MEMORY_MALLOC] $[cdefine USE_MEMORY_NOWRAPPERS] -/* What style STL allocator should we declare? */ -#define OLD_STYLE_ALLOCATOR -#define GNU_STYLE_ALLOCATOR -#define VC6_STYLE_ALLOCATOR -#define MODERN_STYLE_ALLOCATOR -#define NO_STYLE_ALLOCATOR -#if $[not $[DO_MEMORY_USAGE]] - // Without DO_MEMORY_USAGE, we never try to use custom allocators. - #set NO_STYLE_ALLOCATOR 1 -#elif $[eq $[STL_ALLOCATOR], OLD] - // "OLD": Irix 6.2-era STL. - #set OLD_STYLE_ALLOCATOR 1 -#elif $[eq $[STL_ALLOCATOR], GNU] - // "GNU": gcc 2.95-era. - #set GNU_STYLE_ALLOCATOR 1 -#elif $[eq $[STL_ALLOCATOR], VC6] - // "VC6": Microsoft Visual C++ 6. - #set VC6_STYLE_ALLOCATOR 1 -#elif $[eq $[STL_ALLOCATOR], MODERN] - // "MODERN": Have we finally come to a standard? - #set MODERN_STYLE_ALLOCATOR 1 -#else - // Anything else is "unknown". We won't try to define allocators at - // all. - #set NO_STYLE_ALLOCATOR 1 -#endif -$[cdefine OLD_STYLE_ALLOCATOR] -$[cdefine GNU_STYLE_ALLOCATOR] -$[cdefine VC6_STYLE_ALLOCATOR] -$[cdefine MODERN_STYLE_ALLOCATOR] -$[cdefine NO_STYLE_ALLOCATOR] - +/* Can we define a modern-style STL allocator? */ +$[cdefine USE_STL_ALLOCATOR] $[cdefine IS_OSX] diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index 6bac30acfd..8045f2b166 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -331,6 +331,23 @@ // the target is not to be built. #defer build_target $[BUILD_TARGET] +#if $[USE_TAU] +#defer compile_c $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[COMPILE_C] $[TAU_CFLAGS] +#defer compile_c++ $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[COMPILE_C++] $[TAU_CFLAGS] $[TAU_C++FLAGS] +#defer link_bin_c $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[LINK_BIN_C] $[TAU_CFLAGS] +#defer link_bin_c++ $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[LINK_BIN_C++] $[TAU_CFLAGS] $[TAU_C++FLAGS] +#defer shared_lib_c $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[SHARED_LIB_C] $[TAU_CFLAGS] +#defer shared_lib_c++ $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[SHARED_LIB_C++] $[TAU_CFLAGS] $[TAU_C++FLAGS] + +#else +#defer compile_c $[COMPILE_C] +#defer compile_c++ $[COMPILE_C++] +#defer link_bin_c $[LINK_BIN_C] +#defer link_bin_c++ $[LINK_BIN_C++] +#defer shared_lib_c $[SHARED_LIB_C] +#defer shared_lib_c++ $[SHARED_LIB_C++] +#endif // USE_TAU + // This takes advantage of the above two variables to get the actual // list of local libraries we are to link with, eliminating those that @@ -358,7 +375,7 @@ #defer get_sources \ $[SOURCES] \ - $[if $[ne $[NO_COMBINED_SOURCES],], $[INCLUDED_SOURCES], $[get_combined_sources]] + $[if $[or $[NO_COMBINED_SOURCES],$[USE_TAU]], $[INCLUDED_SOURCES], $[get_combined_sources]] #defer included_sources $[INCLUDED_SOURCES] diff --git a/dtool/pptempl/Template.unix.pp b/dtool/pptempl/Template.unix.pp index f34edeeb38..8ab7e2240b 100644 --- a/dtool/pptempl/Template.unix.pp +++ b/dtool/pptempl/Template.unix.pp @@ -178,6 +178,10 @@ #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE]. ################################# DO NOT EDIT ########################### +#if $[USE_TAU] +include $[TAU_MAKEFILE] +#endif + // If we are using GNU make, this will automatically enable the // multiprocessor build mode according to the value in // NUMBER_OF_PROCESSORS, which should be set by NT. Maybe this isn't @@ -213,6 +217,9 @@ $[TAB] rm -f $[patsubst %.yxx,%.cxx %.h,$[yxx_st_sources]] $[patsubst %.lxx,%.cx #if $[py_sources] $[TAB] rm -f *.pyc *.pyo // Also scrub out old generated Python code. #endif +#if $[USE_TAU] +$[TAB] rm -f *.pdb *.inst.* // scrub out tau-generated files. +#endif // 'cleanall' is intended to undo all the effects of running ppremake // and building. It removes everything except the Makefile. @@ -344,9 +351,9 @@ $[varname] = $[sources] $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB] $[SHARED_LIB_C++] +$[TAB] $[shared_lib_c++] #else -$[TAB] $[SHARED_LIB_C] +$[TAB] $[shared_lib_c] #endif #if $[BUNDLE_EXT] @@ -454,9 +461,9 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define sources $($[varname]) $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB] $[SHARED_LIB_C++] +$[TAB] $[shared_lib_c++] #else -$[TAB] $[SHARED_LIB_C] +$[TAB] $[shared_lib_c] #endif #end noinst_lib_target @@ -555,9 +562,9 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define flags $[lflags] $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB] $[LINK_BIN_C++] +$[TAB] $[link_bin_c++] #else -$[TAB] $[LINK_BIN_C] +$[TAB] $[link_bin_c] #endif #define installed_files \ @@ -600,9 +607,9 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define flags $[lflags] $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] -$[TAB] $[LINK_BIN_C++] +$[TAB] $[link_bin_c++] #else -$[TAB] $[LINK_BIN_C] +$[TAB] $[link_bin_c] #endif #end noinst_bin_target test_bin_target @@ -680,7 +687,7 @@ $[TAB] cp $[target_prebuilt] $[target] #endif $[target] : $[source] $[get_depends $[source]] -$[TAB] $[COMPILE_C] +$[TAB] $[compile_c] #end file @@ -700,7 +707,7 @@ $[TAB] $[COMPILE_C] // Yacc must run before some files can be compiled, so all files // depend on yacc having run. $[target] : $[source] $[get_depends $[source]] $[yxx_sources:%.yxx=%.h] -$[TAB] $[COMPILE_C++] +$[TAB] $[compile_c++] #end file diff --git a/dtool/src/dtoolbase/Sources.pp b/dtool/src/dtoolbase/Sources.pp index 40ba6fffdf..f1a328c94f 100644 --- a/dtool/src/dtoolbase/Sources.pp +++ b/dtool/src/dtoolbase/Sources.pp @@ -1,25 +1,73 @@ +#define SELECT_TAU select.tau + #begin lib_target #define TARGET dtoolbase + + #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ + atomicAdjust.h \ + atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I \ + atomicAdjustI386Impl.h atomicAdjustI386Impl.I \ + atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ + atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ + atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ cmath.I cmath.h \ dallocator.T dallocator.h \ - dtoolbase.cxx dtoolbase.h dtoolbase_cc.h dtoolsymbols.h \ + deletedChain.h deletedChain.T \ + dtoolbase.h dtoolbase_cc.h dtoolsymbols.h \ fakestringstream.h \ indent.I indent.h indent.cxx \ + mutexImpl.h \ + mutexDummyImpl.h mutexDummyImpl.I \ + mutexNsprImpl.h mutexNsprImpl.I \ + mutexLinuxImpl.h mutexLinuxImpl.I \ + mutexPosixImpl.h mutexPosixImpl.I \ + mutexWin32Impl.h mutexWin32Impl.I \ nearly_zero.h \ + numeric_types.h \ + selectThreadImpl.h \ stl_compares.I stl_compares.h \ pallocator.T pallocator.h \ pdeque.h plist.h pmap.h pset.h pvector.h \ dlmalloc.c + #define INCLUDED_SOURCES \ + atomicAdjustDummyImpl.cxx \ + atomicAdjustI386Impl.cxx \ + atomicAdjustNsprImpl.cxx \ + atomicAdjustPosixImpl.cxx \ + atomicAdjustWin32Impl.cxx \ + dtoolbase.cxx \ + mutexDummyImpl.cxx \ + mutexNsprImpl.cxx \ + mutexLinuxImpl.cxx \ + mutexPosixImpl.cxx \ + mutexWin32Impl.cxx + #define INSTALL_HEADERS \ + atomicAdjust.h \ + atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I \ + atomicAdjustI386Impl.h atomicAdjustI386Impl.I \ + atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ + atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ + atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ cmath.I cmath.h \ dallocator.T dallocator.h \ + deletedChain.h deletedChain.T \ dtoolbase.h dtoolbase_cc.h dtoolsymbols.h fakestringstream.h \ indent.I indent.h \ + mutexImpl.h \ + mutexDummyImpl.h mutexDummyImpl.I \ + mutexNsprImpl.h mutexNsprImpl.I \ + mutexLinuxImpl.h mutexLinuxImpl.I \ + mutexPosixImpl.h mutexPosixImpl.I \ + mutexWin32Impl.h mutexWin32Impl.I \ nearly_zero.h \ + numeric_types.h \ + selectThreadImpl.h \ stl_compares.I stl_compares.h \ pallocator.T pallocator.h \ pdeque.h plist.h pmap.h pset.h pvector.h + #end lib_target diff --git a/panda/src/express/atomicAdjustImpl.h b/dtool/src/dtoolbase/atomicAdjust.h similarity index 59% rename from panda/src/express/atomicAdjustImpl.h rename to dtool/src/dtoolbase/atomicAdjust.h index 9c968f62d9..ac02b76233 100644 --- a/panda/src/express/atomicAdjustImpl.h +++ b/dtool/src/dtoolbase/atomicAdjust.h @@ -1,4 +1,4 @@ -// Filename: atomicAdjustImpl.h +// Filename: atomicAdjust.h // Created by: drose (09Aug02) // //////////////////////////////////////////////////////////////////// @@ -16,31 +16,43 @@ // //////////////////////////////////////////////////////////////////// -#ifndef ATOMICADJUSTIMPL_H -#define ATOMICADJUSTIMPL_H +#ifndef ATOMICADJUST_H +#define ATOMICADJUST_H -#include "pandabase.h" +#include "dtoolbase.h" #include "selectThreadImpl.h" #if defined(THREAD_DUMMY_IMPL) #include "atomicAdjustDummyImpl.h" -typedef AtomicAdjustDummyImpl AtomicAdjustImpl; +typedef AtomicAdjustDummyImpl AtomicAdjust; + +#elif defined(__i386__) +// For an i386 architecture, we'll always use the i386 implementation. +// It should be safe for any OS, and it might be a bit faster than +// any OS-provided calls. + +#include "atomicAdjustI386Impl.h" +typedef AtomicAdjustI386Impl AtomicAdjust; #elif defined(THREAD_WIN32_IMPL) #include "atomicAdjustWin32Impl.h" -typedef AtomicAdjustWin32Impl AtomicAdjustImpl; +typedef AtomicAdjustWin32Impl AtomicAdjust; + +#elif defined(THREAD_LINUX_IMPL) + +#error Linux native threads are currently implemented only for i386; use Posix threads instead. #elif defined(THREAD_POSIX_IMPL) #include "atomicAdjustPosixImpl.h" -typedef AtomicAdjustPosixImpl AtomicAdjustImpl; +typedef AtomicAdjustPosixImpl AtomicAdjust; #elif defined(THREAD_NSPR_IMPL) #include "atomicAdjustNsprImpl.h" -typedef AtomicAdjustNsprImpl AtomicAdjustImpl; +typedef AtomicAdjustNsprImpl AtomicAdjust; #endif diff --git a/panda/src/express/atomicAdjustDummyImpl.I b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I similarity index 59% rename from panda/src/express/atomicAdjustDummyImpl.I rename to dtool/src/dtoolbase/atomicAdjustDummyImpl.I index f4c64cc720..6ea0cab0ea 100644 --- a/panda/src/express/atomicAdjustDummyImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I @@ -20,23 +20,23 @@ //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustDummyImpl::inc // Access: Public, Static -// Description: Atomically increments the indicated variable and -// returns the new value. +// Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustDummyImpl:: +INLINE void AtomicAdjustDummyImpl:: inc(PN_int32 &var) { - return ++var; + ++var; } //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustDummyImpl::dec // Access: Public, Static // Description: Atomically decrements the indicated variable and -// returns the new value. +// returns true if the new value is nonzero, false if it +// is zero. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustDummyImpl:: +INLINE bool AtomicAdjustDummyImpl:: dec(PN_int32 &var) { - return --var; + return (--var) != 0; } //////////////////////////////////////////////////////////////////// @@ -65,3 +65,40 @@ INLINE PN_int32 AtomicAdjustDummyImpl:: get(const PN_int32 &var) { return var; } + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustDummyImpl::compare_and_exchange +// Access: Public, Static +// Description: Atomic compare and exchange. +// +// If mem is equal to old_value, store new_value in mem. +// In either case, return the original value of mem. +// The caller can test for success by comparing +// return_value == old_value. +//////////////////////////////////////////////////////////////////// +INLINE PN_int32 AtomicAdjustDummyImpl:: +compare_and_exchange(PN_int32 &mem, PN_int32 old_value, + PN_int32 new_value) { + PN_int32 orig_value = mem; + if (mem == old_value) { + mem = new_value; + } + return orig_value; +} + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustDummyImpl::compare_and_exchange_ptr +// Access: Public, Static +// Description: Atomic compare and exchange. +// +// As above, but works on pointers instead of integers. +//////////////////////////////////////////////////////////////////// +INLINE void *AtomicAdjustDummyImpl:: +compare_and_exchange_ptr(void *&mem, void *old_value, + void *new_value) { + void *orig_value = mem; + if (mem == old_value) { + mem = new_value; + } + return orig_value; +} diff --git a/panda/src/express/atomicAdjustDummyImpl.cxx b/dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx similarity index 100% rename from panda/src/express/atomicAdjustDummyImpl.cxx rename to dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx diff --git a/panda/src/express/atomicAdjustDummyImpl.h b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h similarity index 69% rename from panda/src/express/atomicAdjustDummyImpl.h rename to dtool/src/dtoolbase/atomicAdjustDummyImpl.h index 74ef86eaa4..696cb03f85 100644 --- a/panda/src/express/atomicAdjustDummyImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h @@ -19,26 +19,36 @@ #ifndef ATOMICADJUSTDUMMYIMPL_H #define ATOMICADJUSTDUMMYIMPL_H -#include "pandabase.h" +#include "dtoolbase.h" #include "selectThreadImpl.h" #ifdef THREAD_DUMMY_IMPL -#include "pnotify.h" #include "numeric_types.h" +#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1 +#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1 + //////////////////////////////////////////////////////////////////// // Class : AtomicAdjustDummyImpl // Description : A trivial implementation for atomic adjustments for // systems that don't require multiprogramming, and // therefore don't require special atomic operations. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustDummyImpl { +class EXPCL_DTOOL AtomicAdjustDummyImpl { public: - INLINE static PN_int32 inc(PN_int32 &var); - INLINE static PN_int32 dec(PN_int32 &var); + INLINE static void inc(PN_int32 &var); + INLINE static bool dec(PN_int32 &var); INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value); INLINE static PN_int32 get(const PN_int32 &var); + + INLINE static PN_int32 compare_and_exchange(PN_int32 &mem, + PN_int32 old_value, + PN_int32 new_value); + + INLINE static void *compare_and_exchange_ptr(void *&mem, + void *old_value, + void *new_value); }; #include "atomicAdjustDummyImpl.I" diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.I b/dtool/src/dtoolbase/atomicAdjustI386Impl.I new file mode 100644 index 0000000000..4b13776171 --- /dev/null +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.I @@ -0,0 +1,129 @@ +// Filename: atomicAdjustI386Impl.I +// Created by: drose (01Apr06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustI386Impl::inc +// Access: Public, Static +// Description: Atomically increments the indicated variable. +//////////////////////////////////////////////////////////////////// +INLINE void AtomicAdjustI386Impl:: +inc(volatile PN_int32 &var) { +#ifndef __EDG__ + __asm__ __volatile__("lock; incl %0" + :"=m" (var) + :"m" (&var)); +#endif // __EDG__ +} + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustI386Impl::dec +// Access: Public, Static +// Description: Atomically decrements the indicated variable and +// returns true if the new value is nonzero, false if it +// is zero. +//////////////////////////////////////////////////////////////////// +INLINE bool AtomicAdjustI386Impl:: +dec(volatile PN_int32 &var) { + unsigned char c; +#ifndef __EDG__ + __asm__ __volatile__("lock; decl %0; sete %1" + :"=m" (var), "=qm" (c) + :"m" (&var) : "memory"); +#endif // __EDG__ + return (c == 0); +} + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustI386Impl::set +// Access: Public, Static +// Description: Atomically changes the indicated variable and +// returns the original value. +//////////////////////////////////////////////////////////////////// +INLINE PN_int32 AtomicAdjustI386Impl:: +set(PN_int32 &var, PN_int32 new_value) { + PN_int32 orig_value = var; + var = new_value; + return orig_value; +} + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustI386Impl::get +// Access: Public, Static +// Description: Atomically retrieves the snapshot value of the +// indicated variable. This is the only guaranteed safe +// way to retrieve the value that other threads might be +// asynchronously setting, incrementing, or decrementing +// (via other AtomicAjust methods). +//////////////////////////////////////////////////////////////////// +INLINE PN_int32 AtomicAdjustI386Impl:: +get(const PN_int32 &var) { + return var; +} + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustI386Impl::compare_and_exchange +// Access: Public, Static +// Description: Atomic compare and exchange. +// +// If mem is equal to old_value, store new_value in mem. +// In either case, return the original value of mem. +// The caller can test for success by comparing +// return_value == old_value. +// +// The atomic function expressed in pseudo-code: +// +// orig_value = mem; +// if (mem == old_value) { +// mem = new_value; +// } +// return orig_value; +// +//////////////////////////////////////////////////////////////////// +INLINE PN_int32 AtomicAdjustI386Impl:: +compare_and_exchange(volatile PN_int32 &mem, PN_int32 old_value, + PN_int32 new_value) { + PN_int32 prev; +#ifndef __EDG__ + __asm__ __volatile__("lock; cmpxchgl %1,%2" + : "=a"(prev) + : "r"(new_value), "m"(mem), "0"(old_value) + : "memory"); +#endif // __EDG__ + return prev; +} + +//////////////////////////////////////////////////////////////////// +// Function: AtomicAdjustI386Impl::compare_and_exchange_ptr +// Access: Public, Static +// Description: Atomic compare and exchange. +// +// As above, but works on pointers instead of integers. +//////////////////////////////////////////////////////////////////// +INLINE void *AtomicAdjustI386Impl:: +compare_and_exchange_ptr(void * volatile &mem, void *old_value, + void *new_value) { + void *prev; +#ifndef __EDG__ + __asm__ __volatile__("lock; cmpxchgl %1,%2" + : "=a"(prev) + : "r"(new_value), "m"(mem), "0"(old_value) + : "memory"); +#endif // __EDG__ + return prev; +} diff --git a/panda/src/express/atomicAdjust.cxx b/dtool/src/dtoolbase/atomicAdjustI386Impl.cxx similarity index 78% rename from panda/src/express/atomicAdjust.cxx rename to dtool/src/dtoolbase/atomicAdjustI386Impl.cxx index 933d60e675..05ca809b28 100644 --- a/panda/src/express/atomicAdjust.cxx +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.cxx @@ -1,5 +1,5 @@ -// Filename: atomicAdjust.cxx -// Created by: drose (09Aug02) +// Filename: atomicAdjustI386Impl.cxx +// Created by: drose (28Mar06) // //////////////////////////////////////////////////////////////////// // @@ -16,4 +16,10 @@ // //////////////////////////////////////////////////////////////////// -#include "atomicAdjust.h" +#include "selectThreadImpl.h" + +#ifdef __i386__ + +#include "atomicAdjustI386Impl.h" + +#endif // __i386__ diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.h b/dtool/src/dtoolbase/atomicAdjustI386Impl.h new file mode 100644 index 0000000000..de76e20fb8 --- /dev/null +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.h @@ -0,0 +1,59 @@ +// Filename: atomicAdjustI386Impl.h +// Created by: drose (01Apr06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef ATOMICADJUSTI386IMPL_H +#define ATOMICADJUSTI386IMPL_H + +#include "dtoolbase.h" +#include "selectThreadImpl.h" + +#if defined(__i386__) + +#include "numeric_types.h" + +#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1 +#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1 + +//////////////////////////////////////////////////////////////////// +// Class : AtomicAdjustI386Impl +// Description : Uses assembly-language calls to atomically increment +// and decrement. Although this class is named i386, it +// actually uses instructions that are specific to 486 +// and higher. +//////////////////////////////////////////////////////////////////// +class EXPCL_DTOOL AtomicAdjustI386Impl { +public: + INLINE static void inc(volatile PN_int32 &var); + INLINE static bool dec(volatile PN_int32 &var); + INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value); + INLINE static PN_int32 get(const PN_int32 &var); + + INLINE static PN_int32 compare_and_exchange(volatile PN_int32 &mem, + PN_int32 old_value, + PN_int32 new_value); + + INLINE static void *compare_and_exchange_ptr(void * volatile &mem, + void *old_value, + void *new_value); +}; + +#include "atomicAdjustI386Impl.I" + +#endif // __i386__ + +#endif diff --git a/panda/src/express/atomicAdjustNsprImpl.I b/dtool/src/dtoolbase/atomicAdjustNsprImpl.I similarity index 88% rename from panda/src/express/atomicAdjustNsprImpl.I rename to dtool/src/dtoolbase/atomicAdjustNsprImpl.I index e93762b478..04313de4f5 100644 --- a/panda/src/express/atomicAdjustNsprImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustNsprImpl.I @@ -20,23 +20,23 @@ //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustNsprImpl::inc // Access: Public, Static -// Description: Atomically increments the indicated variable and -// returns the new value. +// Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustNsprImpl:: +INLINE void AtomicAdjustNsprImpl:: inc(PN_int32 &var) { - return PR_AtomicIncrement(&var); + PR_AtomicIncrement(&var); } //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustNsprImpl::dec // Access: Public, Static // Description: Atomically decrements the indicated variable and -// returns the new value. +// returns true if the new value is nonzero, false if it +// is zero. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustNsprImpl:: +INLINE bool AtomicAdjustNsprImpl:: dec(PN_int32 &var) { - return PR_AtomicDecrement(&var); + return (PR_AtomicDecrement(&var) != 0); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/atomicAdjustNsprImpl.cxx b/dtool/src/dtoolbase/atomicAdjustNsprImpl.cxx similarity index 100% rename from panda/src/express/atomicAdjustNsprImpl.cxx rename to dtool/src/dtoolbase/atomicAdjustNsprImpl.cxx diff --git a/panda/src/express/atomicAdjustNsprImpl.h b/dtool/src/dtoolbase/atomicAdjustNsprImpl.h similarity index 89% rename from panda/src/express/atomicAdjustNsprImpl.h rename to dtool/src/dtoolbase/atomicAdjustNsprImpl.h index 2df1afe8ff..6a3c1547b7 100644 --- a/panda/src/express/atomicAdjustNsprImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustNsprImpl.h @@ -24,7 +24,6 @@ #ifdef THREAD_NSPR_IMPL -#include "pnotify.h" #include "numeric_types.h" #include @@ -33,10 +32,10 @@ // Class : AtomicAdjustNsprImpl // Description : Uses NSPR to implement atomic adjustments. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustNsprImpl { +class EXPCL_DTOOL AtomicAdjustNsprImpl { public: - INLINE static PN_int32 inc(PN_int32 &var); - INLINE static PN_int32 dec(PN_int32 &var); + INLINE static void inc(PN_int32 &var); + INLINE static bool dec(PN_int32 &var); INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value); INLINE static PN_int32 get(const PN_int32 &var); }; diff --git a/panda/src/express/atomicAdjustPosixImpl.I b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I similarity index 90% rename from panda/src/express/atomicAdjustPosixImpl.I rename to dtool/src/dtoolbase/atomicAdjustPosixImpl.I index e5eb7d8b79..2dcd3c883b 100644 --- a/panda/src/express/atomicAdjustPosixImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I @@ -20,29 +20,28 @@ //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustPosixImpl::inc // Access: Public, Static -// Description: Atomically increments the indicated variable and -// returns the new value. +// Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustPosixImpl:: +INLINE void AtomicAdjustPosixImpl:: inc(PN_int32 &var) { pthread_mutex_lock(&_mutex); - PN_int32 result = ++var; + ++var; pthread_mutex_unlock(&_mutex); - return result; } //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustPosixImpl::dec // Access: Public, Static // Description: Atomically decrements the indicated variable and -// returns the new value. +// returns true if the new value is nonzero, false if it +// is zero. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustPosixImpl:: +INLINE bool AtomicAdjustPosixImpl:: dec(PN_int32 &var) { pthread_mutex_lock(&_mutex); PN_int32 result = --var; pthread_mutex_unlock(&_mutex); - return result; + return (result != 0); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/atomicAdjustPosixImpl.cxx b/dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx similarity index 100% rename from panda/src/express/atomicAdjustPosixImpl.cxx rename to dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx diff --git a/panda/src/express/atomicAdjustPosixImpl.h b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h similarity index 87% rename from panda/src/express/atomicAdjustPosixImpl.h rename to dtool/src/dtoolbase/atomicAdjustPosixImpl.h index 4fe882a22d..b79dab296c 100644 --- a/panda/src/express/atomicAdjustPosixImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h @@ -19,12 +19,11 @@ #ifndef ATOMICADJUSTPOSIXIMPL_H #define ATOMICADJUSTPOSIXIMPL_H -#include "pandabase.h" +#include "dtoolbase.h" #include "selectThreadImpl.h" #ifdef THREAD_POSIX_IMPL -#include "pnotify.h" #include "numeric_types.h" #include @@ -33,10 +32,10 @@ // Class : AtomicAdjustPosixImpl // Description : Uses POSIX to implement atomic adjustments. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustPosixImpl { +class EXPCL_DTOOL AtomicAdjustPosixImpl { public: - INLINE static PN_int32 inc(PN_int32 &var); - INLINE static PN_int32 dec(PN_int32 &var); + INLINE static void inc(PN_int32 &var); + INLINE static bool dec(PN_int32 &var); INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value); INLINE static PN_int32 get(const PN_int32 &var); diff --git a/panda/src/express/atomicAdjustWin32Impl.I b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I similarity index 87% rename from panda/src/express/atomicAdjustWin32Impl.I rename to dtool/src/dtoolbase/atomicAdjustWin32Impl.I index c8e5c49c7f..ec19e900be 100644 --- a/panda/src/express/atomicAdjustWin32Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I @@ -20,23 +20,23 @@ //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustWin32Impl::inc // Access: Public, Static -// Description: Atomically increments the indicated variable and -// returns the new value. +// Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustWin32Impl:: +INLINE void AtomicAdjustWin32Impl:: inc(PN_int32 &var) { - return InterlockedIncrement((LONG *)&var); + InterlockedIncrement((LONG *)&var); } //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustWin32Impl::dec // Access: Public, Static // Description: Atomically decrements the indicated variable and -// returns the new value. +// returns true if the new value is nonzero, false if it +// is zero. //////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjustWin32Impl:: +INLINE bool AtomicAdjustWin32Impl:: dec(PN_int32 &var) { - return InterlockedDecrement((LONG *)&var); + return (InterlockedDecrement((LONG *)&var) != 0); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/atomicAdjustWin32Impl.cxx b/dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx similarity index 100% rename from panda/src/express/atomicAdjustWin32Impl.cxx rename to dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx diff --git a/panda/src/express/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h similarity index 89% rename from panda/src/express/atomicAdjustWin32Impl.h rename to dtool/src/dtoolbase/atomicAdjustWin32Impl.h index 9bbd1625b2..b85e4e36f8 100644 --- a/panda/src/express/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -24,7 +24,6 @@ #ifdef THREAD_WIN32_IMPL -#include "pnotify.h" #include "numeric_types.h" #include @@ -34,10 +33,10 @@ // Description : Uses Windows native calls to implement atomic // adjustments. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustWin32Impl { +class EXPCL_DTOOL AtomicAdjustWin32Impl { public: - INLINE static PN_int32 inc(PN_int32 &var); - INLINE static PN_int32 dec(PN_int32 &var); + INLINE static void inc(PN_int32 &var); + INLINE static bool dec(PN_int32 &var); INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value); INLINE static PN_int32 get(const PN_int32 &var); }; diff --git a/dtool/src/dtoolbase/dallocator.T b/dtool/src/dtoolbase/dallocator.T index fd6a0cd8bb..08c2747147 100644 --- a/dtool/src/dtoolbase/dallocator.T +++ b/dtool/src/dtoolbase/dallocator.T @@ -16,46 +16,6 @@ // //////////////////////////////////////////////////////////////////// -#if defined(OLD_STYLE_ALLOCATOR) - -template -INLINE Type *dallocator:: -allocate(size_t n) { - return (Type *)default_operator_new(n); -} - -template -INLINE void dallocator:: -deallocate(void *p, size_t) { - default_operator_delete(p); -} - -#elif defined(GNU_STYLE_ALLOCATOR) - -template -INLINE dallocator:: -dallocator() { -} - -template -template -INLINE dallocator:: -dallocator(const dallocator<_Tp1> &) { -} - -template -INLINE Type *dallocator:: -allocate(size_t n) { - return (Type *)default_operator_new(n * sizeof(Type)); -} - -template -INLINE void dallocator:: -deallocate(void *p, size_t) { - default_operator_delete(p); -} - -#elif MODERN_STYLE_ALLOCATOR template INLINE dallocator:: @@ -73,5 +33,3 @@ INLINE void dallocator:: deallocate(TYPENAME dallocator::pointer p, TYPENAME dallocator::size_type) { (*global_operator_delete)(p); } - -#endif // *_STYLE_ALLOCATOR diff --git a/dtool/src/dtoolbase/dallocator.h b/dtool/src/dtoolbase/dallocator.h index 446da84edf..165fac34c1 100644 --- a/dtool/src/dtoolbase/dallocator.h +++ b/dtool/src/dtoolbase/dallocator.h @@ -35,46 +35,14 @@ // within the MemoryUsage class itself. //////////////////////////////////////////////////////////////////// -#if defined(NO_STYLE_ALLOCATOR) +#ifndef USE_STL_ALLOCATOR // If we're not trying to make custom allocators (either we don't know // what kind of syntax this STL library wants, or we're compiling with // OPTIMIZE 4), then simply use the standard allocator. #define dallocator allocator -#elif defined(OLD_STYLE_ALLOCATOR) -// Early versions of gcc wanted to use their own kind of allocator, -// somewhat different from the STL standard. Irix uses this one too. -// It might be inherited from an early draft of the STL standard. +#else -template -class dallocator : public alloc { -public: - INLINE static Type *allocate(size_t n); - INLINE static void deallocate(void *p, size_t n); -}; - -#elif defined(GNU_STYLE_ALLOCATOR) -// Later versions of gcc want to use a still different, -// not-quite-standard definition. Sheesh. - -template -class dallocator : public allocator { -public: - INLINE dallocator(); - template - INLINE dallocator(const dallocator<_Tp1> &other); - - INLINE Type *allocate(size_t n); - INLINE void deallocate(void *p, size_t n); - - template struct rebind { - typedef dallocator<_Tp1> other; - }; -}; - -#elif defined(MODERN_STYLE_ALLOCATOR) - -// The final specification? template class dallocator : public allocator { public: @@ -95,31 +63,14 @@ public: INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); INLINE void deallocate(pointer p, size_type n); - /* -#ifdef __GNUC__ - template - INLINE void destroy(Subtype *p) { - p->~Subtype(); - } - template - INLINE void construct(Subtype *p, const Subtype &value) { - ::new(p) Subtype(value); - } -#endif // __GNUC__ - */ - template struct rebind { typedef dallocator other; }; }; -#else -#error Unrecognized allocator symbol defined! -#endif // *_STYLE_ALLOCATOR - -#ifndef NO_STYLE_ALLOCATOR #include "dallocator.T" -#endif + +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/deletedChain.T b/dtool/src/dtoolbase/deletedChain.T new file mode 100644 index 0000000000..8f403b4590 --- /dev/null +++ b/dtool/src/dtoolbase/deletedChain.T @@ -0,0 +1,100 @@ +// Filename: deletedChain.T +// Created by: drose (01Apr06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +template +TYPENAME DeletedChain::ObjectNode *DeletedChain::_deleted_chain; + +#ifndef HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR +template +MutexImpl DeletedChain::_lock; +#endif + +//////////////////////////////////////////////////////////////////// +// Function: DeletedChain::allocate +// Access: Public, Static +// Description: Allocates the memory for a new object of Type. +//////////////////////////////////////////////////////////////////// +template +INLINE Type *DeletedChain:: +allocate(size_t size) { + assert(size <= sizeof(Type)); + +#ifndef HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR + _lock.lock(); + if (_deleted_chain != (ObjectNode *)NULL) { + ObjectNode *obj = _deleted_chain; + _deleted_chain = _deleted_chain->_next; + _lock.release(); + return (Type *)obj; + } + _lock.release(); + +#else // HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR + ObjectNode *obj = _deleted_chain; + while (obj != (ObjectNode *)NULL) { + ObjectNode *result = (ObjectNode *)AtomicAdjust::compare_and_exchange_ptr((void *&)_deleted_chain, (void *)obj, (void *)obj->_next); + if (result == obj) { + // We got it. + return (Type *)obj; + } + // Someone else grabbed the top link first. Try again. + obj = _deleted_chain; + } + +#endif // HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR + + // If we get here, the deleted_chain is empty; we have to allocate a + // new object from the system pool. + +#ifdef DO_MEMORY_USAGE + return (Type *)(*global_operator_new)(sizeof(Type)); +#else + return (Type *)malloc(sizeof(Type)); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: DeletedChain::deallocate +// Access: Public +// Description: Frees the memory for an object of Type. +//////////////////////////////////////////////////////////////////// +template +INLINE void DeletedChain:: +deallocate(Type *ptr) { +#ifndef HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR + _lock.lock(); + + ObjectNode *obj = (ObjectNode *)ptr; + obj->_next = _deleted_chain; + _deleted_chain = obj; + + _lock.release(); + +#else // HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR + + ObjectNode *obj = (ObjectNode *)ptr; + ObjectNode *result; + + do { + obj->_next = _deleted_chain; + result = (ObjectNode *)AtomicAdjust::compare_and_exchange_ptr((void *&)_deleted_chain, (void *)obj->_next, (void *)obj); + // Keep trying until no one else got to _deleted_chain first. + } while (result != obj->_next); + +#endif // HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR +} diff --git a/dtool/src/dtoolbase/deletedChain.h b/dtool/src/dtoolbase/deletedChain.h new file mode 100644 index 0000000000..2440266778 --- /dev/null +++ b/dtool/src/dtoolbase/deletedChain.h @@ -0,0 +1,99 @@ +// Filename: deletedChain.h +// Created by: drose (01Apr06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef DELETEDCHAIN_H +#define DELETEDCHAIN_H + +#include "dtoolbase.h" + +#include "mutexImpl.h" +#include "atomicAdjust.h" +#include + +//////////////////////////////////////////////////////////////////// +// Class : DeletedChain +// Description : This template class can be used to provide faster +// allocation/deallocation for many Panda objects. It +// works by maintaining a linked list of deleted objects +// that are all of the same type; when a new object is +// allocated that matches that type, the same space is +// just reused. +// +// This is particularly important to do in the case of a +// multithreaded pipeline, so we minimize contention +// between the parallel threads. If we didn't do this, +// the threads might compete overmuch on the system +// mutex protecting the malloc() call. This way, there +// can be a different mutex for each type of object; or on +// some systems (e.g. i386), no mutex at all. +// +// Of course, this trick of maintaining the deleted +// object chain won't work in the presence of +// polymorphism, where you might have many classes that +// derive from a base class, and all of them have a +// different size--unless you instantiate a DeletedChain +// for *every* kind of derived class. The +// ALLOC_DELETED_CHAIN macro, below, is designed to make +// this easy. +//////////////////////////////////////////////////////////////////// +template +class DeletedChain { +public: + INLINE static Type *allocate(size_t size); + INLINE static void deallocate(Type *ptr); + +private: + class ObjectNode { + public: + ObjectNode *_next; + }; + + // Ideally, the compiler and linker will unify all references to + // this static pointer for a given type, as per the C++ spec. + // However, if the compiler fails to do this (*cough* Microsoft), it + // won't be a big deal; it just means there will be multiple + // unrelated chains of deleted objects for a particular type. + static ObjectNode *_deleted_chain; + +#ifndef HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR + // If we don't have atomic compare-and-exchange, we need to use a + // Mutex to protect the above linked list. + static MutexImpl _lock; +#endif +}; + +// Place this macro within a class definition to define appropriate +// operator new and delete methods that take advantage of +// DeletedChain. +#define ALLOC_DELETED_CHAIN(Type) \ + inline void *operator new(size_t size) { \ + return (void *)DeletedChain::allocate(size); \ + } \ + inline void *operator new(size_t size, void *ptr) { \ + return ptr; \ + } \ + inline void operator delete(void *ptr) { \ + DeletedChain::deallocate((Type *)ptr); \ + } \ + inline void operator delete(void *, void *) { \ + } + +#include "deletedChain.T" + +#endif + diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index d60c4960f7..67408c2ff1 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -138,6 +138,108 @@ #include #endif +#ifdef USE_TAU +/* If we're building with the Tau instrumentor, include the + appropriate header file to pick up the TAU macros. */ +#include +#else +/* Otherwise, if we're not building with the Tau instrumentor, turn + off all the TAU macros. We could include the Tau header file to do + this, but it's better not to assume that Tau is installed. */ +#define TAU_TYPE_STRING(profileString, str) +#define TAU_PROFILE(name, type, group) +#define TAU_PROFILE_TIMER(var, name, type, group) +#define TAU_PROFILE_START(var) +#define TAU_PROFILE_STOP(var) +#define TAU_PROFILE_STMT(stmt) +#define TAU_PROFILE_EXIT(msg) +#define TAU_PROFILE_INIT(argc, argv) +#define TAU_PROFILE_SET_NODE(node) +#define TAU_PROFILE_SET_CONTEXT(context) +#define TAU_PROFILE_SET_GROUP_NAME(newname) +#define TAU_PROFILE_TIMER_SET_GROUP_NAME(t, newname) +#define TAU_PROFILE_CALLSTACK() +#define TAU_DB_DUMP() +#define TAU_DB_PURGE() + +#define TAU_REGISTER_CONTEXT_EVENT(event, name) +#define TAU_CONTEXT_EVENT(event, data) +#define TAU_DISABLE_CONTEXT_EVENT(event) +#define TAU_ENABLE_CONTEXT_EVENT(event) + +#define TAU_REGISTER_EVENT(event, name) +#define TAU_EVENT(event, data) +#define TAU_EVENT_DISABLE_MIN(event) +#define TAU_EVENT_DISABLE_MAX(event) +#define TAU_EVENT_DISABLE_MEAN(event) +#define TAU_EVENT_DISABLE_STDDEV(event) +#define TAU_REPORT_STATISTICS() +#define TAU_REPORT_THREAD_STATISTICS() +#define TAU_REGISTER_THREAD() +#define TAU_REGISTER_FORK(id, op) +#define TAU_ENABLE_INSTRUMENTATION() +#define TAU_DISABLE_INSTRUMENTATION() +#define TAU_ENABLE_GROUP(group) +#define TAU_DISABLE_GROUP(group) +#define TAU_ENABLE_GROUP_NAME(group) +#define TAU_DISABLE_GROUP_NAME(group) +#define TAU_ENABLE_ALL_GROUPS() +#define TAU_DISABLE_ALL_GROUPS() +#define TAU_TRACK_MEMORY() +#define TAU_TRACK_MEMORY_HERE() +#define TAU_ENABLE_TRACKING_MEMORY() +#define TAU_DISABLE_TRACKING_MEMORY() +#define TAU_TRACK_MEMORY() +#define TAU_TRACK_MEMORY_HERE() +#define TAU_ENABLE_TRACKING_MUSE_EVENTS() +#define TAU_DISABLE_TRACKING_MUSE_EVENTS() +#define TAU_TRACK_MUSE_EVENTS() +#define TAU_SET_INTERRUPT_INTERVAL(value) + +#define TAU_TRACE_SENDMSG(type, destination, length) +#define TAU_TRACE_RECVMSG(type, source, length) + +#define TAU_MAPPING(stmt, group) stmt +#define TAU_MAPPING_OBJECT(FuncInfoVar) +#define TAU_MAPPING_LINK(FuncInfoVar, Group) +#define TAU_MAPPING_PROFILE(FuncInfoVar) +#define TAU_MAPPING_CREATE(name, type, key, groupname, tid) +#define TAU_MAPPING_PROFILE_TIMER(Timer, FuncInfoVar, tid) +#define TAU_MAPPING_TIMER_CREATE(t, name, type, gr, group_name) +#define TAU_MAPPING_PROFILE_START(Timer, tid) +#define TAU_MAPPING_PROFILE_STOP(tid) +#define TAU_MAPPING_PROFILE_EXIT(msg, tid) +#define TAU_MAPPING_DB_DUMP(tid) +#define TAU_MAPPING_DB_PURGE(tid) +#define TAU_MAPPING_PROFILE_SET_NODE(node, tid) +#define TAU_MAPPING_PROFILE_SET_GROUP_NAME(timer, name) +#define TAU_PROFILE_TIMER_SET_NAME(t, newname) +#define TAU_PROFILE_TIMER_SET_TYPE(t, newname) +#define TAU_PROFILE_TIMER_SET_GROUP(t, id) +#define TAU_MAPPING_PROFILE_SET_NAME(timer, name) +#define TAU_MAPPING_PROFILE_SET_TYPE(timer, name) +#define TAU_MAPPING_PROFILE_SET_GROUP(timer, id) +#define TAU_MAPPING_PROFILE_GET_GROUP_NAME(timer) +#define TAU_MAPPING_PROFILE_GET_GROUP(timer) +#define TAU_MAPPING_PROFILE_GET_NAME(timer) +#define TAU_MAPPING_PROFILE_GET_TYPE(timer) + +#define TAU_PHASE(name, type, group) +#define TAU_PHASE_CREATE_STATIC(var, name, type, group) +#define TAU_PHASE_CREATE_DYNAMIC(var, name, type, group) +#define TAU_PHASE_START(var) +#define TAU_PHASE_STOP(var) +#define TAU_GLOBAL_PHASE(timer, name, type, group) +#define TAU_GLOBAL_PHASE_START(timer) +#define TAU_GLOBAL_PHASE_STOP(timer) +#define TAU_GLOBAL_PHASE_EXTERNAL(timer) +#define TAU_GLOBAL_TIMER(timer, name, type, group) +#define TAU_GLOBAL_TIMER_EXTERNAL(timer) +#define TAU_GLOBAL_TIMER_START(timer) +#define TAU_GLOBAL_TIMER_STOP() + +#endif // USE_TAU + /* We define the macros BEGIN_PUBLISH and END_PUBLISH to bracket functions and global variable definitions that are to be published diff --git a/dtool/src/dtoolbase/dtoolbase_composite1.cxx b/dtool/src/dtoolbase/dtoolbase_composite1.cxx new file mode 100644 index 0000000000..863cdc8887 --- /dev/null +++ b/dtool/src/dtoolbase/dtoolbase_composite1.cxx @@ -0,0 +1,5 @@ +#include "atomicAdjustDummyImpl.cxx" +#include "atomicAdjustI386Impl.cxx" +#include "atomicAdjustNsprImpl.cxx" +#include "atomicAdjustPosixImpl.cxx" +#include "atomicAdjustWin32Impl.cxx" diff --git a/dtool/src/dtoolbase/dtoolbase_composite2.cxx b/dtool/src/dtoolbase/dtoolbase_composite2.cxx new file mode 100644 index 0000000000..c99a7d363f --- /dev/null +++ b/dtool/src/dtoolbase/dtoolbase_composite2.cxx @@ -0,0 +1,6 @@ +#include "dtoolbase.cxx" +#include "mutexDummyImpl.cxx" +#include "mutexNsprImpl.cxx" +#include "mutexLinuxImpl.cxx" +#include "mutexPosixImpl.cxx" +#include "mutexWin32Impl.cxx" diff --git a/dtool/src/interrogatedb/mutexDummyImpl.I b/dtool/src/dtoolbase/mutexDummyImpl.I similarity index 100% rename from dtool/src/interrogatedb/mutexDummyImpl.I rename to dtool/src/dtoolbase/mutexDummyImpl.I diff --git a/dtool/src/interrogatedb/mutexDummyImpl.cxx b/dtool/src/dtoolbase/mutexDummyImpl.cxx similarity index 100% rename from dtool/src/interrogatedb/mutexDummyImpl.cxx rename to dtool/src/dtoolbase/mutexDummyImpl.cxx diff --git a/dtool/src/interrogatedb/mutexDummyImpl.h b/dtool/src/dtoolbase/mutexDummyImpl.h similarity index 95% rename from dtool/src/interrogatedb/mutexDummyImpl.h rename to dtool/src/dtoolbase/mutexDummyImpl.h index 6fa8759a04..9d651a8be9 100644 --- a/dtool/src/interrogatedb/mutexDummyImpl.h +++ b/dtool/src/dtoolbase/mutexDummyImpl.h @@ -24,15 +24,13 @@ #ifdef THREAD_DUMMY_IMPL -#include "pnotify.h" - //////////////////////////////////////////////////////////////////// // Class : MutexDummyImpl // Description : A fake mutex implementation for single-threaded // applications that don't need any synchronization // control. This does nothing at all. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG MutexDummyImpl { +class EXPCL_DTOOL MutexDummyImpl { public: INLINE MutexDummyImpl(); INLINE ~MutexDummyImpl(); diff --git a/dtool/src/interrogatedb/mutexImpl.h b/dtool/src/dtoolbase/mutexImpl.h similarity index 89% rename from dtool/src/interrogatedb/mutexImpl.h rename to dtool/src/dtoolbase/mutexImpl.h index e874194c09..63c1ab455e 100644 --- a/dtool/src/interrogatedb/mutexImpl.h +++ b/dtool/src/dtoolbase/mutexImpl.h @@ -36,6 +36,12 @@ typedef MutexWin32Impl MutexImpl; typedef MutexWin32Impl ReMutexImpl; // Win32 Mutexes are always reentrant. #define HAVE_REMUTEXIMPL 1 +#elif defined(THREAD_LINUX_IMPL) + +#include "mutexLinuxImpl.h" +typedef MutexLinuxImpl MutexImpl; +#undef HAVE_REMUTEXIMPL // The futex implementation is non-reentrant. + #elif defined(THREAD_POSIX_IMPL) #include "mutexPosixImpl.h" diff --git a/dtool/src/dtoolbase/mutexLinuxImpl.I b/dtool/src/dtoolbase/mutexLinuxImpl.I new file mode 100644 index 0000000000..a0b5a45ce1 --- /dev/null +++ b/dtool/src/dtoolbase/mutexLinuxImpl.I @@ -0,0 +1,38 @@ +// Filename: mutexLinuxImpl.I +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: MutexLinuxImpl::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE MutexLinuxImpl:: +MutexLinuxImpl() { + _mode = M_unlocked; +} + +//////////////////////////////////////////////////////////////////// +// Function: MutexLinuxImpl::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE MutexLinuxImpl:: +~MutexLinuxImpl() { + assert(_mode == M_unlocked); +} diff --git a/dtool/src/dtoolbase/mutexLinuxImpl.cxx b/dtool/src/dtoolbase/mutexLinuxImpl.cxx new file mode 100644 index 0000000000..0436e9c69c --- /dev/null +++ b/dtool/src/dtoolbase/mutexLinuxImpl.cxx @@ -0,0 +1,64 @@ +// Filename: mutexLinuxImpl.cxx +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "selectThreadImpl.h" + +#ifdef THREAD_LINUX_IMPL + +#include "mutexLinuxImpl.h" +#include "atomicAdjust.h" + +#include +#include +#include + +//////////////////////////////////////////////////////////////////// +// Function: MutexLinuxImpl::lock +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void MutexLinuxImpl:: +lock() { + PN_int32 c; + c = AtomicAdjust::compare_and_exchange + (_mode, M_unlocked, M_locked_no_waiters); + while (c != M_unlocked) { + if (c == M_locked_with_waiters || + AtomicAdjust::compare_and_exchange(_mode, M_locked_no_waiters, + M_locked_with_waiters) != M_unlocked) { + syscall(SYS_futex, &_mode, FUTEX_WAIT, M_locked_with_waiters, (void *)NULL); + } + c = AtomicAdjust::compare_and_exchange + (_mode, M_unlocked, M_locked_with_waiters); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: MutexLinuxImpl::release +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void MutexLinuxImpl:: +release() { + if (AtomicAdjust::dec(_mode)) { + _mode = M_unlocked; + syscall(SYS_futex, &_mode, FUTEX_WAKE, 1); + } +} + +#endif // THREAD_LINUX_IMPL diff --git a/panda/src/express/atomicAdjust.h b/dtool/src/dtoolbase/mutexLinuxImpl.h similarity index 53% rename from panda/src/express/atomicAdjust.h rename to dtool/src/dtoolbase/mutexLinuxImpl.h index f1fcbc12e0..560bdd04e3 100644 --- a/panda/src/express/atomicAdjust.h +++ b/dtool/src/dtoolbase/mutexLinuxImpl.h @@ -1,5 +1,5 @@ -// Filename: atomicAdjust.h -// Created by: drose (09Aug02) +// Filename: mutexLinuxImpl.h +// Created by: drose (28Mar06) // //////////////////////////////////////////////////////////////////// // @@ -16,28 +16,43 @@ // //////////////////////////////////////////////////////////////////// -#ifndef ATOMICADJUST_H -#define ATOMICADJUST_H +#ifndef MUTEXLINUXIMPL_H +#define MUTEXLINUXIMPL_H + +#include "dtoolbase.h" +#include "selectThreadImpl.h" + +#ifdef THREAD_LINUX_IMPL -#include "pandabase.h" -#include "atomicAdjustImpl.h" #include "numeric_types.h" +#undef MUTEX_DEFINES_TRYLOCK + //////////////////////////////////////////////////////////////////// -// Class : AtomicAdjust -// Description : A suite of functions to atomically adjust a numeric -// value. Some platforms require a bit more work than -// others to guarantee that a multibyte value is changed -// in one atomic operation. +// Class : MutexLinuxImpl +// Description : Uses Linux threads to implement a mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjust { +class EXPCL_DTOOL MutexLinuxImpl { public: - INLINE static PN_int32 inc(PN_int32 &var); - INLINE static PN_int32 dec(PN_int32 &var); - INLINE static PN_int32 set(PN_int32 &var, PN_int32 new_value); - INLINE static PN_int32 get(const PN_int32 &var); + INLINE MutexLinuxImpl(); + INLINE ~MutexLinuxImpl(); + + void lock(); + void release(); + +private: + enum Mode { + M_unlocked = 0, + M_locked_no_waiters = 1, + M_locked_with_waiters = 2, + }; + + PN_int32 _mode; + friend class ConditionVarLinuxImpl; }; -#include "atomicAdjust.I" +#include "mutexLinuxImpl.I" + +#endif // THREAD_LINUX_IMPL #endif diff --git a/dtool/src/interrogatedb/mutexNsprImpl.I b/dtool/src/dtoolbase/mutexNsprImpl.I similarity index 96% rename from dtool/src/interrogatedb/mutexNsprImpl.I rename to dtool/src/dtoolbase/mutexNsprImpl.I index ffe3ac2b76..5dda0c41b7 100644 --- a/dtool/src/interrogatedb/mutexNsprImpl.I +++ b/dtool/src/dtoolbase/mutexNsprImpl.I @@ -25,7 +25,7 @@ INLINE MutexNsprImpl:: MutexNsprImpl() { _lock = PR_NewLock(); - nassertv(_lock != (PRLock *)NULL); + assert(_lock != (PRLock *)NULL); } //////////////////////////////////////////////////////////////////// @@ -68,5 +68,5 @@ try_lock() { INLINE void MutexNsprImpl:: release() { int status = PR_Unlock(_lock); - nassertv(status == PR_SUCCESS); + assert(status == PR_SUCCESS); } diff --git a/dtool/src/interrogatedb/mutexNsprImpl.cxx b/dtool/src/dtoolbase/mutexNsprImpl.cxx similarity index 100% rename from dtool/src/interrogatedb/mutexNsprImpl.cxx rename to dtool/src/dtoolbase/mutexNsprImpl.cxx diff --git a/dtool/src/interrogatedb/mutexNsprImpl.h b/dtool/src/dtoolbase/mutexNsprImpl.h similarity index 95% rename from dtool/src/interrogatedb/mutexNsprImpl.h rename to dtool/src/dtoolbase/mutexNsprImpl.h index ca4aa96664..cc9a018256 100644 --- a/dtool/src/interrogatedb/mutexNsprImpl.h +++ b/dtool/src/dtoolbase/mutexNsprImpl.h @@ -24,8 +24,6 @@ #ifdef THREAD_NSPR_IMPL -#include "pnotify.h" - #include #undef MUTEX_DEFINES_TRYLOCK @@ -34,7 +32,7 @@ // Class : MutexNsprImpl // Description : Uses NSPR to implement a mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG MutexNsprImpl { +class EXPCL_DTOOL MutexNsprImpl { public: INLINE MutexNsprImpl(); INLINE ~MutexNsprImpl(); diff --git a/dtool/src/interrogatedb/mutexPosixImpl.I b/dtool/src/dtoolbase/mutexPosixImpl.I similarity index 82% rename from dtool/src/interrogatedb/mutexPosixImpl.I rename to dtool/src/dtoolbase/mutexPosixImpl.I index 5a7595f954..29a0c09019 100644 --- a/dtool/src/interrogatedb/mutexPosixImpl.I +++ b/dtool/src/dtoolbase/mutexPosixImpl.I @@ -24,12 +24,13 @@ //////////////////////////////////////////////////////////////////// INLINE MutexPosixImpl:: MutexPosixImpl() { + TAU_PROFILE("MutexPosixImpl::MutexPosixImpl", " ", TAU_USER); pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); int result = pthread_mutex_init(&_lock, &attr); pthread_mutexattr_destroy(&attr); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -39,8 +40,9 @@ MutexPosixImpl() { //////////////////////////////////////////////////////////////////// INLINE MutexPosixImpl:: ~MutexPosixImpl() { + TAU_PROFILE("MutexPosixImpl::~MutexPosixImpl", " ", TAU_USER); int result = pthread_mutex_destroy(&_lock); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -50,8 +52,9 @@ INLINE MutexPosixImpl:: //////////////////////////////////////////////////////////////////// INLINE void MutexPosixImpl:: lock() { + TAU_PROFILE("MutexPosixImpl::lock", " ", TAU_USER); int result = pthread_mutex_lock(&_lock); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -61,8 +64,9 @@ lock() { //////////////////////////////////////////////////////////////////// INLINE bool MutexPosixImpl:: try_lock() { + TAU_PROFILE("MutexPosixImpl::try_lock", " ", TAU_USER); int result = pthread_mutex_trylock(&_lock); - nassertr(result == 0 || result == EBUSY, false); + assert(result == 0 || result == EBUSY); return (result == 0); } @@ -73,8 +77,9 @@ try_lock() { //////////////////////////////////////////////////////////////////// INLINE void MutexPosixImpl:: release() { + TAU_PROFILE("MutexPosixImpl::release", " ", TAU_USER); int result = pthread_mutex_unlock(&_lock); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -84,12 +89,13 @@ release() { //////////////////////////////////////////////////////////////////// INLINE ReMutexPosixImpl:: ReMutexPosixImpl() { + TAU_PROFILE("ReMutexPosixImpl::ReMutexPosixImpl", " ", TAU_USER); pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); int result = pthread_mutex_init(&_lock, &attr); pthread_mutexattr_destroy(&attr); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -99,8 +105,9 @@ ReMutexPosixImpl() { //////////////////////////////////////////////////////////////////// INLINE ReMutexPosixImpl:: ~ReMutexPosixImpl() { + TAU_PROFILE("ReMutexPosixImpl::~ReMutexPosixImpl", " ", TAU_USER); int result = pthread_mutex_destroy(&_lock); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -110,8 +117,9 @@ INLINE ReMutexPosixImpl:: //////////////////////////////////////////////////////////////////// INLINE void ReMutexPosixImpl:: lock() { + TAU_PROFILE("ReMutexPosixImpl::lock", " ", TAU_USER); int result = pthread_mutex_lock(&_lock); - nassertv(result == 0); + assert(result == 0); } //////////////////////////////////////////////////////////////////// @@ -121,8 +129,9 @@ lock() { //////////////////////////////////////////////////////////////////// INLINE bool ReMutexPosixImpl:: try_lock() { + TAU_PROFILE("ReMutexPosixImpl::try_lock", " ", TAU_USER); int result = pthread_mutex_trylock(&_lock); - nassertr(result == 0 || result == EBUSY, false); + assert(result == 0 || result == EBUSY); return (result == 0); } @@ -133,6 +142,7 @@ try_lock() { //////////////////////////////////////////////////////////////////// INLINE void ReMutexPosixImpl:: release() { + TAU_PROFILE("ReMutexPosixImpl::release", " ", TAU_USER); int result = pthread_mutex_unlock(&_lock); - nassertv(result == 0); + assert(result == 0); } diff --git a/dtool/src/interrogatedb/mutexPosixImpl.cxx b/dtool/src/dtoolbase/mutexPosixImpl.cxx similarity index 100% rename from dtool/src/interrogatedb/mutexPosixImpl.cxx rename to dtool/src/dtoolbase/mutexPosixImpl.cxx diff --git a/dtool/src/interrogatedb/mutexPosixImpl.h b/dtool/src/dtoolbase/mutexPosixImpl.h similarity index 94% rename from dtool/src/interrogatedb/mutexPosixImpl.h rename to dtool/src/dtoolbase/mutexPosixImpl.h index 73f38782a8..9b062efe67 100644 --- a/dtool/src/interrogatedb/mutexPosixImpl.h +++ b/dtool/src/dtoolbase/mutexPosixImpl.h @@ -24,8 +24,6 @@ #ifdef THREAD_POSIX_IMPL -#include "pnotify.h" - #include #include @@ -35,7 +33,7 @@ // Class : MutexPosixImpl // Description : Uses Posix threads to implement a mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG MutexPosixImpl { +class EXPCL_DTOOL MutexPosixImpl { public: INLINE MutexPosixImpl(); INLINE ~MutexPosixImpl(); @@ -53,7 +51,7 @@ private: // Class : ReMutexPosixImpl // Description : Uses Posix threads to implement a reentrant mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG ReMutexPosixImpl { +class EXPCL_DTOOL ReMutexPosixImpl { public: INLINE ReMutexPosixImpl(); INLINE ~ReMutexPosixImpl(); diff --git a/dtool/src/interrogatedb/mutexWin32Impl.I b/dtool/src/dtoolbase/mutexWin32Impl.I similarity index 100% rename from dtool/src/interrogatedb/mutexWin32Impl.I rename to dtool/src/dtoolbase/mutexWin32Impl.I diff --git a/dtool/src/interrogatedb/mutexWin32Impl.cxx b/dtool/src/dtoolbase/mutexWin32Impl.cxx similarity index 100% rename from dtool/src/interrogatedb/mutexWin32Impl.cxx rename to dtool/src/dtoolbase/mutexWin32Impl.cxx diff --git a/dtool/src/interrogatedb/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h similarity index 95% rename from dtool/src/interrogatedb/mutexWin32Impl.h rename to dtool/src/dtoolbase/mutexWin32Impl.h index aebf204e19..6d53be6661 100644 --- a/dtool/src/interrogatedb/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -24,8 +24,6 @@ #ifdef THREAD_WIN32_IMPL -#include "pnotify.h" - #include #define MUTEX_DEFINES_TRYLOCK 1 @@ -34,7 +32,7 @@ // Class : MutexWin32Impl // Description : Uses Windows native calls to implement a mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG MutexWin32Impl { +class EXPCL_DTOOL MutexWin32Impl { public: INLINE MutexWin32Impl(); INLINE ~MutexWin32Impl(); diff --git a/panda/src/express/numeric_types.h b/dtool/src/dtoolbase/numeric_types.h similarity index 100% rename from panda/src/express/numeric_types.h rename to dtool/src/dtoolbase/numeric_types.h diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index b91d556de6..076cfbf791 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -16,77 +16,42 @@ // //////////////////////////////////////////////////////////////////// -#if defined(OLD_STYLE_ALLOCATOR) - template -INLINE Type *pallocator:: -allocate(size_t n) { - return (Type *)(*global_operator_new)(n); +INLINE pallocator_single:: +pallocator_single() throw() { } template -INLINE void pallocator:: -deallocate(void *p, size_t) { +INLINE TYPENAME pallocator_single::pointer pallocator_single:: +allocate(TYPENAME pallocator_single::size_type n, TYPENAME allocator::const_pointer) { + TAU_PROFILE("pallocator_single:allocate()", " ", TAU_USER); + // This doesn't support allocating arrays. + assert(n == 1); + return DeletedChain::allocate(sizeof(Type)); +} + +template +INLINE void pallocator_single:: +deallocate(TYPENAME pallocator_single::pointer p, TYPENAME pallocator_single::size_type) { + TAU_PROFILE("pallocator_single:deallocate()", " ", TAU_USER); + return DeletedChain::deallocate(p); +} + +template +INLINE pallocator_array:: +pallocator_array() throw() { +} + +template +INLINE TYPENAME pallocator_array::pointer pallocator_array:: +allocate(TYPENAME pallocator_array::size_type n, TYPENAME allocator::const_pointer) { + TAU_PROFILE("pallocator_array:allocate()", " ", TAU_USER); + return (TYPENAME pallocator_array::pointer)(*global_operator_new)(n * sizeof(Type)); +} + +template +INLINE void pallocator_array:: +deallocate(TYPENAME pallocator_array::pointer p, TYPENAME pallocator_array::size_type) { + TAU_PROFILE("pallocator_array:deallocate()", " ", TAU_USER); (*global_operator_delete)(p); } - -#elif defined(GNU_STYLE_ALLOCATOR) - -template -INLINE pallocator:: -pallocator() { -} - -template -template -INLINE pallocator:: -pallocator(const pallocator<_Tp1> &) { -} - -template -INLINE Type *pallocator:: -allocate(size_t n) { - return (Type *)(*global_operator_new)(n * sizeof(Type)); -} - -template -INLINE void pallocator:: -deallocate(void *p, size_t) { - (*global_operator_delete)(p); -} - -#elif VC6_STYLE_ALLOCATOR - -template -INLINE pallocator::pointer pallocator:: -allocate(pallocator::size_type n, allocator::const_pointer) { - return (pallocator::pointer)(*global_operator_new)(n * sizeof(Type)); -} - -template -INLINE void pallocator:: -//deallocate(pallocator::pointer p, allocator::size_type) { -deallocate(void *p, allocator::size_type) { - (*global_operator_delete)(p); -} - -#elif MODERN_STYLE_ALLOCATOR - -template -INLINE pallocator:: -pallocator() throw() { -} - -template -INLINE TYPENAME pallocator::pointer pallocator:: -allocate(TYPENAME pallocator::size_type n, TYPENAME allocator::const_pointer) { - return (TYPENAME pallocator::pointer)(*global_operator_new)(n * sizeof(Type)); -} - -template -INLINE void pallocator:: -deallocate(TYPENAME pallocator::pointer p, TYPENAME pallocator::size_type) { - (*global_operator_delete)(p); -} - -#endif // *_STYLE_ALLOCATOR diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index 20745ebd30..9cdbd78929 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -21,7 +21,7 @@ #include #include "dtoolbase.h" - +#include "deletedChain.h" //////////////////////////////////////////////////////////////////// // Class : pallocator @@ -32,60 +32,24 @@ // // pvector, pmap, etc. are all defined in this directory // to use a pallocator. + +// pallocator actually comes it two flavors now: +// pallocator_single, which can only allocate single +// instances of an object, and pallocator_array, which +// can allocate arrays of objects. //////////////////////////////////////////////////////////////////// -#if defined(NO_STYLE_ALLOCATOR) +#ifndef USE_STL_ALLOCATOR // If we're not trying to make custom allocators (either we don't know // what kind of syntax this STL library wants, or we're compiling with // OPTIMIZE 4), then simply use the standard allocator. -#define pallocator allocator +#define pallocator_single allocator +#define pallocator_array allocator -#elif defined(OLD_STYLE_ALLOCATOR) -// Early versions of gcc wanted to use their own kind of allocator, -// somewhat different from the STL standard. Irix uses this one too. -// It might be inherited from an early draft of the STL standard. +#else template -class pallocator : public alloc { -public: - INLINE static Type *allocate(size_t n); - INLINE static void deallocate(void *p, size_t n); -}; - -#elif defined(GNU_STYLE_ALLOCATOR) -// Later versions of gcc want to use a still different, -// not-quite-standard definition. Sheesh. - -template -class pallocator : public allocator { -public: - INLINE pallocator(); - template - INLINE pallocator(const pallocator<_Tp1> &other); - - INLINE Type *allocate(size_t n); - INLINE void deallocate(void *p, size_t n); - - template struct rebind { - typedef pallocator<_Tp1> other; - }; -}; - -#elif defined(VC6_STYLE_ALLOCATOR) - -// The VC6-era definition. -template -class pallocator : public allocator { -public: - INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); - INLINE void deallocate(void *p, size_type n); -}; - -#elif defined(MODERN_STYLE_ALLOCATOR) - -// The final specification? -template -class pallocator : public allocator { +class pallocator_single : public allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes // in a template class; we must explicitly copy them here. @@ -95,42 +59,48 @@ public: typedef TYPENAME allocator::const_reference const_reference; typedef TYPENAME allocator::size_type size_type; - INLINE pallocator() throw(); + INLINE pallocator_single() throw(); // template member functions in VC++ can only be defined in-class. template - INLINE pallocator(const pallocator &) throw() { } + INLINE pallocator_single(const pallocator_single &) throw() { } INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); INLINE void deallocate(pointer p, size_type n); - /* -#ifdef __GNUC__ - // The gcc 4.0 version seems to pass any old type to construct() and - // destroy(), so we need template methods. - template - INLINE void construct(Subtype *p, const Subtype &value) { - ::new(p) Subtype(value); - } - template - INLINE void destroy(Subtype *p) { - p->~Subtype(); - } -#endif // __GNUC__ - */ - template struct rebind { - typedef pallocator other; + typedef pallocator_single other; }; }; -#else -#error Unrecognized allocator symbol defined! -#endif // *_STYLE_ALLOCATOR +template +class pallocator_array : public allocator { +public: + // Nowadays we cannot implicitly inherit typedefs from base classes + // in a template class; we must explicitly copy them here. + typedef TYPENAME allocator::pointer pointer; + typedef TYPENAME allocator::reference reference; + typedef TYPENAME allocator::const_pointer const_pointer; + typedef TYPENAME allocator::const_reference const_reference; + typedef TYPENAME allocator::size_type size_type; + + INLINE pallocator_array() throw(); + + // template member functions in VC++ can only be defined in-class. + template + INLINE pallocator_array(const pallocator_array &) throw() { } + + INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); + INLINE void deallocate(pointer p, size_type n); + + template struct rebind { + typedef pallocator_array other; + }; +}; -#ifndef NO_STYLE_ALLOCATOR #include "pallocator.T" -#endif + +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index 639583698a..60de0e9230 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -23,7 +23,7 @@ #include "pallocator.h" #include -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR // If we're not using custom allocators, just use the standard class // definition. #define pdeque deque @@ -38,14 +38,14 @@ // memory. //////////////////////////////////////////////////////////////////// template -class pdeque : public deque > { +class pdeque : public deque > { public: - typedef TYPENAME deque >::size_type size_type; - pdeque() : deque >() { } - pdeque(const pdeque ©) : deque >(copy) { } - pdeque(size_type n) : deque >(n) { } - pdeque(size_type n, const Type &value) : deque >(n, value) { } + typedef TYPENAME deque >::size_type size_type; + pdeque() : deque >() { } + pdeque(const pdeque ©) : deque >(copy) { } + pdeque(size_type n) : deque >(n) { } + pdeque(size_type n, const Type &value) : deque >(n, value) { } }; -#endif // NO_STYLE_ALLOCATOR +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 10af85dabc..7fe4811290 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -23,7 +23,7 @@ #include "pallocator.h" #include -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR // If we're not using custom allocators, just use the standard class // definition. #define plist list @@ -38,19 +38,19 @@ // memory. //////////////////////////////////////////////////////////////////// template -class plist : public list > { +class plist : public list > { public: - typedef TYPENAME list >::size_type size_type; - plist() : list >() { } - plist(const plist ©) : list >(copy) { } - plist(size_type n) : list >(n) { } - plist(size_type n, const Type &value) : list >(n, value) { } + typedef TYPENAME list >::size_type size_type; + plist() : list >() { } + plist(const plist ©) : list >(copy) { } + plist(size_type n) : list >(n) { } + plist(size_type n, const Type &value) : list >(n, value) { } - typedef TYPENAME list >::iterator iterator; - typedef TYPENAME list >::const_iterator const_iterator; - typedef TYPENAME list >::reverse_iterator reverse_iterator; - typedef TYPENAME list >::const_reverse_iterator const_reverse_iterator; + typedef TYPENAME list >::iterator iterator; + typedef TYPENAME list >::const_iterator const_iterator; + typedef TYPENAME list >::reverse_iterator reverse_iterator; + typedef TYPENAME list >::const_reverse_iterator const_reverse_iterator; }; -#endif // NO_STYLE_ALLOCATOR +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index 1719294895..7845c3d2a9 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -28,7 +28,7 @@ #include #endif -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR // If we're not using custom allocators, just use the standard class // definition. #define pmap map @@ -42,7 +42,7 @@ #define phash_multimap multimap #endif // HAVE_STL_HASH -#else // NO_STYLE_ALLOCATOR +#else // USE_STL_ALLOCATOR //////////////////////////////////////////////////////////////////// // Class : pmap @@ -52,11 +52,65 @@ // memory. //////////////////////////////////////////////////////////////////// template > -class pmap : public map > > { +class pmap : public map > > { public: - pmap() : map > >() { } - pmap(const pmap ©) : map > >(copy) { } - pmap(const Compare &comp) : map > >(comp) { } + typedef map > > base_class; + + pmap() : base_class() { } + pmap(const pmap ©) : base_class(copy) { } + pmap(const Compare &comp) : base_class(comp) { } + +#ifdef USE_TAU + TYPENAME base_class::mapped_type & + operator [] (const TYPENAME base_class::key_type &k) { + TAU_PROFILE("pmap::operator [] (const key_type &)", " ", TAU_USER); + return base_class::operator [] (k); + } + + std::pair + insert(const TYPENAME base_class::value_type &x) { + TAU_PROFILE("pmap::insert(const value_type &)", " ", TAU_USER); + return base_class::insert(x); + } + + TYPENAME base_class::iterator + insert(TYPENAME base_class::iterator position, + const TYPENAME base_class::value_type &x) { + TAU_PROFILE("pmap::insert(iterator, const value_type &)", " ", TAU_USER); + return base_class::insert(position, x); + } + + void + erase(TYPENAME base_class::iterator position) { + TAU_PROFILE("pmap::erase(iterator)", " ", TAU_USER); + base_class::erase(position); + } + + TYPENAME base_class::size_type + erase(const TYPENAME base_class::key_type &x) { + TAU_PROFILE("pmap::erase(const key_type &)", " ", TAU_USER); + return base_class::erase(x); + } + + void + clear() { + TAU_PROFILE("pmap::clear()", " ", TAU_USER); + base_class::clear(); + } + + TYPENAME base_class::iterator + find(const TYPENAME base_class::key_type &x) { + TAU_PROFILE("pmap::find(const key_type &)", " ", TAU_USER); + return base_class::find(x); + } + + TYPENAME base_class::const_iterator + find(const TYPENAME base_class::key_type &x) const { + TAU_PROFILE("pmap::find(const key_type &)", " ", TAU_USER); + return base_class::find(x); + } + +#endif // USE_TAU }; //////////////////////////////////////////////////////////////////// @@ -67,11 +121,11 @@ public: // memory. //////////////////////////////////////////////////////////////////// template > -class pmultimap : public multimap > > { +class pmultimap : public multimap > > { public: - pmultimap() : multimap > >() { } - pmultimap(const pmultimap ©) : multimap > >(copy) { } - pmultimap(const Compare &comp) : multimap > >(comp) { } + pmultimap() : multimap > >() { } + pmultimap(const pmultimap ©) : multimap > >(copy) { } + pmultimap(const Compare &comp) : multimap > >(comp) { } }; #ifdef HAVE_STL_HASH @@ -83,11 +137,11 @@ public: // memory. //////////////////////////////////////////////////////////////////// template > > -class phash_map : public hash_map > > { +class phash_map : public hash_map > > { public: - phash_map() : hash_map > >() { } - phash_map(const phash_map ©) : hash_map > >(copy) { } - phash_map(const Compare &comp) : hash_map > >(comp) { } + phash_map() : hash_map > >() { } + phash_map(const phash_map ©) : hash_map > >(copy) { } + phash_map(const Compare &comp) : hash_map > >(comp) { } }; //////////////////////////////////////////////////////////////////// @@ -98,11 +152,11 @@ public: // memory. //////////////////////////////////////////////////////////////////// template > > -class phash_multimap : public hash_multimap > > { +class phash_multimap : public hash_multimap > > { public: - phash_multimap() : hash_multimap > >() { } - phash_multimap(const phash_multimap ©) : hash_multimap > >(copy) { } - phash_multimap(const Compare &comp) : hash_multimap > >(comp) { } + phash_multimap() : hash_multimap > >() { } + phash_multimap(const phash_multimap ©) : hash_multimap > >(copy) { } + phash_multimap(const Compare &comp) : hash_multimap > >(comp) { } }; #else // HAVE_STL_HASH @@ -110,5 +164,5 @@ public: #define phash_multimap pmultimap #endif // HAVE_STL_HASH -#endif // NO_STYLE_ALLOCATOR +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 2169d08292..9af959b4c2 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -28,7 +28,7 @@ #include #endif -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR // If we're not using custom allocators, just use the standard class // definition. #define pset set @@ -42,7 +42,7 @@ #define phash_multiset multiset #endif // HAVE_STL_HASH -#else // NO_STYLE_ALLOCATOR +#else // USE_STL_ALLOCATOR //////////////////////////////////////////////////////////////////// // Class : pset @@ -52,11 +52,57 @@ // memory. //////////////////////////////////////////////////////////////////// template > -class pset : public set > { +class pset : public set > { public: - pset() : set >() { } - pset(const pset ©) : set >(copy) { } - pset(const Compare &comp) : set >(comp) { } + typedef set > base_class; + pset() : base_class() { } + pset(const pset ©) : base_class(copy) { } + pset(const Compare &comp) : base_class(comp) { } + +#ifdef USE_TAU + std::pair + insert(const TYPENAME base_class::value_type &x) { + TAU_PROFILE("pset::insert(const value_type &)", " ", TAU_USER); + return base_class::insert(x); + } + + TYPENAME base_class::iterator + insert(TYPENAME base_class::iterator position, + const TYPENAME base_class::value_type &x) { + TAU_PROFILE("pset::insert(iterator, const value_type &)", " ", TAU_USER); + return base_class::insert(position, x); + } + + void + erase(TYPENAME base_class::iterator position) { + TAU_PROFILE("pset::erase(iterator)", " ", TAU_USER); + base_class::erase(position); + } + + TYPENAME base_class::size_type + erase(const TYPENAME base_class::key_type &x) { + TAU_PROFILE("pset::erase(const key_type &)", " ", TAU_USER); + return base_class::erase(x); + } + + void + clear() { + TAU_PROFILE("pset::clear()", " ", TAU_USER); + base_class::clear(); + } + + TYPENAME base_class::iterator + find(const TYPENAME base_class::key_type &x) { + TAU_PROFILE("pset::find(x)", " ", TAU_USER); + return base_class::find(x); + } + + TYPENAME base_class::const_iterator + find(const TYPENAME base_class::key_type &x) const { + TAU_PROFILE("pset::find(x)", " ", TAU_USER); + return base_class::find(x); + } +#endif // USE_TAU }; //////////////////////////////////////////////////////////////////// @@ -67,11 +113,11 @@ public: // memory. //////////////////////////////////////////////////////////////////// template > -class pmultiset : public multiset > { +class pmultiset : public multiset > { public: - pmultiset() : multiset >() { } - pmultiset(const pmultiset ©) : multiset >(copy) { } - pmultiset(const Compare &comp) : multiset >(comp) { } + pmultiset() : multiset >() { } + pmultiset(const pmultiset ©) : multiset >(copy) { } + pmultiset(const Compare &comp) : multiset >(comp) { } }; #ifdef HAVE_STL_HASH @@ -83,11 +129,11 @@ public: // memory. //////////////////////////////////////////////////////////////////// template > > -class phash_set : public hash_set > { +class phash_set : public hash_set > { public: - phash_set() : hash_set >() { } - phash_set(const phash_set ©) : hash_set >(copy) { } - phash_set(const Compare &comp) : hash_set >(comp) { } + phash_set() : hash_set >() { } + phash_set(const phash_set ©) : hash_set >(copy) { } + phash_set(const Compare &comp) : hash_set >(comp) { } }; //////////////////////////////////////////////////////////////////// @@ -98,11 +144,11 @@ public: // memory. //////////////////////////////////////////////////////////////////// template > > -class phash_multiset : public hash_multiset > { +class phash_multiset : public hash_multiset > { public: - phash_multiset() : hash_multiset >() { } - phash_multiset(const phash_multiset ©) : hash_multiset >(copy) { } - phash_multiset(const Compare &comp) : hash_multiset >(comp) { } + phash_multiset() : hash_multiset >() { } + phash_multiset(const phash_multiset ©) : hash_multiset >(copy) { } + phash_multiset(const Compare &comp) : hash_multiset >(comp) { } }; #else // HAVE_STL_HASH @@ -110,5 +156,5 @@ public: #define phash_multiset pmultiset #endif // HAVE_STL_HASH -#endif // NO_STYLE_ALLOCATOR +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 4fc117efdd..5160398aae 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -24,7 +24,7 @@ #include "dtoolbase.h" #include "pallocator.h" -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR // If we're not using custom allocators, just use the standard class // definition. #define pvector vector @@ -39,17 +39,26 @@ // memory. //////////////////////////////////////////////////////////////////// template -class pvector : public vector > { +class pvector : public vector > { public: - typedef TYPENAME vector >::size_type size_type; + typedef vector > base_class; + typedef TYPENAME base_class::size_type size_type; - pvector() : vector >() { } - pvector(const pvector ©) : vector >(copy) { } - pvector(size_type n) : vector >(n) { } - pvector(size_type n, const Type &value) : vector >(n, value) { } - pvector(const Type *begin, const Type *end) : vector >(begin, end) { } + pvector() : base_class() { } + pvector(const pvector ©) : base_class(copy) { } + pvector(size_type n) : base_class(n) { } + pvector(size_type n, const Type &value) : base_class(n, value) { } + pvector(const Type *begin, const Type *end) : base_class(begin, end) { } + +#ifdef USE_TAU + void + push_back(const TYPENAME base_class::value_type &x) { + TAU_PROFILE("pvector::push_back(const value_type &)", " ", TAU_USER); + base_class::push_back(x); + } +#endif // USE_TAU }; -#endif // NO_STYLE_ALLOCATOR +#endif // USE_STL_ALLOCATOR #endif diff --git a/dtool/src/dtoolbase/select.tau b/dtool/src/dtoolbase/select.tau new file mode 100644 index 0000000000..39b2687ecb --- /dev/null +++ b/dtool/src/dtoolbase/select.tau @@ -0,0 +1,4 @@ +BEGIN_EXCLUDE_LIST +void *default_operator_new# +void default_operator_delete# +END_EXCLUDE_LIST diff --git a/dtool/src/interrogatedb/selectThreadImpl.h b/dtool/src/dtoolbase/selectThreadImpl.h similarity index 94% rename from dtool/src/interrogatedb/selectThreadImpl.h rename to dtool/src/dtoolbase/selectThreadImpl.h index f630a6a0e2..fd1fad851e 100644 --- a/dtool/src/interrogatedb/selectThreadImpl.h +++ b/dtool/src/dtoolbase/selectThreadImpl.h @@ -43,6 +43,11 @@ // In Windows, use the native threading library. #define THREAD_WIN32_IMPL 1 +#elif defined(HAVE_LINUX_NATIVE_THREADS) + +// In Linux, we might want to use the low-level system calls. +#define THREAD_LINUX_IMPL 1 + #elif defined(HAVE_POSIX_THREADS) // Posix threads are nice. diff --git a/dtool/src/dtoolutil/pandaSystem.h b/dtool/src/dtoolutil/pandaSystem.h index b6a97db42b..78a4e84c91 100644 --- a/dtool/src/dtoolutil/pandaSystem.h +++ b/dtool/src/dtoolutil/pandaSystem.h @@ -21,6 +21,7 @@ #include "dtoolbase.h" #include "pmap.h" +#include "pvector.h" //////////////////////////////////////////////////////////////////// // Class : PandaSystem diff --git a/dtool/src/dtoolutil/vector_src.h b/dtool/src/dtoolutil/vector_src.h index 38c3ac601a..bbf2009167 100644 --- a/dtool/src/dtoolutil/vector_src.h +++ b/dtool/src/dtoolutil/vector_src.h @@ -52,7 +52,7 @@ #ifdef HAVE_DINKUM // With the Dinkum library, we must first export the base class, // _Vector_val. - #define VV_BASE std::_Vector_val > + #define VV_BASE std::_Vector_val > #pragma warning (disable : 4231) EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, VV_BASE) #undef VV_BASE @@ -61,10 +61,10 @@ EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, VV_BASE) // Now we can export the vector class. #pragma warning (disable : 4231) -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, std::vector) #else -#define STD_VECTOR std::vector > +#define STD_VECTOR std::vector > EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, STD_VECTOR) #undef STD_VECTOR EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, pvector) @@ -74,7 +74,7 @@ EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, pvector) // Now make a typedef for the vector. -#ifdef NO_STYLE_ALLOCATOR +#ifndef USE_STL_ALLOCATOR typedef std::vector NAME; #else typedef pvector NAME; diff --git a/dtool/src/interrogatedb/Sources.pp b/dtool/src/interrogatedb/Sources.pp index 36bbe3ec2d..a235a9092c 100644 --- a/dtool/src/interrogatedb/Sources.pp +++ b/dtool/src/interrogatedb/Sources.pp @@ -3,63 +3,47 @@ #begin lib_target #define TARGET interrogatedb - #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx + #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ - config_interrogatedb.h indexRemapper.h interrogateComponent.I \ - interrogateComponent.h interrogateDatabase.I \ - interrogateDatabase.h interrogateElement.I \ - interrogateElement.h interrogateFunction.I \ - interrogateFunction.h interrogateFunctionWrapper.I \ - interrogateFunctionWrapper.h interrogateManifest.I \ - interrogateManifest.h interrogateType.I interrogateType.h \ - interrogate_datafile.I interrogate_datafile.h \ - interrogate_interface.h interrogate_request.h \ - mutexImpl.h \ - mutexDummyImpl.h mutexDummyImpl.I \ - mutexNsprImpl.h mutexNsprImpl.I \ - mutexPosixImpl.h mutexPosixImpl.I \ - mutexWin32Impl.h mutexWin32Impl.I \ - py_panda.h \ - register_type.I register_type.h \ - selectThreadImpl.h \ - typedObject.I typedObject.h \ - typeHandle.I typeHandle.h \ - typeRegistry.I typeRegistry.h \ - typeRegistryNode.I typeRegistryNode.h \ - vector_int.h + config_interrogatedb.h indexRemapper.h interrogateComponent.I \ + interrogateComponent.h interrogateDatabase.I \ + interrogateDatabase.h interrogateElement.I \ + interrogateElement.h interrogateFunction.I \ + interrogateFunction.h interrogateFunctionWrapper.I \ + interrogateFunctionWrapper.h interrogateManifest.I \ + interrogateManifest.h interrogateType.I interrogateType.h \ + interrogate_datafile.I interrogate_datafile.h \ + interrogate_interface.h interrogate_request.h \ + py_panda.h \ + register_type.I register_type.h \ + typedObject.I typedObject.h \ + typeHandle.I typeHandle.h \ + typeRegistry.I typeRegistry.h \ + typeRegistryNode.I typeRegistryNode.h \ + vector_int.h #define INCLUDED_SOURCES \ - config_interrogatedb.cxx \ - dtool_super_base.cxx \ - indexRemapper.cxx \ - interrogateComponent.cxx interrogateDatabase.cxx \ - interrogateElement.cxx interrogateFunction.cxx \ - interrogateFunctionWrapper.cxx interrogateManifest.cxx \ - interrogateType.cxx interrogate_datafile.cxx \ - interrogate_interface.cxx interrogate_request.cxx \ - mutexDummyImpl.cxx \ - mutexNsprImpl.cxx \ - mutexPosixImpl.cxx \ - mutexWin32Impl.cxx \ - py_panda.cxx \ - register_type.cxx \ - typedObject.cxx \ - typeHandle.cxx \ - typeRegistry.cxx typeRegistryNode.cxx \ - vector_int.cxx + config_interrogatedb.cxx \ + dtool_super_base.cxx \ + indexRemapper.cxx \ + interrogateComponent.cxx interrogateDatabase.cxx \ + interrogateElement.cxx interrogateFunction.cxx \ + interrogateFunctionWrapper.cxx interrogateManifest.cxx \ + interrogateType.cxx interrogate_datafile.cxx \ + interrogate_interface.cxx interrogate_request.cxx \ + py_panda.cxx \ + register_type.cxx \ + typedObject.cxx \ + typeHandle.cxx \ + typeRegistry.cxx typeRegistryNode.cxx \ + vector_int.cxx #define INSTALL_HEADERS \ interrogate_interface.h interrogate_request.h vector_int.h \ config_interrogatedb.h \ - mutexImpl.h \ - mutexDummyImpl.h mutexDummyImpl.I \ - mutexNsprImpl.h mutexNsprImpl.I \ - mutexPosixImpl.h mutexPosixImpl.I \ - mutexWin32Impl.h mutexWin32Impl.I \ py_panda.h \ register_type.I register_type.h \ - selectThreadImpl.h \ typedObject.I typedObject.h \ typeHandle.I typeHandle.h \ typeRegistry.I typeRegistry.h \ diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 536b33ef59..f45f3c781e 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -20,6 +20,7 @@ #include "interrogateDatabase.h" #include "interrogateType.h" #include "interrogateFunction.h" +#include "config_interrogatedb.h" // This function adds one more directory to the list of directories // search for interrogate (*.in) files. In the past, this list has diff --git a/dtool/src/interrogatedb/interrogatedb_composite2.cxx b/dtool/src/interrogatedb/interrogatedb_composite2.cxx index 68e2e45e10..1521861194 100644 --- a/dtool/src/interrogatedb/interrogatedb_composite2.cxx +++ b/dtool/src/interrogatedb/interrogatedb_composite2.cxx @@ -1,9 +1,5 @@ #include "interrogateType.cxx" #include "interrogate_request.cxx" -#include "mutexDummyImpl.cxx" -#include "mutexNsprImpl.cxx" -#include "mutexPosixImpl.cxx" -#include "mutexWin32Impl.cxx" #include "py_panda.cxx" #include "register_type.cxx" #include "typedObject.cxx" diff --git a/dtool/src/prc/configDeclaration.I b/dtool/src/prc/configDeclaration.I index b0531c3d1c..4354266183 100644 --- a/dtool/src/prc/configDeclaration.I +++ b/dtool/src/prc/configDeclaration.I @@ -80,6 +80,7 @@ INLINE void ConfigDeclaration:: set_string_value(const string &string_value) { _string_value = string_value; _got_words = false; + invalidate_cache(); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configDeclaration.cxx b/dtool/src/prc/configDeclaration.cxx index 5bcf28ccfd..8b775eff43 100644 --- a/dtool/src/prc/configDeclaration.cxx +++ b/dtool/src/prc/configDeclaration.cxx @@ -84,6 +84,7 @@ set_string_word(int n, const string &value) { _string_value += (*wi)._str; ++wi; } + invalidate_cache(); } //////////////////////////////////////////////////////////////////// @@ -102,6 +103,7 @@ set_bool_word(int n, bool value) { _words[n]._flags |= (F_checked_bool | F_valid_bool); _words[n]._bool = value; + invalidate_cache(); } //////////////////////////////////////////////////////////////////// @@ -118,6 +120,7 @@ set_int_word(int n, int value) { _words[n]._flags |= (F_checked_int | F_valid_int); _words[n]._int = value; + invalidate_cache(); } //////////////////////////////////////////////////////////////////// @@ -134,6 +137,7 @@ set_double_word(int n, double value) { _words[n]._flags |= (F_checked_double | F_valid_double); _words[n]._double = value; + invalidate_cache(); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index a7605ee6d8..778fc05055 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -20,6 +20,7 @@ #define CONFIGDECLARATION_H #include "dtoolbase.h" +#include "configFlags.h" #include "configPage.h" #include "vector_string.h" @@ -33,7 +34,7 @@ class ConfigVariableCore; // a pairing of a string name (actually, a // ConfigVariableCore pointer) to a string value. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG ConfigDeclaration { +class EXPCL_DTOOLCONFIG ConfigDeclaration : public ConfigFlags { private: ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable, const string &string_value, int decl_seq); diff --git a/dtool/src/prc/configFlags.I b/dtool/src/prc/configFlags.I index 7791375f48..734e2ea842 100644 --- a/dtool/src/prc/configFlags.I +++ b/dtool/src/prc/configFlags.I @@ -16,3 +16,52 @@ // //////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: ConfigFlags::is_cache_valid +// Access: Protected, Static +// Description: Returns true if the local object's cache is still +// valid (based on a comparison of the supplied +// local_modified value with the global_modified value). +//////////////////////////////////////////////////////////////////// +INLINE bool ConfigFlags:: +is_cache_valid(PN_int32 local_modified) { + return local_modified == _global_modified; +} + +//////////////////////////////////////////////////////////////////// +// Function: ConfigFlags::mark_cache_valid +// Access: Protected, Static +// Description: Updates the indicated local_modified value so that +// the cache will appear to be valid, until someone next +// calls invalidate_cache(). +//////////////////////////////////////////////////////////////////// +INLINE void ConfigFlags:: +mark_cache_valid(PN_int32 &local_modified) { + local_modified = _global_modified; +} + +//////////////////////////////////////////////////////////////////// +// Function: ConfigFlags::initial_invalid_cache +// Access: Protected, Static +// Description: Returns a value that will be appropriate for +// initializing a local_modified value. This value will +// indicate an invalid cache in the next call to +// is_cache_valid(). +//////////////////////////////////////////////////////////////////// +INLINE PN_int32 ConfigFlags:: +initial_invalid_cache() { + return _global_modified - 1; +} + +//////////////////////////////////////////////////////////////////// +// Function: ConfigFlags::invalidate_cache +// Access: Protected, Static +// Description: Invalidates all of the global ConfigVariable caches +// in the world at once, by incrementing the +// global_modified counter. +//////////////////////////////////////////////////////////////////// +INLINE void ConfigFlags:: +invalidate_cache() { + AtomicAdjust::inc(_global_modified); +} diff --git a/dtool/src/prc/configFlags.cxx b/dtool/src/prc/configFlags.cxx index 2f5a7be3e7..cd8ecc3e18 100644 --- a/dtool/src/prc/configFlags.cxx +++ b/dtool/src/prc/configFlags.cxx @@ -18,6 +18,8 @@ #include "configFlags.h" +PN_int32 ConfigFlags::_global_modified; + //////////////////////////////////////////////////////////////////// // Function: ConfigFlags::Type output operator // Description: diff --git a/dtool/src/prc/configFlags.h b/dtool/src/prc/configFlags.h index 200b746f56..86e0a11ee5 100644 --- a/dtool/src/prc/configFlags.h +++ b/dtool/src/prc/configFlags.h @@ -20,6 +20,8 @@ #define CONFIGFLAGS_H #include "dtoolbase.h" +#include "numeric_types.h" +#include "atomicAdjust.h" //////////////////////////////////////////////////////////////////// // Class : ConfigFlags @@ -60,9 +62,20 @@ PUBLISHED: // shouldn't pass this in directly. F_dconfig = 0x00008000, }; + +protected: + INLINE static bool is_cache_valid(PN_int32 local_modified); + INLINE static void mark_cache_valid(PN_int32 &local_modified); + INLINE static PN_int32 initial_invalid_cache(); + INLINE static void invalidate_cache(); + +private: + static PN_int32 _global_modified; }; ostream &operator << (ostream &out, ConfigFlags::ValueType type); +#include "configFlags.I" + #endif diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index 42dcec9b08..f53eaa1d03 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -304,6 +304,7 @@ reload_implicit_pages() { } _currently_loading = false; + invalidate_cache(); } //////////////////////////////////////////////////////////////////// @@ -320,6 +321,7 @@ make_explicit_page(const string &name) { ++_next_page_seq; _explicit_pages.push_back(page); _pages_sorted = false; + invalidate_cache(); return page; } @@ -340,6 +342,7 @@ delete_explicit_page(ConfigPage *page) { if ((*pi) == page) { _explicit_pages.erase(pi); delete page; + invalidate_cache(); return true; } } diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index de5636bfe1..e87ddc33aa 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -20,6 +20,7 @@ #define CONFIGPAGEMANAGER_H #include "dtoolbase.h" +#include "configFlags.h" #include "pvector.h" #include "dSearchPath.h" #include "globPattern.h" @@ -33,7 +34,7 @@ class ConfigPage; // everywhere in the world, and keeps them in sorted // order. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG ConfigPageManager { +class EXPCL_DTOOLCONFIG ConfigPageManager : public ConfigFlags { protected: ConfigPageManager(); ~ConfigPageManager(); diff --git a/dtool/src/prc/configVariableBool.I b/dtool/src/prc/configVariableBool.I index e7b3d00348..62d758cea8 100644 --- a/dtool/src/prc/configVariableBool.I +++ b/dtool/src/prc/configVariableBool.I @@ -24,7 +24,8 @@ //////////////////////////////////////////////////////////////////// INLINE ConfigVariableBool:: ConfigVariableBool(const string &name) : - ConfigVariable(name, VT_bool) + ConfigVariable(name, VT_bool), + _local_modified(initial_invalid_cache()) { _core->set_used(); } @@ -37,7 +38,12 @@ ConfigVariableBool(const string &name) : INLINE ConfigVariableBool:: ConfigVariableBool(const string &name, bool default_value, const string &description, int flags) : - ConfigVariable(name, VT_bool, description, flags) +#ifdef PRC_SAVE_DESCRIPTIONS + ConfigVariable(name, VT_bool, description, flags), +#else + ConfigVariable(name, VT_bool, string(), flags), +#endif + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value ? "1" : "0"); _core->set_used(); @@ -51,7 +57,12 @@ ConfigVariableBool(const string &name, bool default_value, INLINE ConfigVariableBool:: ConfigVariableBool(const string &name, const string &default_value, const string &description, int flags) : - ConfigVariable(name, VT_bool, description, flags) +#ifdef PRC_SAVE_DESCRIPTIONS + ConfigVariable(name, VT_bool, description, flags), +#else + ConfigVariable(name, VT_bool, string(), flags), +#endif + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value); _core->set_used(); @@ -115,7 +126,12 @@ set_value(bool value) { //////////////////////////////////////////////////////////////////// INLINE bool ConfigVariableBool:: get_value() const { - return get_bool_word(0); + TAU_PROFILE("bool ConfigVariableBool::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + mark_cache_valid(((ConfigVariableBool *)this)->_local_modified); + ((ConfigVariableBool *)this)->_cache = get_bool_word(0); + } + return _cache; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableBool.h b/dtool/src/prc/configVariableBool.h index 8763298371..1aa95b7133 100644 --- a/dtool/src/prc/configVariableBool.h +++ b/dtool/src/prc/configVariableBool.h @@ -47,6 +47,10 @@ PUBLISHED: INLINE bool get_word(int n) const; INLINE void set_word(int n, bool value); + +private: + PN_int32 _local_modified; + bool _cache; }; #include "configVariableBool.I" diff --git a/dtool/src/prc/configVariableCore.I b/dtool/src/prc/configVariableCore.I index 4b105b7e1e..38d160c398 100644 --- a/dtool/src/prc/configVariableCore.I +++ b/dtool/src/prc/configVariableCore.I @@ -163,20 +163,6 @@ has_local_value() const { return _local_value != (ConfigDeclaration *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_value_seq -// Access: Public -// Description: Returns a sequence number that changes every time the -// value of the variable might have changed. This is -// useful for caching values from the variable, and -// detecting when the cache has expired. It is -// initially zero and will increment from there. -//////////////////////////////////////////////////////////////////// -INLINE int ConfigVariableCore:: -get_value_seq() const { - return _value_seq; -} - //////////////////////////////////////////////////////////////////// // Function: ConfigVariableCore::get_num_references // Access: Public diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index 9403d8472c..569e66c7c2 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -41,8 +41,7 @@ ConfigVariableCore(const string &name) : _default_value(NULL), _local_value(NULL), _declarations_sorted(true), - _value_queried(false), - _value_seq(0) + _value_queried(false) { } @@ -63,8 +62,7 @@ ConfigVariableCore(const ConfigVariableCore &templ, const string &name) : _default_value(NULL), _local_value(NULL), _declarations_sorted(false), - _value_queried(false), - _value_seq(0) + _value_queried(false) { if (templ._default_value != (ConfigDeclaration *)NULL) { set_default_value(templ._default_value->get_string_value()); @@ -244,11 +242,6 @@ make_local_value() { } } - // Assume that everytime someone asks for the local value, they're - // about to change it; further assume that no one changes the local - // value without calling this method immediately before. - _value_seq++; - return _local_value; } @@ -267,7 +260,6 @@ clear_local_value() { if (_local_value != (ConfigDeclaration *)NULL) { ConfigPage::get_local_page()->delete_declaration(_local_value); _local_value = (ConfigDeclaration *)NULL; - _value_seq++; return true; } @@ -403,10 +395,6 @@ add_declaration(ConfigDeclaration *decl) { _declarations.push_back(decl); _declarations_sorted = false; - - if (!has_local_value()) { - _value_seq++; - } } //////////////////////////////////////////////////////////////////// @@ -429,9 +417,6 @@ remove_declaration(ConfigDeclaration *decl) { (*di) = (*di2); _declarations.erase(di2); _declarations_sorted = false; - if (!has_local_value()) { - _value_seq++; - } return; } } diff --git a/dtool/src/prc/configVariableCore.h b/dtool/src/prc/configVariableCore.h index 0ea1066ba2..1be8d7a94c 100644 --- a/dtool/src/prc/configVariableCore.h +++ b/dtool/src/prc/configVariableCore.h @@ -71,8 +71,6 @@ public: int get_num_declarations() const; const ConfigDeclaration *get_declaration(int n) const; - INLINE int get_value_seq() const; - INLINE int get_num_references() const; INLINE const ConfigDeclaration *get_reference(int n) const; @@ -108,7 +106,6 @@ private: Declarations _unique_declarations; bool _declarations_sorted; bool _value_queried; - int _value_seq; friend class ConfigDeclaration; friend class ConfigVariableManager; diff --git a/dtool/src/prc/configVariableDouble.I b/dtool/src/prc/configVariableDouble.I index 8d7078d63d..4a4a6cbf90 100644 --- a/dtool/src/prc/configVariableDouble.I +++ b/dtool/src/prc/configVariableDouble.I @@ -24,7 +24,8 @@ //////////////////////////////////////////////////////////////////// INLINE ConfigVariableDouble:: ConfigVariableDouble(const string &name) : - ConfigVariable(name, VT_double) + ConfigVariable(name, VT_double), + _local_modified(initial_invalid_cache()) { _core->set_used(); } @@ -38,10 +39,11 @@ INLINE ConfigVariableDouble:: ConfigVariableDouble(const string &name, double default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS - ConfigVariable(name, ConfigVariableCore::VT_double, description, flags) + ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags) + ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags), #endif + _local_modified(initial_invalid_cache()) { set_default_value(default_value); _core->set_used(); @@ -56,10 +58,11 @@ INLINE ConfigVariableDouble:: ConfigVariableDouble(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS - ConfigVariable(name, ConfigVariableCore::VT_double, description, flags) + ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags) + ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags), #endif + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value); _core->set_used(); @@ -123,7 +126,12 @@ set_value(double value) { //////////////////////////////////////////////////////////////////// INLINE double ConfigVariableDouble:: get_value() const { - return get_double_word(0); + TAU_PROFILE("double ConfigVariableDouble::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + mark_cache_valid(((ConfigVariableDouble *)this)->_local_modified); + ((ConfigVariableDouble *)this)->_cache = get_double_word(0); + } + return _cache; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableDouble.h b/dtool/src/prc/configVariableDouble.h index 1a2cb75d79..042e70427b 100644 --- a/dtool/src/prc/configVariableDouble.h +++ b/dtool/src/prc/configVariableDouble.h @@ -52,6 +52,10 @@ PUBLISHED: private: void set_default_value(double default_value); + +private: + PN_int32 _local_modified; + double _cache; }; #include "configVariableDouble.I" diff --git a/dtool/src/prc/configVariableEnum.I b/dtool/src/prc/configVariableEnum.I index dcee1c8cdb..deb8d47625 100644 --- a/dtool/src/prc/configVariableEnum.I +++ b/dtool/src/prc/configVariableEnum.I @@ -31,10 +31,9 @@ ConfigVariableEnum(const string &name, EnumType default_value, #else ConfigVariable(name, ConfigVariableCore::VT_enum, string(), flags), #endif - _value_seq(-1), - _value(default_value), _got_default_value(true), - _default_value(default_value) + _default_value(default_value), + _local_modified(initial_invalid_cache()) { _core->set_default_value(format_enum(default_value)); _core->set_used(); @@ -54,10 +53,9 @@ ConfigVariableEnum(const string &name, const string &default_value, #else ConfigVariable(name, ConfigVariableCore::VT_enum, string(), flags), #endif - _value_seq(-1), - _value(default_value), _got_default_value(true), - _default_value(parse_string(default_value)) + _default_value(parse_string(default_value)), + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value); _core->set_used(); @@ -136,11 +134,12 @@ set_value(EnumType value) { template INLINE EnumType ConfigVariableEnum:: get_value() const { - if (_value_seq != _core->get_value_seq()) { - ((ConfigVariableEnum *)this)->_value = (EnumType)parse_string(get_string_value()); - ((ConfigVariableEnum *)this)->_value_seq = _core->get_value_seq(); + TAU_PROFILE("EnumType ConfigVariableEnum::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + mark_cache_valid(((ConfigVariableEnum *)this)->_local_modified); + ((ConfigVariableEnum *)this)->_cache = (EnumType)parse_string(get_string_value()); } - return _value; + return _cache; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableEnum.h b/dtool/src/prc/configVariableEnum.h index 68f33ca9b7..d6693d4f89 100644 --- a/dtool/src/prc/configVariableEnum.h +++ b/dtool/src/prc/configVariableEnum.h @@ -63,11 +63,12 @@ private: INLINE EnumType parse_string(const string &value) const; INLINE string format_enum(EnumType value) const; - int _value_seq; - EnumType _value; - +private: bool _got_default_value; EnumType _default_value; + + PN_int32 _local_modified; + EnumType _cache; }; #include "configVariableEnum.I" diff --git a/dtool/src/prc/configVariableFilename.I b/dtool/src/prc/configVariableFilename.I index 86ce776449..06c7e7942b 100644 --- a/dtool/src/prc/configVariableFilename.I +++ b/dtool/src/prc/configVariableFilename.I @@ -25,8 +25,7 @@ INLINE ConfigVariableFilename:: ConfigVariableFilename(const string &name) : ConfigVariable(name, VT_filename), - _value_seq(-1), - _value_stale(true) + _local_modified(initial_invalid_cache()) { _core->set_used(); } @@ -44,8 +43,7 @@ ConfigVariableFilename(const string &name, const Filename &default_value, #else ConfigVariable(name, VT_filename, string(), flags), #endif - _value_seq(-1), - _value_stale(true) + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value); _core->set_used(); @@ -233,10 +231,11 @@ set_value(const Filename &value) { //////////////////////////////////////////////////////////////////// INLINE const Filename &ConfigVariableFilename:: get_value() const { - if (_value_stale || _value_seq != _core->get_value_seq()) { - ((ConfigVariableFilename *)this)->reload_value(); + TAU_PROFILE("const Filename &ConfigVariableFilename::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + ((ConfigVariableFilename *)this)->reload_cache(); } - return _value; + return _cache; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableFilename.cxx b/dtool/src/prc/configVariableFilename.cxx index 7ae5ac61f2..d45101f842 100644 --- a/dtool/src/prc/configVariableFilename.cxx +++ b/dtool/src/prc/configVariableFilename.cxx @@ -20,14 +20,15 @@ #include "executionEnvironment.h" //////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::reload_value +// Function: ConfigVariableFilename::reload_cache // Access: Private // Description: Recopies the config variable into the Filename for // returning its value. //////////////////////////////////////////////////////////////////// void ConfigVariableFilename:: -reload_value() { +reload_cache() { nassertv(_core != (ConfigVariableCore *)NULL); + mark_cache_valid(_local_modified); const ConfigDeclaration *decl = _core->get_declaration(0); const ConfigPage *page = decl->get_page(); @@ -36,9 +37,6 @@ reload_value() { Filename page_dirname = page_filename.get_dirname(); ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); - _value = Filename::expand_from(decl->get_string_value()); + _cache = Filename::expand_from(decl->get_string_value()); ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); - - _value_seq = _core->get_value_seq(); - _value_stale = false; } diff --git a/dtool/src/prc/configVariableFilename.h b/dtool/src/prc/configVariableFilename.h index 2bdab7d8c7..8050e4fa87 100644 --- a/dtool/src/prc/configVariableFilename.h +++ b/dtool/src/prc/configVariableFilename.h @@ -67,12 +67,11 @@ PUBLISHED: INLINE void set_word(int n, const Filename &value); private: - void reload_value(); + void reload_cache(); - int _value_seq; - bool _value_stale; - - Filename _value; +private: + PN_int32 _local_modified; + Filename _cache; }; #include "configVariableFilename.I" diff --git a/dtool/src/prc/configVariableInt.I b/dtool/src/prc/configVariableInt.I index c25950e4bd..b76edfcd99 100644 --- a/dtool/src/prc/configVariableInt.I +++ b/dtool/src/prc/configVariableInt.I @@ -24,7 +24,8 @@ //////////////////////////////////////////////////////////////////// INLINE ConfigVariableInt:: ConfigVariableInt(const string &name) : - ConfigVariable(name, VT_int) + ConfigVariable(name, VT_int), + _local_modified(initial_invalid_cache()) { _core->set_used(); } @@ -38,10 +39,11 @@ INLINE ConfigVariableInt:: ConfigVariableInt(const string &name, int default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS - ConfigVariable(name, ConfigVariableCore::VT_int, description, flags) + ConfigVariable(name, ConfigVariableCore::VT_int, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_int, string(), flags) + ConfigVariable(name, ConfigVariableCore::VT_int, string(), flags), #endif + _local_modified(initial_invalid_cache()) { set_default_value(default_value); _core->set_used(); @@ -56,10 +58,11 @@ INLINE ConfigVariableInt:: ConfigVariableInt(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS - ConfigVariable(name, ConfigVariableCore::VT_int, description, flags) + ConfigVariable(name, ConfigVariableCore::VT_int, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_int, string(), flags) + ConfigVariable(name, ConfigVariableCore::VT_int, string(), flags), #endif + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value); _core->set_used(); @@ -123,7 +126,12 @@ set_value(int value) { //////////////////////////////////////////////////////////////////// INLINE int ConfigVariableInt:: get_value() const { - return get_int_word(0); + TAU_PROFILE("int ConfigVariableInt::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + mark_cache_valid(((ConfigVariableInt *)this)->_local_modified); + ((ConfigVariableInt *)this)->_cache = get_int_word(0); + } + return _cache; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableInt.h b/dtool/src/prc/configVariableInt.h index 7a13090094..b4c118d84f 100644 --- a/dtool/src/prc/configVariableInt.h +++ b/dtool/src/prc/configVariableInt.h @@ -52,6 +52,10 @@ PUBLISHED: private: void set_default_value(int default_value); + +private: + PN_int32 _local_modified; + int _cache; }; #include "configVariableInt.I" diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index 5f127c9d24..e9c7c805d3 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -30,7 +30,8 @@ class ConfigVariableCore; //////////////////////////////////////////////////////////////////// // Class : ConfigVariableManager -// Description : A global object that maintains the set of ConfigVariableCores +// Description : A global object that maintains the set of +// ConfigVariables (actually, ConfigVariableCores) // everywhere in the world, and keeps them in sorted // order. //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index e7f2c44058..390e22167b 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -30,8 +30,7 @@ ConfigVariableSearchPath(const string &name, #else ConfigVariableBase(name, VT_search_path, string(), flags), #endif - _value_seq(-1), - _value_stale(true) + _local_modified(initial_invalid_cache()) { // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from @@ -61,6 +60,20 @@ operator const DSearchPath & () const { return get_value(); } +//////////////////////////////////////////////////////////////////// +// Function: ConfigVariableSearchPath::get_value +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE const DSearchPath &ConfigVariableSearchPath:: +get_value() const { + TAU_PROFILE("const DSearchPath &ConfigVariableSearchPath::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + ((ConfigVariableSearchPath *)this)->reload_search_path(); + } + return _cache; +} + //////////////////////////////////////////////////////////////////// // Function: ConfigVariableSearchPath::clear_local_value // Access: Published @@ -79,7 +92,7 @@ clear_local_value() { any_to_clear = true; } - _value_stale = true; + _local_modified = initial_invalid_cache(); return any_to_clear; } @@ -102,7 +115,7 @@ clear() { INLINE void ConfigVariableSearchPath:: append_directory(const Filename &directory) { _postfix.append_directory(directory); - _value_stale = true; + _local_modified = initial_invalid_cache(); } //////////////////////////////////////////////////////////////////// @@ -113,7 +126,7 @@ append_directory(const Filename &directory) { INLINE void ConfigVariableSearchPath:: prepend_directory(const Filename &directory) { _prefix.prepend_directory(directory); - _value_stale = true; + _local_modified = initial_invalid_cache(); } //////////////////////////////////////////////////////////////////// @@ -125,7 +138,7 @@ prepend_directory(const Filename &directory) { INLINE void ConfigVariableSearchPath:: append_path(const string &path, const string &separator) { _postfix.append_path(path, separator); - _value_stale = true; + _local_modified = initial_invalid_cache(); } //////////////////////////////////////////////////////////////////// @@ -137,7 +150,7 @@ append_path(const string &path, const string &separator) { INLINE void ConfigVariableSearchPath:: append_path(const DSearchPath &path) { _postfix.append_path(path); - _value_stale = true; + _local_modified = initial_invalid_cache(); } //////////////////////////////////////////////////////////////////// @@ -149,7 +162,7 @@ append_path(const DSearchPath &path) { INLINE void ConfigVariableSearchPath:: prepend_path(const DSearchPath &path) { _prefix.prepend_path(path); - _value_stale = true; + _local_modified = initial_invalid_cache(); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index a842520cfd..95d9c4e961 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -19,20 +19,6 @@ #include "configVariableSearchPath.h" #include "executionEnvironment.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::get_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -const DSearchPath &ConfigVariableSearchPath:: -get_value() const { - nassertr(_core != (ConfigVariableCore *)NULL, _value); - if (_value_stale || _value_seq != _core->get_value_seq()) { - ((ConfigVariableSearchPath *)this)->reload_search_path(); - } - return _value; -} - //////////////////////////////////////////////////////////////////// // Function: ConfigVariableSearchPath::reload_search_path // Access: Private @@ -42,9 +28,10 @@ get_value() const { void ConfigVariableSearchPath:: reload_search_path() { nassertv(_core != (ConfigVariableCore *)NULL); - _value.clear(); + mark_cache_valid(_local_modified); + _cache.clear(); - _value.append_path(_prefix); + _cache.append_path(_prefix); int num_unique_references = _core->get_num_unique_references(); for (int i = 0; i < num_unique_references; i++) { const ConfigDeclaration *decl = _core->get_unique_reference(i); @@ -56,16 +43,13 @@ reload_search_path() { string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); if (!expanded.empty()) { - _value.append_directory(Filename::from_os_specific(expanded)); + _cache.append_directory(Filename::from_os_specific(expanded)); } } - _value.append_path(_postfix); + _cache.append_path(_postfix); - if (_value.is_empty()) { + if (_cache.is_empty()) { // An empty search path implicitly has "." on it. - _value.append_directory("."); + _cache.append_directory("."); } - - _value_seq = _core->get_value_seq(); - _value_stale = false; } diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index 00d6f92b5d..0ab4580874 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -51,7 +51,7 @@ PUBLISHED: INLINE ~ConfigVariableSearchPath(); INLINE operator const DSearchPath & () const; - const DSearchPath &get_value() const; + INLINE const DSearchPath &get_value() const; INLINE bool clear_local_value(); @@ -77,11 +77,10 @@ PUBLISHED: private: void reload_search_path(); - int _value_seq; - bool _value_stale; - - DSearchPath _value; DSearchPath _prefix, _postfix; + + PN_int32 _local_modified; + DSearchPath _cache; }; INLINE ostream &operator << (ostream &out, const ConfigVariableSearchPath &variable); diff --git a/dtool/src/prc/configVariableString.I b/dtool/src/prc/configVariableString.I index 44366bb09d..0d37d13ae5 100644 --- a/dtool/src/prc/configVariableString.I +++ b/dtool/src/prc/configVariableString.I @@ -24,7 +24,8 @@ //////////////////////////////////////////////////////////////////// INLINE ConfigVariableString:: ConfigVariableString(const string &name) : - ConfigVariable(name, VT_string) + ConfigVariable(name, VT_string), + _local_modified(initial_invalid_cache()) { _core->set_used(); } @@ -38,10 +39,11 @@ INLINE ConfigVariableString:: ConfigVariableString(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS - ConfigVariable(name, VT_string, description, flags) + ConfigVariable(name, VT_string, description, flags), #else - ConfigVariable(name, VT_string, string(), flags) + ConfigVariable(name, VT_string, string(), flags), #endif + _local_modified(initial_invalid_cache()) { _core->set_default_value(default_value); _core->set_used(); @@ -155,7 +157,12 @@ set_value(const string &value) { //////////////////////////////////////////////////////////////////// INLINE const string &ConfigVariableString:: get_value() const { - return get_string_value(); + TAU_PROFILE("const string &ConfigVariableString::get_value() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + mark_cache_valid(((ConfigVariableString *)this)->_local_modified); + ((ConfigVariableString *)this)->_cache = get_string_value(); + } + return _cache; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/prc/configVariableString.h b/dtool/src/prc/configVariableString.h index f77f4e18d9..41e65ed9fd 100644 --- a/dtool/src/prc/configVariableString.h +++ b/dtool/src/prc/configVariableString.h @@ -54,6 +54,10 @@ PUBLISHED: INLINE string get_word(int n) const; INLINE void set_word(int n, const string &value); + +private: + PN_int32 _local_modified; + string _cache; }; #include "configVariableString.I" diff --git a/dtool/src/prc/config_prc.cxx b/dtool/src/prc/config_prc.cxx index 204c8f7032..2590730be4 100644 --- a/dtool/src/prc/config_prc.cxx +++ b/dtool/src/prc/config_prc.cxx @@ -17,5 +17,11 @@ //////////////////////////////////////////////////////////////////// #include "config_prc.h" +#include "configVariableBool.h" NotifyCategoryDef(prc, ""); + +ConfigVariableBool assert_abort +("assert-abort", false, + "Set this true to trigger a core dump and/or stack trace when the first assertion fails"); + diff --git a/dtool/src/prc/config_prc.h b/dtool/src/prc/config_prc.h index 5d23455932..c02eb26bab 100644 --- a/dtool/src/prc/config_prc.h +++ b/dtool/src/prc/config_prc.h @@ -22,7 +22,11 @@ #include "dtoolbase.h" #include "notifyCategoryProxy.h" +class ConfigVariableBool; + NotifyCategoryDecl(prc, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG); +extern ConfigVariableBool assert_abort; + #endif diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index ab1210f5d2..be6deb0bbf 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -22,16 +22,12 @@ #include "configVariableFilename.h" #include "configVariableBool.h" #include "filename.h" +#include "config_prc.h" #include Notify *Notify::_global_ptr = (Notify *)NULL; -static ConfigVariableBool assert_abort -("assert-abort", false, - "Set this true to trigger a core dump and/or stack trace when the first assertion fails"); - - //////////////////////////////////////////////////////////////////// // Function: Notify::Constructor // Access: Public diff --git a/dtool/src/prc/notifyCategory.I b/dtool/src/prc/notifyCategory.I index 880e30fca8..a238a8d73c 100644 --- a/dtool/src/prc/notifyCategory.I +++ b/dtool/src/prc/notifyCategory.I @@ -37,6 +37,20 @@ get_basename() const { return _basename; } +//////////////////////////////////////////////////////////////////// +// Function: NotifyCategory::get_severity +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +NotifySeverity NotifyCategory:: +get_severity() const { + TAU_PROFILE("NotifyCategory NotifyCategory::get_severity() const", " ", TAU_USER); + if (!is_cache_valid(_local_modified)) { + ((NotifyCategory *)this)->update_severity_cache(); + } + return _severity_cache; +} + //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::set_severity // Access: Public @@ -47,6 +61,7 @@ get_basename() const { INLINE void NotifyCategory:: set_severity(NotifySeverity severity) { _severity = severity; + invalidate_cache(); } //////////////////////////////////////////////////////////////////// @@ -57,6 +72,7 @@ set_severity(NotifySeverity severity) { //////////////////////////////////////////////////////////////////// INLINE bool NotifyCategory:: is_on(NotifySeverity severity) const { + TAU_PROFILE("bool NotifyCategory::is_on(NotifySeverity) const", " ", TAU_USER); return (int)severity >= (int)get_severity(); } diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 0b390d729a..5a32bc214e 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -21,6 +21,7 @@ #include "configPageManager.h" #include "configVariableString.h" #include "configVariableBool.h" +#include "config_prc.h" #include // for strftime(). #include @@ -40,7 +41,8 @@ NotifyCategory(const string &fullname, const string &basename, _parent(parent), _severity(get_config_name(), NS_unspecified, "Default severity of this notify category", - ConfigVariable::F_dynamic) + ConfigVariable::F_dynamic), + _local_modified(initial_invalid_cache()) { if (_parent != (NotifyCategory *)NULL) { _parent->_children.push_back(this); @@ -50,31 +52,6 @@ NotifyCategory(const string &fullname, const string &basename, nassertv(_parent != (NotifyCategory *)NULL || _fullname.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_severity -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -NotifySeverity NotifyCategory:: -get_severity() const { - if (_severity == NS_unspecified) { - // If we don't have an explicit severity level, inherit our - // parent's. - if (_severity.has_value()) { - nout << "Invalid severity name for " << _severity.get_name() << ": " - << _severity.get_string_value() << "\n"; - } - if (_parent != (NotifyCategory *)NULL) { - return _parent->get_severity(); - - } else { - // Unless, of course, we're the root. - return NS_info; - } - } - return _severity; -} - //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::out // Access: Published @@ -184,6 +161,33 @@ get_config_name() const { return config_name; } +//////////////////////////////////////////////////////////////////// +// Function: NotifyCategory::update_severity_cache +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void NotifyCategory:: +update_severity_cache() { + if (_severity == NS_unspecified) { + // If we don't have an explicit severity level, inherit our + // parent's. + if (_severity.has_value()) { + nout << "Invalid severity name for " << _severity.get_name() << ": " + << _severity.get_string_value() << "\n"; + } + if (_parent != (NotifyCategory *)NULL) { + _severity_cache = _parent->get_severity(); + + } else { + // Unless, of course, we're the root. + _severity_cache = NS_info; + } + } else { + _severity_cache = _severity; + } + mark_cache_valid(_local_modified); +} + //////////////////////////////////////////////////////////////////// // Function: NotifyCategory::get_notify_timestamp // Access: Private, Static diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 3fca4813df..67499820cf 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -23,6 +23,7 @@ #include "notifySeverity.h" #include "configVariableEnum.h" +#include "configFlags.h" #include "pvector.h" //////////////////////////////////////////////////////////////////// @@ -34,7 +35,7 @@ // created within a package if a finer grain of control // is required. //////////////////////////////////////////////////////////////////// -class EXPCL_DTOOLCONFIG NotifyCategory { +class EXPCL_DTOOLCONFIG NotifyCategory : public ConfigFlags { private: NotifyCategory(const string &fullname, const string &basename, NotifyCategory *parent); @@ -42,7 +43,7 @@ private: PUBLISHED: INLINE string get_fullname() const; INLINE string get_basename() const; - NotifySeverity get_severity() const; + INLINE NotifySeverity get_severity() const; INLINE void set_severity(NotifySeverity severity); INLINE bool is_on(NotifySeverity severity) const; @@ -80,6 +81,7 @@ PUBLISHED: private: string get_config_name() const; + void update_severity_cache(); static bool get_notify_timestamp(); static bool get_check_debug_notify_protect(); @@ -92,6 +94,9 @@ private: static long _server_delta; // not a time_t because server delta may be signed. + PN_int32 _local_modified; + NotifySeverity _severity_cache; + friend class Notify; }; diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index bd4989aa12..9d42543e49 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -85,8 +85,13 @@ public: INLINE bool is_on(NotifySeverity severity); +#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) INLINE bool is_spam(); INLINE bool is_debug(); +#else + INLINE static bool is_spam(); + INLINE static bool is_debug(); +#endif INLINE bool is_info(); INLINE bool is_warning(); INLINE bool is_error(); diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index 1e3d3e3738..388cc1496a 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -19,7 +19,8 @@ #include "animChannelScalarDynamic.h" #include "animBundle.h" #include "config_chan.h" - +#include "transformState.h" +#include "pandaNode.h" #include "indent.h" #include "datagram.h" #include "datagramIterator.h" diff --git a/panda/src/chan/animChannelScalarDynamic.h b/panda/src/chan/animChannelScalarDynamic.h index 411ec686c7..020ad09ce7 100644 --- a/panda/src/chan/animChannelScalarDynamic.h +++ b/panda/src/chan/animChannelScalarDynamic.h @@ -23,6 +23,9 @@ #include "animChannel.h" +class PandaNode; +class TransformState; + //////////////////////////////////////////////////////////////////// // Class : AnimChannelScalarDynamic // Description : An animation channel that accepts a scalar each frame diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index fc2e36e490..2c6e0cce01 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -20,6 +20,7 @@ #include "animChannelBase.h" #include "partBundle.h" #include "config_chan.h" +#include "dcast.h" TypeHandle AnimControl::_type_handle; diff --git a/panda/src/chan/movingPartBase.cxx b/panda/src/chan/movingPartBase.cxx index afbe30f69e..bd67cdf6ac 100644 --- a/panda/src/chan/movingPartBase.cxx +++ b/panda/src/chan/movingPartBase.cxx @@ -20,7 +20,8 @@ #include "animControl.h" #include "animChannelBase.h" #include "bitArray.h" - +#include "config_chan.h" +#include "dcast.h" #include "indent.h" TypeHandle MovingPartBase::_type_handle; diff --git a/panda/src/chan/movingPartMatrix.cxx b/panda/src/chan/movingPartMatrix.cxx index 2cbd0c390e..f23139ed7a 100644 --- a/panda/src/chan/movingPartMatrix.cxx +++ b/panda/src/chan/movingPartMatrix.cxx @@ -18,7 +18,7 @@ #include "movingPartMatrix.h" - +#include "animChannelMatrixFixed.h" #include "compose_matrix.h" #include "datagram.h" #include "datagramIterator.h" diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index a7e4c10989..b15462b0ef 100755 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -20,7 +20,7 @@ #include "collisionNode.h" #include "collisionEntry.h" #include "config_collide.h" - +#include "collisionPlane.h" #include "clockObject.h" TypeHandle CollisionHandlerGravity::_type_handle; diff --git a/panda/src/collide/collisionLevelState.cxx b/panda/src/collide/collisionLevelState.cxx index a3f2f2cdcd..fcdef13866 100644 --- a/panda/src/collide/collisionLevelState.cxx +++ b/panda/src/collide/collisionLevelState.cxx @@ -18,6 +18,7 @@ #include "collisionLevelState.h" #include "collisionSolid.h" +#include "collisionNode.h" #include "dcast.h" PStatCollector CollisionLevelState::_node_volume_pcollector("Collision Volumes:PandaNode"); diff --git a/panda/src/collide/collisionRecorder.h b/panda/src/collide/collisionRecorder.h index d54196e121..f465f95477 100644 --- a/panda/src/collide/collisionRecorder.h +++ b/panda/src/collide/collisionRecorder.h @@ -21,8 +21,10 @@ #include "pandabase.h" #include "typeHandle.h" +#include "typedObject.h" class CollisionTraverser; +class CollisionEntry; #ifdef DO_COLLISION_RECORDING diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index e9934aa250..04591d3c90 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -22,6 +22,7 @@ #include "collisionLine.h" #include "collisionRay.h" #include "collisionSegment.h" +#include "collisionEntry.h" #include "boundingSphere.h" #include "datagram.h" #include "datagramIterator.h" diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index fc7637f5b5..3c739c21a6 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -24,7 +24,7 @@ #include "collisionRecorder.h" #include "collisionVisualizer.h" #include "config_collide.h" - +#include "boundingSphere.h" #include "transformState.h" #include "geomNode.h" #include "geom.h" diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index 783d0b3e78..c4bf0cb5ee 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -37,6 +37,7 @@ #include "geom.h" #include "geomTristrips.h" #include "geomVertexWriter.h" +#include "boundingSphere.h" PStatCollector CollisionTube::_volume_pcollector("Collision Volumes:CollisionTube"); PStatCollector CollisionTube::_test_pcollector("Collision Tests:CollisionTube"); diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 13911bc009..cb7d047f6b 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -35,6 +35,7 @@ #include "colorScaleAttrib.h" #include "transparencyAttrib.h" #include "clipPlaneAttrib.h" +#include "geomVertexWriter.h" #ifdef DO_COLLISION_RECORDING diff --git a/panda/src/collide/collisionVisualizer.h b/panda/src/collide/collisionVisualizer.h index 1e32e03cb6..3d4b1fb555 100644 --- a/panda/src/collide/collisionVisualizer.h +++ b/panda/src/collide/collisionVisualizer.h @@ -22,6 +22,7 @@ #include "pandabase.h" #include "pandaNode.h" #include "collisionRecorder.h" +#include "collisionSolid.h" #include "nodePath.h" #include "pmap.h" diff --git a/panda/src/device/Sources.pp b/panda/src/device/Sources.pp index 51a0c823e9..9b043b0cb2 100644 --- a/panda/src/device/Sources.pp +++ b/panda/src/device/Sources.pp @@ -30,7 +30,6 @@ clientDialDevice.cxx clientTrackerDevice.cxx \ config_device.cxx \ dialNode.cxx \ - dialNode.cxx \ mouseAndKeyboard.cxx \ trackerData.cxx \ trackerNode.cxx \ diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index 39437382de..39932b4a38 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -18,6 +18,7 @@ #include "trackerNode.h" #include "config_device.h" +#include "dataNodeTransmit.h" TypeHandle TrackerNode::_type_handle; diff --git a/panda/src/device/virtualMouse.cxx b/panda/src/device/virtualMouse.cxx index 3d0d83fddd..2e1ac7d6a4 100644 --- a/panda/src/device/virtualMouse.cxx +++ b/panda/src/device/virtualMouse.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "virtualMouse.h" +#include "dataNodeTransmit.h" TypeHandle VirtualMouse::_type_handle; diff --git a/panda/src/device/virtualMouse.h b/panda/src/device/virtualMouse.h index c4b7127225..26be733200 100644 --- a/panda/src/device/virtualMouse.h +++ b/panda/src/device/virtualMouse.h @@ -20,11 +20,13 @@ #define VIRTUALMOUSE_H #include "pandabase.h" - #include "dataNode.h" #include "buttonHandle.h" #include "buttonEvent.h" #include "pointerTo.h" +#include "luse.h" +#include "linmath_events.h" +#include "buttonEventList.h" //////////////////////////////////////////////////////////////////// // Class : VirtualMouse diff --git a/panda/src/dgraph/dataNodeTransmit.h b/panda/src/dgraph/dataNodeTransmit.h index cbc05f7d04..c4bb8a1dfb 100644 --- a/panda/src/dgraph/dataNodeTransmit.h +++ b/panda/src/dgraph/dataNodeTransmit.h @@ -22,6 +22,7 @@ #include "pandabase.h" #include "eventParameter.h" #include "typedWritable.h" +#include "deletedChain.h" class Datagram; class DatagramIterator; @@ -41,6 +42,7 @@ public: INLINE DataNodeTransmit(const DataNodeTransmit ©); INLINE void operator = (const DataNodeTransmit ©); virtual ~DataNodeTransmit(); + ALLOC_DELETED_CHAIN(DataNodeTransmit); INLINE void reserve(int num_wires); diff --git a/panda/src/display/Sources.pp b/panda/src/display/Sources.pp index bb586d87bd..a2980d29a1 100644 --- a/panda/src/display/Sources.pp +++ b/panda/src/display/Sources.pp @@ -28,9 +28,10 @@ graphicsWindowInputDevice.I \ graphicsWindowInputDevice.h \ graphicsDevice.h graphicsDevice.I \ + lru.h \ parasiteBuffer.I parasiteBuffer.h \ windowProperties.I windowProperties.h \ - lru.h + renderBuffer.h #define INCLUDED_SOURCES \ standardMunger.cxx \ @@ -68,6 +69,7 @@ graphicsThreadingModel.I graphicsThreadingModel.h \ graphicsWindowInputDevice.I graphicsWindowInputDevice.h \ graphicsDevice.I graphicsDevice.h \ + lru.h \ parasiteBuffer.I parasiteBuffer.h \ windowProperties.I windowProperties.h \ renderBuffer.h diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index da93cb229c..c3e43297be 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -61,6 +61,15 @@ ConfigVariableString threading_model "a 3-stage pipeline. See GraphicsEngine::set_threading_model(). " "EXPERIMENTAL and incomplete, do not use this!")); +ConfigVariableBool allow_nonpipeline_threads +("allow-nonpipeline-threads", false, + PRC_DESC("This variable should only be set true for debugging or development " + "purposes. When true, the threading-model variable may specify " + "a threaded pipeline mode, even if pipelining is not compiled in. " + "This will certainly result in erroneous behavior, and quite likely " + "will cause a crash. Do not set this unless you know what you " + "are doing.")); + ConfigVariableBool auto_flip ("auto-flip", false, PRC_DESC("This indicates the initial setting of the auto-flip flag. Set it " diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index 3c625803f6..b8ac5e5014 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -41,6 +41,7 @@ extern EXPCL_PANDA ConfigVariableBool view_frustum_cull; extern EXPCL_PANDA ConfigVariableBool pstats_unused_states; extern EXPCL_PANDA ConfigVariableString threading_model; +extern EXPCL_PANDA ConfigVariableBool allow_nonpipeline_threads; extern EXPCL_PANDA ConfigVariableBool auto_flip; extern EXPCL_PANDA ConfigVariableBool yield_timeslice; diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index 3a36fff15b..789a164d74 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -19,6 +19,7 @@ #include "frameBufferProperties.h" #include "string_utils.h" #include "renderBuffer.h" +#include "config_display.h" //////////////////////////////////////////////////////////////////// // Function: FrameBufferProperties::Constructor diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index 22abe75053..4519c302de 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -20,6 +20,7 @@ #define FRAMEBUFFERPROPERTIES_H #include "pandabase.h" +#include "pnotify.h" //////////////////////////////////////////////////////////////////// // Class : FrameBufferProperties diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index ad3c779478..3d52ab7e9d 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -179,7 +179,13 @@ set_threading_model(const GraphicsThreadingModel &threading_model) { display_cat.warning() << "Threading model " << threading_model << " requested but multithreaded render pipelines not enabled in build.\n"; - return; + if (!allow_nonpipeline_threads) { + display_cat.warning() + << "Ignoring requested threading model.\n"; + return; + } + display_cat.warning() + << "Danger! Creating requested render threads anyway!\n"; } #endif // THREADED_PIPELINE MutexHolder holder(_lock); @@ -1705,7 +1711,7 @@ get_window_renderer(const string &name, int pipeline_stage) { thread->start(TP_normal, true, true); _threads[name] = thread; - nassertr(pipeline_stage < _pipeline->get_num_stages(), thread.p()); + nassertr(thread->get_pipeline_stage() < _pipeline->get_num_stages(), thread.p()); return thread.p(); } diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index ba42944c73..88d14d6242 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -24,6 +24,8 @@ #include "config_display.h" #include "pset.h" +#include + GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = NULL; //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 9067cd6e72..982d7fe382 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -16,7 +16,6 @@ // //////////////////////////////////////////////////////////////////// - #include "graphicsStateGuardian.h" #include "config_display.h" #include "textureContext.h" @@ -36,6 +35,9 @@ #include "colorWriteAttrib.h" #include "shader.h" #include "pnotify.h" +#include "drawableRegion.h" +#include "displayRegion.h" +#include "graphicsOutput.h" #include #include diff --git a/panda/src/display/lru.cxx b/panda/src/display/lru.cxx index 52102913e1..f270e21023 100644 --- a/panda/src/display/lru.cxx +++ b/panda/src/display/lru.cxx @@ -64,7 +64,7 @@ Lru::Lru (int maximum_memory, int maximum_pages, int maximum_page_types) lru_page = new LruPage ( ); if(lru_page) { - lru_page->_m.pre_allocated = true; + lru_page->_m.v.pre_allocated = true; this->_m.lru_page_pool[index] = lru_page; } else { @@ -100,7 +100,7 @@ Lru::~Lru ( ) if(this->_m.lru_page_free_pool) { for(index = 0; index < this->_m.maximum_pages; index++) { lru_page = this->_m.lru_page_pool[index]; - if(lru_page->_m.in_lru) { + if(lru_page->_m.v.in_lru) { this->remove_page(lru_page); } @@ -214,7 +214,7 @@ LruPage *Lru::allocate_page (int size) this->_m.total_lru_pages_in_free_pool--; memset (&lru_page -> _m, 0, sizeof (LruPage::LruPageVariables)); - lru_page->_m.pre_allocated = true; + lru_page->_m.v.pre_allocated = true; } else { if(this->_m.total_lru_pages_in_pool < this->_m.maximum_pages) { @@ -236,7 +236,7 @@ LruPage *Lru::allocate_page (int size) lru_page->_m.first_frame_identifier = this->_m.current_frame_identifier; lru_page->_m.last_frame_identifier = this->_m.current_frame_identifier; - lru_page->_m.allocated = true; + lru_page->_m.v.allocated = true; lru_page->_m.identifier = this->_m.identifier; lru_page->_m.average_frame_utilization = 1.0f; @@ -298,13 +298,13 @@ void Lru::free_page (LruPage *lru_page) this->update_start_update_lru_page(lru_page); - if(lru_page->_m.in_cache) { + if(lru_page->_m.v.in_cache) { this->_m.available_memory += lru_page->_m.size; } - if(lru_page->_m.pre_allocated) { + if(lru_page->_m.v.pre_allocated) { if(this->_m.maximum_pages) { - lru_page->_m.allocated = false; + lru_page->_m.v.allocated = false; this->_m.lru_page_free_pool [this->_m.total_lru_pages_in_free_pool] = lru_page; this->_m.total_lru_pages_in_free_pool++; @@ -349,7 +349,7 @@ void Lru::add_page (LruPagePriority priority, LruPage *lru_page) this->_m.lru_page_array[lru_page->_m.priority] = lru_page; - lru_page->_m.in_lru = true; + lru_page->_m.v.in_lru = true; } } @@ -364,7 +364,7 @@ void Lru::add_cached_page (LruPagePriority priority, LruPage *lru_page) if(lru_page) { LruMutexHolder(this->_m.mutex); - lru_page->_m.in_cache = true; + lru_page->_m.v.in_cache = true; if(lru_page->_m.size > this->_m.available_memory) { int memory_required; @@ -412,7 +412,7 @@ void Lru::remove_page (LruPage *lru_page) lru_page->_m.next = 0; lru_page->_m.previous = 0; - lru_page->_m.in_lru = false; + lru_page->_m.v.in_lru = false; } } else { @@ -435,7 +435,7 @@ void Lru::remove_page (LruPage *lru_page) //////////////////////////////////////////////////////////////////// void Lru::lock_page (LruPage *lru_page) { - lru_page->_m.lock = true; + lru_page->_m.v.lock = true; } //////////////////////////////////////////////////////////////////// @@ -445,7 +445,7 @@ void Lru::lock_page (LruPage *lru_page) //////////////////////////////////////////////////////////////////// void Lru::unlock_page (LruPage *lru_page) { - lru_page->_m.lock = false; + lru_page->_m.v.lock = false; } //////////////////////////////////////////////////////////////////// @@ -475,7 +475,7 @@ void Lru::access_page (LruPage *lru_page) } // check if the page is out - if(lru_page->_m.in_cache == false) { + if(lru_page->_m.v.in_cache == false) { bool state; state = true; @@ -495,9 +495,9 @@ void Lru::access_page (LruPage *lru_page) // load the page in if(state) { // PAGE IN CALLBACK - if(this->_m.page_in_function_array[lru_page->_m.type](lru_page)) { + if(this->_m.page_in_function_array[lru_page->_m.v.type](lru_page)) { this->_m.available_memory -= lru_page->_m.size; - lru_page->_m.in_cache = true; + lru_page->_m.v.in_cache = true; // CHANGE THE PAGE PRIORITY FROM LPP_PageOut TO LPP_New this->remove_page(lru_page); @@ -606,7 +606,7 @@ void Lru::update_lru_page (LruPage *lru_page) } #endif - if(lru_page->_m.lock == false && lru_page->_m.in_cache) { + if(lru_page->_m.v.lock == false && lru_page->_m.v.in_cache) { int delta_priority; int lifetime_frames; @@ -702,7 +702,7 @@ void Lru::update_lru_page_old (LruPage *lru_page) } #endif - if(lru_page->_m.lock == false) { + if(lru_page->_m.v.lock == false) { int delta_priority; delta_priority = 0; @@ -989,7 +989,7 @@ void Lru::unlock_all_pages (void) while(lru_page) { next_lru_page = lru_page->_m.next; - lru_page->_m.lock = false; + lru_page->_m.v.lock = false; lru_page = next_lru_page; } @@ -1026,13 +1026,13 @@ bool Lru::page_out_lru (int memory_required) while(lru_page) { next_lru_page = lru_page->_m.next; - if(lru_page->_m.lock == false && lru_page->_m.in_cache) { + if(lru_page->_m.v.lock == false && lru_page->_m.v.in_cache) { memory_required -= lru_page->_m.size; this->_m.available_memory += lru_page->_m.size; - lru_page->_m.in_cache = false; + lru_page->_m.v.in_cache = false; // PAGE OUT CALLBACK - this->_m.page_out_function_array[lru_page->_m.type](lru_page); + this->_m.page_out_function_array[lru_page->_m.v.type](lru_page); this->_m.total_lifetime_page_outs++; // MOVE THE PAGE TO THE LPP_PageOut PRIORITY @@ -1124,11 +1124,11 @@ void Lru::calculate_lru_statistics (void) next_lru_page = lru_page->_m.next; - type = lru_page->_m.type; + type = lru_page->_m.v.type; page_type_statistics = &this->_m.page_type_statistics_array[type]; page_type_statistics->total_pages++; - if(lru_page->_m.in_cache) { + if(lru_page->_m.v.in_cache) { page_type_statistics->total_pages_in++; page_type_statistics->total_memory_in += lru_page->_m.size; } diff --git a/panda/src/display/lru.h b/panda/src/display/lru.h index 8011d33f20..4a8305e389 100644 --- a/panda/src/display/lru.h +++ b/panda/src/display/lru.h @@ -98,7 +98,7 @@ public: unsigned int pre_allocated : 1; unsigned int allocated : 1; unsigned int in_lru : 1; - }; + } v; int first_frame_identifier; // creation time int last_frame_identifier; // previous time page was used diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index b2c2db8dd4..8c9a6773d9 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "windowProperties.h" +#include "config_display.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 83df8ec83a..f8c5005fff 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -26,6 +26,8 @@ #include "geomVertexWriter.h" #include "geomVertexReader.h" #include "geomVertexRewriter.h" +#include "config_distort.h" +#include "cullTraverserData.h" TypeHandle ProjectionScreen::_type_handle; diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index c03dca9a87..d424094e4b 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -17,10 +17,12 @@ //////////////////////////////////////////////////////////////////// #include "bioPtr.h" -#include "urlSpec.h" #ifdef HAVE_OPENSSL +#include "urlSpec.h" +#include "config_downloader.h" + //////////////////////////////////////////////////////////////////// // Function: BioPtr::Constructor // Access: Public diff --git a/panda/src/downloader/download_utils.cxx b/panda/src/downloader/download_utils.cxx index e50124fad1..8d943a8c8c 100644 --- a/panda/src/downloader/download_utils.cxx +++ b/panda/src/downloader/download_utils.cxx @@ -43,7 +43,7 @@ check_crc(Filename name) { // Compute the crc unsigned long crc = crc32(0L, Z_NULL, 0); - crc = crc32(crc, (uchar *)buffer, buffer_length); + crc = crc32(crc, (unsigned char *)buffer, buffer_length); delete buffer; @@ -69,7 +69,7 @@ check_adler(Filename name) { // Compute the adler checksum unsigned long adler = adler32(0L, Z_NULL, 0); - adler = adler32(adler, (uchar *)buffer, buffer_length); + adler = adler32(adler, (unsigned char *)buffer, buffer_length); delete buffer; diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index 91bcffa72f..819c46d227 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -20,6 +20,7 @@ #ifdef HAVE_OPENSSL +#include "httpChannel.h" #include "openssl/ssl.h" #include "openssl/md5.h" #include diff --git a/panda/src/dxgsg8/dxGeomMunger8.I b/panda/src/dxgsg8/dxGeomMunger8.I index 4e2abf5b8f..431a6ae2c6 100644 --- a/panda/src/dxgsg8/dxGeomMunger8.I +++ b/panda/src/dxgsg8/dxGeomMunger8.I @@ -32,15 +32,3 @@ DXGeomMunger8(GraphicsStateGuardian *gsg, const RenderState *state) : _texture = _texture->filter_to_max(gsg->get_max_texture_stages()); } } - -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger8::operator new -// Access: Public -// Description: Calls up to do_operator_new() to implement the -// low-overhead allocation/deallocation for this type of -// GeomMunger. -//////////////////////////////////////////////////////////////////// -INLINE void *DXGeomMunger8:: -operator new(size_t size) { - return do_operator_new(size, &_deleted_chain); -} diff --git a/panda/src/dxgsg8/dxGeomMunger8.h b/panda/src/dxgsg8/dxGeomMunger8.h index 1e460eae54..17479391f0 100644 --- a/panda/src/dxgsg8/dxGeomMunger8.h +++ b/panda/src/dxgsg8/dxGeomMunger8.h @@ -34,6 +34,7 @@ class EXPCL_PANDADX DXGeomMunger8 : public StandardMunger { public: INLINE DXGeomMunger8(GraphicsStateGuardian *gsg, const RenderState *state); + ALLOC_DELETED_CHAIN(DXGeomMunger8); protected: virtual CPT(GeomVertexFormat) munge_format_impl(const GeomVertexFormat *orig, @@ -42,9 +43,6 @@ protected: virtual int compare_to_impl(const GeomMunger *other) const; virtual int geom_compare_to_impl(const GeomMunger *other) const; -public: - INLINE void *operator new(size_t size); - private: CPT(TextureAttrib) _texture; CPT(TexGenAttrib) _tex_gen; diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index 7c68d2cfdb..94b63c528f 100755 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -33,15 +33,3 @@ DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : } } -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::operator new -// Access: Public -// Description: Calls up to do_operator_new() to implement the -// low-overhead allocation/deallocation for this type of -// GeomMunger. -//////////////////////////////////////////////////////////////////// -INLINE void *DXGeomMunger9:: -operator new(size_t size) { - return do_operator_new(size, &_deleted_chain); -} - diff --git a/panda/src/dxgsg9/dxGeomMunger9.h b/panda/src/dxgsg9/dxGeomMunger9.h index c97bf834e2..55b52cc9b2 100755 --- a/panda/src/dxgsg9/dxGeomMunger9.h +++ b/panda/src/dxgsg9/dxGeomMunger9.h @@ -34,6 +34,7 @@ class EXPCL_PANDADX DXGeomMunger9 : public StandardMunger { public: INLINE DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state); + ALLOC_DELETED_CHAIN(DXGeomMunger9); protected: virtual CPT(GeomVertexFormat) munge_format_impl(const GeomVertexFormat *orig, @@ -42,9 +43,6 @@ protected: virtual int compare_to_impl(const GeomMunger *other) const; virtual int geom_compare_to_impl(const GeomMunger *other) const; -public: - INLINE void *operator new(size_t size); - private: CPT(TextureAttrib) _texture; CPT(TexGenAttrib) _tex_gen; diff --git a/panda/src/dxgsg9/dxIndexBufferContext9.cxx b/panda/src/dxgsg9/dxIndexBufferContext9.cxx index 9b86cbaeff..9477fc2515 100755 --- a/panda/src/dxgsg9/dxIndexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxIndexBufferContext9.cxx @@ -180,7 +180,7 @@ create_ibuffer(DXScreenData &scrn) { lru_page = lru -> allocate_page (data_size); if (lru_page) { - lru_page -> _m.type = GPT_IndexBuffer; + lru_page -> _m.v.type = GPT_IndexBuffer; lru_page -> _m.lru_page_type.pointer = this; lru -> add_cached_page (LPP_New, lru_page); diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index ff47d97a71..49c3df833d 100755 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -829,7 +829,7 @@ create_texture(DXScreenData &scrn) { lru_page = lru -> allocate_page (data_size); if (lru_page) { - lru_page -> _m.type = GPT_Texture; + lru_page -> _m.v.type = GPT_Texture; lru_page -> _m.lru_page_type.pointer = this; lru -> add_cached_page (LPP_New, lru_page); diff --git a/panda/src/dxgsg9/dxVertexBufferContext9.cxx b/panda/src/dxgsg9/dxVertexBufferContext9.cxx index 904ed30b38..c64cc397f8 100755 --- a/panda/src/dxgsg9/dxVertexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxVertexBufferContext9.cxx @@ -419,7 +419,7 @@ create_vbuffer(DXScreenData &scrn) { lru_page = lru -> allocate_page (data_size); if (lru_page) { - lru_page -> _m.type = GPT_VertexBuffer; + lru_page -> _m.v.type = GPT_VertexBuffer; lru_page -> _m.lru_page_type.pointer = this; lru -> add_cached_page (LPP_New, lru_page); diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index a5b6895fb6..3b879d8936 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -18,6 +18,7 @@ #include "eggCompositePrimitive.h" #include "eggGroupNode.h" +#include "eggVertexPool.h" TypeHandle EggCompositePrimitive::_type_handle; diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index e2ba5466c0..2360be8d8e 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -21,6 +21,8 @@ #include "eggPolygon.h" #include "eggCompositePrimitive.h" #include "eggTriangleStrip.h" +#include "eggTriangleFan.h" +#include "eggGroup.h" #include "config_egg.h" #include "eggGroupNode.h" #include "dcast.h" diff --git a/panda/src/egg/eggMesherFanMaker.cxx b/panda/src/egg/eggMesherFanMaker.cxx index 8d88000875..f20f3c1e2d 100644 --- a/panda/src/egg/eggMesherFanMaker.cxx +++ b/panda/src/egg/eggMesherFanMaker.cxx @@ -17,6 +17,9 @@ //////////////////////////////////////////////////////////////////// #include "eggMesherFanMaker.h" +#include "eggMesher.h" +#include "eggPolygon.h" +#include "eggGroupNode.h" //////////////////////////////////////////////////////////////////// // Function: EggMesherFanMaker::Constructor diff --git a/panda/src/egg/eggMesherFanMaker.h b/panda/src/egg/eggMesherFanMaker.h index 0b796b09ec..0b0a26f3f0 100644 --- a/panda/src/egg/eggMesherFanMaker.h +++ b/panda/src/egg/eggMesherFanMaker.h @@ -23,7 +23,7 @@ #include "eggMesherEdge.h" #include "eggMesherStrip.h" - +#include "config_egg.h" #include "plist.h" #include "pvector.h" diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index cee3600786..9e2ca3c5c5 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -39,6 +39,7 @@ #include "materialAttrib.h" #include "materialPool.h" #include "config_gobj.h" +#include "config_egg2pg.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/Sources.pp b/panda/src/express/Sources.pp index f2ded7784a..bfff880532 100644 --- a/panda/src/express/Sources.pp +++ b/panda/src/express/Sources.pp @@ -9,11 +9,6 @@ #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ - atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I atomicAdjust.h \ - atomicAdjust.I atomicAdjustImpl.h \ - atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ - atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ - atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ bigEndian.h buffer.I buffer.h \ checksumHashGenerator.I checksumHashGenerator.h circBuffer.I \ circBuffer.h \ @@ -35,7 +30,6 @@ multifile.I multifile.h \ namable.I \ namable.h nativeNumericData.I nativeNumericData.h \ - numeric_types.h \ ordered_vector.h ordered_vector.I ordered_vector.T \ password_hash.h \ patchfile.I patchfile.h \ @@ -71,10 +65,6 @@ zStream.I zStream.h zStreamBuf.h #define INCLUDED_SOURCES \ - atomicAdjust.cxx atomicAdjustDummyImpl.cxx \ - atomicAdjustNsprImpl.cxx \ - atomicAdjustPosixImpl.cxx \ - atomicAdjustWin32Impl.cxx \ buffer.cxx checksumHashGenerator.cxx \ config_express.cxx \ datagram.cxx datagramGenerator.cxx \ @@ -119,11 +109,6 @@ zStream.cxx zStreamBuf.cxx #define INSTALL_HEADERS \ - atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I atomicAdjust.h \ - atomicAdjust.I atomicAdjustImpl.h \ - atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ - atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ - atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ bigEndian.h buffer.I buffer.h \ checksumHashGenerator.I checksumHashGenerator.h circBuffer.I \ circBuffer.h \ @@ -145,7 +130,6 @@ multifile.I multifile.h \ namable.I \ namable.h nativeNumericData.I nativeNumericData.h \ - numeric_types.h \ ordered_vector.h ordered_vector.I ordered_vector.T \ password_hash.h \ patchfile.I patchfile.h \ diff --git a/panda/src/express/atomicAdjust.I b/panda/src/express/atomicAdjust.I deleted file mode 100644 index 2f8f527bdc..0000000000 --- a/panda/src/express/atomicAdjust.I +++ /dev/null @@ -1,65 +0,0 @@ -// Filename: atomicAdjust.I -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjust::inc -// Access: Public, Static -// Description: Atomically increments the indicated variable and -// returns the new value. -//////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjust:: -inc(PN_int32 &var) { - return AtomicAdjustImpl::inc(var); -} - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjust::dec -// Access: Public, Static -// Description: Atomically decrements the indicated variable and -// returns the new value. -//////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjust:: -dec(PN_int32 &var) { - return AtomicAdjustImpl::dec(var); -} - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjust::set -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjust:: -set(PN_int32 &var, PN_int32 new_value) { - return AtomicAdjustImpl::set(var, new_value); -} - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjust::get -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// -INLINE PN_int32 AtomicAdjust:: -get(const PN_int32 &var) { - return AtomicAdjustImpl::get(var); -} diff --git a/panda/src/express/dcast.T b/panda/src/express/dcast.T index 599287d862..a29613121e 100644 --- a/panda/src/express/dcast.T +++ b/panda/src/express/dcast.T @@ -26,6 +26,7 @@ template INLINE TypeHandle _dcast_get_typehandle(WantType *) { + TAU_PROFILE("_dcast_get_typehandle()", " ", TAU_USER); TypeHandle handle = WantType::get_class_type(); #ifdef _DEBUG @@ -55,6 +56,7 @@ template INLINE WantType * _dcast(WantType *, TypedObject *ptr) { #ifdef DO_DCAST + TAU_PROFILE("_dcast()", " ", TAU_USER); TypeHandle want_handle = _dcast_get_typehandle((WantType *)0); if (!_dcast_verify(want_handle, sizeof(WantType), ptr)) { return (WantType *)NULL; @@ -76,6 +78,7 @@ template INLINE const WantType * _dcast(WantType *, const TypedObject *ptr) { #ifdef DO_DCAST + TAU_PROFILE("_dcast()", " ", TAU_USER); TypeHandle want_handle = _dcast_get_typehandle((WantType *)0); if (!_dcast_verify(want_handle, sizeof(WantType), ptr)) { return (const WantType *)NULL; diff --git a/panda/src/express/express_composite1.cxx b/panda/src/express/express_composite1.cxx index f22af42f6f..300050f3a4 100644 --- a/panda/src/express/express_composite1.cxx +++ b/panda/src/express/express_composite1.cxx @@ -1,8 +1,3 @@ -#include "atomicAdjust.cxx" -#include "atomicAdjustDummyImpl.cxx" -#include "atomicAdjustNsprImpl.cxx" -#include "atomicAdjustPosixImpl.cxx" -#include "atomicAdjustWin32Impl.cxx" #include "buffer.cxx" #include "checksumHashGenerator.cxx" #include "config_express.cxx" diff --git a/panda/src/express/memoryInfo.cxx b/panda/src/express/memoryInfo.cxx index 87e1f900e8..8093128193 100644 --- a/panda/src/express/memoryInfo.cxx +++ b/panda/src/express/memoryInfo.cxx @@ -16,9 +16,10 @@ // //////////////////////////////////////////////////////////////////// +#include "memoryInfo.h" + #ifdef DO_MEMORY_USAGE -#include "memoryInfo.h" #include "typedReferenceCount.h" #include "typeHandle.h" diff --git a/panda/src/express/memoryUsage.I b/panda/src/express/memoryUsage.I index 6bf31d5b6e..397a49a344 100644 --- a/panda/src/express/memoryUsage.I +++ b/panda/src/express/memoryUsage.I @@ -30,8 +30,6 @@ get_track_memory_usage() { return get_global_ptr()->_track_memory_usage; } -#ifndef __GNUC__ - //////////////////////////////////////////////////////////////////// // Function: MemoryUsage::record_pointer // Access: Public, Static @@ -83,8 +81,6 @@ remove_pointer(ReferenceCount *ptr) { get_global_ptr()->ns_remove_pointer(ptr); } -#endif // __GNUC__ - //////////////////////////////////////////////////////////////////// // Function: MemoryUsage::is_tracking // Access: Public, Static diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index 248064dd81..4d5f2171d7 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -16,13 +16,14 @@ // //////////////////////////////////////////////////////////////////// +#include "memoryUsage.h" + #ifdef DO_MEMORY_USAGE #include "memoryUsagePointers.h" #include "trueClock.h" #include "typedReferenceCount.h" - -#include "memoryUsage.h" +#include "mutexImpl.h" #include "interrogate_request.h" #if defined(WIN32_VC) && defined(_DEBUG) @@ -189,61 +190,6 @@ choose_bucket(double age) const { return 0; } -#if defined(__GNUC__) - -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::record_pointer -// Access: Public, Static -// Description: Indicates that the given pointer has been recently -// allocated. -//////////////////////////////////////////////////////////////////// -void MemoryUsage:: -record_pointer(ReferenceCount *ptr) { - get_global_ptr()->ns_record_pointer(ptr); -} - -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::update_type -// Access: Public, Static -// Description: Associates the indicated type with the given pointer. -// This should be called by functions (e.g. the -// constructor) that know more specifically what type of -// thing we've got; otherwise, the MemoryUsage database -// will know only that it's a "ReferenceCount". -//////////////////////////////////////////////////////////////////// -void MemoryUsage:: -update_type(ReferenceCount *ptr, TypeHandle type) { - get_global_ptr()->ns_update_type(ptr, type); -} - -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::update_type -// Access: Public, Static -// Description: Associates the indicated type with the given pointer. -// This flavor of update_type() also passes in the -// pointer as a TypedObject, and useful for objects that -// are, in fact, TypedObjects. Once the MemoryUsage -// database has the pointer as a TypedObject it doesn't -// need any more help. -//////////////////////////////////////////////////////////////////// -void MemoryUsage:: -update_type(ReferenceCount *ptr, TypedObject *typed_ptr) { - get_global_ptr()->ns_update_type(ptr, typed_ptr); -} - -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::remove_pointer -// Access: Public, Static -// Description: Indicates that the given pointer has been recently -// freed. -//////////////////////////////////////////////////////////////////// -void MemoryUsage:: -remove_pointer(ReferenceCount *ptr) { - get_global_ptr()->ns_remove_pointer(ptr); -} - -#endif // __GNUC__ - //////////////////////////////////////////////////////////////////// // Function: MemoryUsage::operator_new_handler // Access: Public, Static @@ -278,6 +224,18 @@ operator_new_handler(size_t size) { } } + /* + cerr << "new(" << size << ") = " << ptr << "\n"; + static int counter = 0; + static int target = 0; + + ++counter; + if (target == 0 && counter == 1000) { + target = ConfigVariableInt("target", 10000); + } + nassertr(counter != target, ptr); + */ + return ptr; } @@ -292,6 +250,7 @@ operator_new_handler(size_t size) { //////////////////////////////////////////////////////////////////// void MemoryUsage:: operator_delete_handler(void *ptr) { + cerr << "delete(" << ptr << ")\n"; if (_recursion_protect) { if (express_cat.is_spam()) { express_cat.spam() @@ -627,6 +586,7 @@ ns_record_void_pointer(void *ptr, size_t size) { // We have to protect modifications to the table from recursive // calls by toggling _recursion_protect while we adjust it. + _recursion_protect = true; pair insert_result = _table.insert(Table::value_type((void *)ptr, MemoryInfo())); @@ -1021,7 +981,7 @@ ns_show_trend_ages() { // Function: MemoryUsage::consolidate_void_ptr // Access: Private // Description: If the size information has not yet been determined -// for this pointer, checks to see if it has possible +// for this pointer, checks to see if it has possibly // been recorded under the TypedObject pointer (this // will happen when the class inherits from TypedObject // before ReferenceCount, e.g. TypedReferenceCount). diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index dba019c499..8806425f0d 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -46,23 +46,10 @@ class EXPCL_PANDAEXPRESS MemoryUsage { public: INLINE static bool get_track_memory_usage(); -#if defined(__GNUC__) - // There seems to be a problem with egcs-2.91.66: it gets confused - // with too many nested inline functions, and sets the wrong pointer - // as 'this'. Yucky. The workaround is to make these functions - // non-inline, but this is inner-loop stuff, and we'd rather not pay - // the price universally. So we only compile them non-inline when - // we're building on GCC. - static void record_pointer(ReferenceCount *ptr); - static void update_type(ReferenceCount *ptr, TypeHandle type); - static void update_type(ReferenceCount *ptr, TypedObject *typed_ptr); - static void remove_pointer(ReferenceCount *ptr); -#else // __GNUC__ INLINE static void record_pointer(ReferenceCount *ptr); INLINE static void update_type(ReferenceCount *ptr, TypeHandle type); INLINE static void update_type(ReferenceCount *ptr, TypedObject *typed_ptr); INLINE static void remove_pointer(ReferenceCount *ptr); -#endif // __GNUC__ public: static void *operator_new_handler(size_t size); diff --git a/panda/src/express/memoryUsagePointerCounts.cxx b/panda/src/express/memoryUsagePointerCounts.cxx index 3487788072..1b155c04b7 100644 --- a/panda/src/express/memoryUsagePointerCounts.cxx +++ b/panda/src/express/memoryUsagePointerCounts.cxx @@ -16,9 +16,10 @@ // //////////////////////////////////////////////////////////////////// +#include "memoryUsagePointerCounts.h" + #ifdef DO_MEMORY_USAGE -#include "memoryUsagePointerCounts.h" #include "memoryInfo.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/memoryUsagePointers.cxx b/panda/src/express/memoryUsagePointers.cxx index ccbb2d524d..a9634eb1a9 100644 --- a/panda/src/express/memoryUsagePointers.cxx +++ b/panda/src/express/memoryUsagePointers.cxx @@ -16,9 +16,10 @@ // //////////////////////////////////////////////////////////////////// +#include "memoryUsagePointers.h" + #ifdef DO_MEMORY_USAGE -#include "memoryUsagePointers.h" #include "config_express.h" #include "referenceCount.h" #include "typedReferenceCount.h" diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index 027306ade4..62d6d84b2d 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -311,6 +311,7 @@ operator >= (const ordered_vector &other) const { template INLINE pair::ITERATOR, bool> ordered_vector:: insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { + TAU_PROFILE("ordered_vector::insert_unique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); #ifdef NDEBUG pair bogus_result(end(), false); @@ -343,6 +344,7 @@ insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { + TAU_PROFILE("ordered_vector::insert_nonunique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); nassertr(position >= begin() && position <= end(), end()); @@ -360,6 +362,7 @@ insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: erase(TYPENAME ordered_vector::ITERATOR position) { + TAU_PROFILE("ordered_vector::erase(iterator)", " ", TAU_USER); SIZE_TYPE count = position - begin(); _vector.erase(position); return begin() + count; @@ -374,6 +377,7 @@ erase(TYPENAME ordered_vector::ITERATOR position) { template INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: erase(const TYPENAME ordered_vector::KEY_TYPE &key) { + TAU_PROFILE("ordered_vector::erase(const key_type &)", " ", TAU_USER); pair result = equal_range(key); SIZE_TYPE count = result.second - result.first; erase(result.first, result.second); @@ -390,6 +394,7 @@ template INLINE void ordered_vector:: erase(TYPENAME ordered_vector::ITERATOR first, TYPENAME ordered_vector::ITERATOR last) { + TAU_PROFILE("ordered_vector::erase(iterator, iterator)", " ", TAU_USER); _vector.erase(first, last); } @@ -401,6 +406,7 @@ erase(TYPENAME ordered_vector::ITERATOR first, template INLINE void ordered_vector:: clear() { + TAU_PROFILE("ordered_vector::clear()", " ", TAU_USER); _vector.erase(_vector.begin(), _vector.end()); } @@ -415,6 +421,7 @@ clear() { template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: find(const TYPENAME ordered_vector::KEY_TYPE &key) { + TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return nci(r_find(begin(), end(), end(), key)); } @@ -429,6 +436,7 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) { template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: find(const TYPENAME ordered_vector::KEY_TYPE &key) const { + TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return r_find(begin(), end(), end(), key); } @@ -451,6 +459,7 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) const { template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { + TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return nci(r_find_particular(begin(), end(), end(), key)); } @@ -470,6 +479,7 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) const { + TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return r_find_particular(begin(), end(), end(), key); } @@ -482,6 +492,7 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) cons template INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: count(const key_type &key) const { + TAU_PROFILE("ordered_vector::count(const key_type &)", " ", TAU_USER); return r_count(begin(), end(), key); } @@ -494,6 +505,7 @@ count(const key_type &key) const { template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { + TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return nci(r_lower_bound(begin(), end(), key)); } @@ -506,6 +518,7 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { + TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return r_lower_bound(begin(), end(), key); } @@ -519,6 +532,7 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { + TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return nci(r_upper_bound(begin(), end(), key)); } @@ -532,6 +546,7 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { + TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return r_upper_bound(begin(), end(), key); } @@ -543,6 +558,7 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { template INLINE pair::ITERATOR, TYPENAME ordered_vector::ITERATOR> ordered_vector:: equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { + TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> result; result = r_equal_range(begin(), end(), key); return pair::ITERATOR, TYPENAME ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); @@ -556,6 +572,7 @@ equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { template INLINE pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { + TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); return r_equal_range(begin(), end(), key); } @@ -568,6 +585,7 @@ equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { template INLINE void ordered_vector:: swap(ordered_vector ©) { + TAU_PROFILE("ordered_vector::swap(ordered_vector &)", " ", TAU_USER); _vector.swap(copy._vector); } @@ -581,6 +599,7 @@ swap(ordered_vector ©) { template INLINE void ordered_vector:: reserve(TYPENAME ordered_vector::SIZE_TYPE n) { + TAU_PROFILE("ordered_vector::reserve(size_type)", " ", TAU_USER); _vector.reserve(n); } @@ -599,6 +618,7 @@ reserve(TYPENAME ordered_vector::SIZE_TYPE n) { template INLINE void ordered_vector:: sort_unique() { + TAU_PROFILE("ordered_vector::sort_unique()", " ", TAU_USER); sort(begin(), end(), _compare); iterator new_end = unique(begin(), end(), EquivalentTest(_compare)); erase(new_end, end()); @@ -616,6 +636,7 @@ sort_unique() { template INLINE void ordered_vector:: sort_nonunique() { + TAU_PROFILE("ordered_vector::sort_nonunique()", " ", TAU_USER); stable_sort(begin(), end(), _compare); } @@ -630,6 +651,7 @@ sort_nonunique() { template INLINE void ordered_vector:: push_back(const value_type &key) { + TAU_PROFILE("ordered_vector::push_back()", " ", TAU_USER); _vector.push_back(key); } @@ -641,6 +663,7 @@ push_back(const value_type &key) { template INLINE void ordered_vector:: pop_back() { + TAU_PROFILE("ordered_vector::pop_back()", " ", TAU_USER); _vector.pop_back(); } diff --git a/panda/src/express/ordered_vector.T b/panda/src/express/ordered_vector.T index 59245561b4..5d248008e3 100644 --- a/panda/src/express/ordered_vector.T +++ b/panda/src/express/ordered_vector.T @@ -35,6 +35,7 @@ template TYPENAME ordered_vector::ITERATOR ordered_vector:: insert_unique(TYPENAME ordered_vector::ITERATOR position, const TYPENAME ordered_vector::VALUE_TYPE &key) { + TAU_PROFILE("ordered_vector::insert_unique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're // inserting before should not lexicographically precede this one. @@ -81,6 +82,7 @@ template TYPENAME ordered_vector::ITERATOR ordered_vector:: insert_nonunique(TYPENAME ordered_vector::ITERATOR position, const TYPENAME ordered_vector::VALUE_TYPE &key) { + TAU_PROFILE("ordered_vector::insert_nonunique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're // inserting before should not lexicographically precede this one. @@ -112,6 +114,7 @@ insert_nonunique(TYPENAME ordered_vector::ITERATOR position, template bool ordered_vector:: verify_list_unique() const { + TAU_PROFILE("ordered_vector::verify_list_unique()", " ", TAU_USER); if (!empty()) { CONST_ITERATOR prev = begin(); CONST_ITERATOR i = begin(); @@ -138,6 +141,7 @@ verify_list_unique() const { template bool ordered_vector:: verify_list_nonunique() const { + TAU_PROFILE("ordered_vector::verify_list_nonunique()", " ", TAU_USER); if (!empty()) { CONST_ITERATOR prev = begin(); CONST_ITERATOR i = begin(); diff --git a/panda/src/express/password_hash.cxx b/panda/src/express/password_hash.cxx index bc1350819a..36f0d2993e 100644 --- a/panda/src/express/password_hash.cxx +++ b/panda/src/express/password_hash.cxx @@ -22,6 +22,7 @@ // within OpenSSL. #ifdef HAVE_OPENSSL +#include "pnotify.h" #include "openssl/evp.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index a2544266e2..fc2e6610b5 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -103,6 +103,7 @@ operator = (const ReferenceCount &) { //////////////////////////////////////////////////////////////////// INLINE ReferenceCount:: ~ReferenceCount() { + TAU_PROFILE("ReferenceCount::~ReferenceCount()", " ", TAU_USER); nassertv(this != NULL); // If this assertion fails, we're trying to delete an object that @@ -162,7 +163,7 @@ INLINE ReferenceCount:: //////////////////////////////////////////////////////////////////// INLINE int ReferenceCount:: get_ref_count() const { -#ifndef NDEBUG +#ifdef _DEBUG test_ref_count_integrity(); #endif return AtomicAdjust::get(_ref_count); @@ -183,14 +184,15 @@ get_ref_count() const { // with the object. An object might be const in other // ways, but we still need to accurately count the // number of references to it. -// -// The return value is the new reference count. //////////////////////////////////////////////////////////////////// -INLINE int ReferenceCount:: +INLINE void ReferenceCount:: ref() const { - nassertr(test_ref_count_integrity(), 0); + TAU_PROFILE("void ReferenceCount::ref()", " ", TAU_USER); +#ifdef _DEBUG + nassertv(test_ref_count_integrity()); +#endif - return AtomicAdjust::inc(((ReferenceCount *)this)->_ref_count); + AtomicAdjust::inc(((ReferenceCount *)this)->_ref_count); } //////////////////////////////////////////////////////////////////// @@ -216,16 +218,20 @@ ref() const { // ways, but we still need to accurately count the // number of references to it. // -// The return value is the new reference count. +// The return value is true if the new reference count +// is nonzero, false if it is zero. //////////////////////////////////////////////////////////////////// -INLINE int ReferenceCount:: +INLINE bool ReferenceCount:: unref() const { + TAU_PROFILE("void ReferenceCount::unref()", " ", TAU_USER); +#ifdef _DEBUG nassertr(test_ref_count_integrity(), 0); // If this assertion fails, you tried to unref an object with a // zero reference count. Are you using ref() and unref() // directly? Are you sure you can't use PointerTo's? nassertr(_ref_count > 0, 0); +#endif return AtomicAdjust::dec(((ReferenceCount *)this)->_ref_count); } @@ -308,6 +314,7 @@ get_weak_list() const { //////////////////////////////////////////////////////////////////// INLINE void ReferenceCount:: weak_ref(WeakPointerToVoid *ptv) { + TAU_PROFILE("void ReferenceCount::weak_ref()", " ", TAU_USER); get_weak_list()->add_reference(ptv); } @@ -320,6 +327,7 @@ weak_ref(WeakPointerToVoid *ptv) { //////////////////////////////////////////////////////////////////// INLINE void ReferenceCount:: weak_unref(WeakPointerToVoid *ptv) { + TAU_PROFILE("void ReferenceCount::weak_unref()", " ", TAU_USER); nassertv(has_weak_list()); _weak_list->clear_reference(ptv); } @@ -337,12 +345,13 @@ weak_unref(WeakPointerToVoid *ptv) { template INLINE void unref_delete(RefCountType *ptr) { + TAU_PROFILE("unref_delete()", " ", TAU_USER); // Although it may be tempting to try to upcast ptr to a // ReferenceCount object (particularly to get around inheritance // issues), resist that temptation, since some classes (in // particular, TransformState and RenderState) rely on a non-virtual // overloading of the unref() method. - if (ptr->unref() == 0) { + if (!ptr->unref()) { #ifndef NDEBUG if (get_leak_memory()) { // In leak-memory mode, we don't actually delete the pointer, diff --git a/panda/src/express/referenceCount.h b/panda/src/express/referenceCount.h index 45d642b1b0..9e492dbd81 100644 --- a/panda/src/express/referenceCount.h +++ b/panda/src/express/referenceCount.h @@ -49,8 +49,8 @@ protected: PUBLISHED: INLINE int get_ref_count() const; - INLINE int ref() const; - INLINE int unref() const; + INLINE void ref() const; + INLINE bool unref() const; INLINE bool test_ref_count_integrity() const; diff --git a/panda/src/express/streamReader.h b/panda/src/express/streamReader.h index 834ec77e9d..61252921db 100644 --- a/panda/src/express/streamReader.h +++ b/panda/src/express/streamReader.h @@ -20,7 +20,7 @@ #define STREAMREADER_H #include "pandabase.h" - +#include "pnotify.h" #include "numeric_types.h" #include "littleEndian.h" #include "bigEndian.h" diff --git a/panda/src/express/streamWriter.h b/panda/src/express/streamWriter.h index 50936836bf..fcec77e59d 100644 --- a/panda/src/express/streamWriter.h +++ b/panda/src/express/streamWriter.h @@ -20,7 +20,7 @@ #define STREAMWRITER_H #include "pandabase.h" - +#include "pnotify.h" #include "numeric_types.h" #include "littleEndian.h" #include "bigEndian.h" diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index dd0b787236..8c329ec841 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -17,40 +17,13 @@ //////////////////////////////////////////////////////////////////// #include "subStreamBuf.h" +#include "pnotify.h" #ifndef HAVE_STREAMSIZE // Some compilers (notably SGI) don't define this for us typedef int streamsize; #endif /* HAVE_STREAMSIZE */ -// Temporary hack to make these thread-safe. -//#define SUBSTREAM_THREAD_SAFE - -#ifdef SUBSTREAM_THREAD_SAFE -// This requires NSPR for now. -#include -PRLock *substream_mutex = (PRLock *)NULL; - -inline void init_lock() { - if (substream_mutex == (PRLock *)NULL) { - substream_mutex = PR_NewLock(); - } -} -inline void grab_lock() { - PR_Lock(substream_mutex); -} -inline void release_lock() { - PR_Unlock(substream_mutex); -} -#else // SUBSTREAM_THREAD_SAFE -inline void init_lock() { -} -inline void grab_lock() { -} -inline void release_lock() { -} -#endif // SUBSTREAM_THREAD_SAFE - //////////////////////////////////////////////////////////////////// // Function: SubStreamBuf::Constructor // Access: Public @@ -82,8 +55,6 @@ SubStreamBuf() { // the unused part of the buffer. _unused = 0; - init_lock(); - #ifdef HAVE_IOSTREAM // The new-style iostream library doesn't seem to support allocate(). char *buf = new char[4096]; @@ -168,10 +139,10 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode mode) { if (_end == (streampos)0) { // If the end of the file is unspecified, we have to seek to // find it. - grab_lock(); + _lock.lock(); _source->seekg(off, ios::end); new_pos = _source->tellg(); - release_lock(); + _lock.release(); } else { new_pos = _end + off; @@ -269,11 +240,11 @@ underflow() { gbump(-(int)num_bytes); nassertr(gptr() + num_bytes <= egptr(), EOF); - grab_lock(); + _lock.lock(); _source->seekg(_cur); _source->read(gptr(), num_bytes); size_t read_count = _source->gcount(); - release_lock(); + _lock.release(); if (read_count != num_bytes) { // Oops, we didn't read what we thought we would. diff --git a/panda/src/express/subStreamBuf.h b/panda/src/express/subStreamBuf.h index 7b050f8c45..7e12988f12 100644 --- a/panda/src/express/subStreamBuf.h +++ b/panda/src/express/subStreamBuf.h @@ -20,6 +20,7 @@ #define SUBSTREAMBUF_H #include "pandabase.h" +#include "mutexImpl.h" //////////////////////////////////////////////////////////////////// // Class : SubStreamBuf @@ -47,6 +48,7 @@ private: streampos _end; streampos _cur; size_t _unused; + MutexImpl _lock; }; #endif diff --git a/panda/src/express/textEncoder.cxx b/panda/src/express/textEncoder.cxx index edc15d17df..2b771d77d9 100644 --- a/panda/src/express/textEncoder.cxx +++ b/panda/src/express/textEncoder.cxx @@ -19,6 +19,7 @@ #include "textEncoder.h" #include "stringDecoder.h" #include "unicodeLatinMap.h" +#include "config_express.h" TypeHandle TextEncoder::_type_handle; ConfigVariableEnum TextEncoder::_default_encoding diff --git a/panda/src/express/textEncoder.h b/panda/src/express/textEncoder.h index 6765653747..e666bf06a5 100644 --- a/panda/src/express/textEncoder.h +++ b/panda/src/express/textEncoder.h @@ -22,6 +22,7 @@ #include "pandabase.h" #include "unicodeLatinMap.h" #include "configVariableEnum.h" +#include "typedObject.h" class StringDecoder; diff --git a/panda/src/express/virtualFileSimple.cxx b/panda/src/express/virtualFileSimple.cxx index f6c93f0378..070ac5597e 100644 --- a/panda/src/express/virtualFileSimple.cxx +++ b/panda/src/express/virtualFileSimple.cxx @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////// #include "virtualFileSimple.h" +#include "virtualFileMount.h" +#include "virtualFileList.h" #include "zStream.h" TypeHandle VirtualFileSimple::_type_handle; diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index 359c674eb5..74f14b65a8 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////// #include "virtualFileSystem.h" +#include "virtualFileSimple.h" +#include "virtualFileComposite.h" #include "virtualFileMount.h" #include "virtualFileMountMultifile.h" #include "virtualFileMountSystem.h" diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 7e47bb022c..d236dcb097 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -21,6 +21,7 @@ #include "pandabase.h" #include "weakPointerToBase.h" +#include "pointerTo.h" //////////////////////////////////////////////////////////////////// // Class : WeakPointerTo diff --git a/panda/src/express/weakReferenceList.cxx b/panda/src/express/weakReferenceList.cxx index 0a5acd2025..44c5ff2211 100644 --- a/panda/src/express/weakReferenceList.cxx +++ b/panda/src/express/weakReferenceList.cxx @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////// #include "weakReferenceList.h" +#include "weakPointerToVoid.h" +#include "pnotify.h" //////////////////////////////////////////////////////////////////// // Function: WeakReferenceList::Constructor diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index 3175fd9680..778cd770ba 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -20,6 +20,9 @@ #ifdef HAVE_ZLIB +#include "pnotify.h" +#include "config_express.h" + #ifndef HAVE_STREAMSIZE // Some compilers (notably SGI) don't define this for us typedef int streamsize; diff --git a/panda/src/glstuff/glGeomContext_src.h b/panda/src/glstuff/glGeomContext_src.h index b7c63ce8f3..2a27e6b491 100644 --- a/panda/src/glstuff/glGeomContext_src.h +++ b/panda/src/glstuff/glGeomContext_src.h @@ -22,6 +22,7 @@ #include "geomVertexData.h" #include "pointerTo.h" #include "pmap.h" +#include "deletedChain.h" class CLP(GeomMunger); @@ -33,6 +34,7 @@ class EXPCL_GL CLP(GeomContext) : public GeomContext { public: INLINE CLP(GeomContext)(Geom *geom); virtual ~CLP(GeomContext)(); + ALLOC_DELETED_CHAIN(CLP(GeomContext)); bool get_display_list(GLuint &index, const CLP(GeomMunger) *munger, UpdateSeq modified); diff --git a/panda/src/glstuff/glGeomMunger_src.I b/panda/src/glstuff/glGeomMunger_src.I index e98b75c0bc..5c55e04c1f 100644 --- a/panda/src/glstuff/glGeomMunger_src.I +++ b/panda/src/glstuff/glGeomMunger_src.I @@ -29,15 +29,3 @@ CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) : _tex_gen(state->get_tex_gen()) { } - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::operator new -// Access: Public -// Description: Calls up to do_operator_new() to implement the -// low-overhead allocation/deallocation for this type of -// GeomMunger. -//////////////////////////////////////////////////////////////////// -INLINE void *CLP(GeomMunger):: -operator new(size_t size) { - return do_operator_new(size, &_deleted_chain); -} diff --git a/panda/src/glstuff/glGeomMunger_src.h b/panda/src/glstuff/glGeomMunger_src.h index 175686f245..88598b4abe 100644 --- a/panda/src/glstuff/glGeomMunger_src.h +++ b/panda/src/glstuff/glGeomMunger_src.h @@ -35,6 +35,7 @@ class EXPCL_GL CLP(GeomMunger) : public StandardMunger { public: INLINE CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state); virtual ~CLP(GeomMunger)(); + ALLOC_DELETED_CHAIN(CLP(GeomMunger)); protected: virtual CPT(GeomVertexFormat) munge_format_impl(const GeomVertexFormat *orig, @@ -42,9 +43,6 @@ protected: virtual int compare_to_impl(const GeomMunger *other) const; virtual int geom_compare_to_impl(const GeomMunger *other) const; -public: - INLINE void *operator new(size_t size); - private: CPT(TextureAttrib) _texture; CPT(TexGenAttrib) _tex_gen; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index ae000b7c79..27da266339 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -47,6 +47,7 @@ class Light; // system GL version matches or exceeds the GL version in which these // functions are defined, and the system gl.h sometimes doesn't // declare these typedefs. +#ifndef __EDG__ // Protect the following from the Tau instrumentor. typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); @@ -71,6 +72,7 @@ typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint lev typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +#endif // __EDG__ //////////////////////////////////////////////////////////////////// // Class : GLGraphicsStateGuardian diff --git a/panda/src/glstuff/glIndexBufferContext_src.h b/panda/src/glstuff/glIndexBufferContext_src.h index 2409c89445..12bb89a87f 100644 --- a/panda/src/glstuff/glIndexBufferContext_src.h +++ b/panda/src/glstuff/glIndexBufferContext_src.h @@ -18,6 +18,7 @@ #include "pandabase.h" #include "indexBufferContext.h" +#include "deletedChain.h" //////////////////////////////////////////////////////////////////// // Class : GLIndexBufferContext @@ -28,6 +29,7 @@ class EXPCL_GL CLP(IndexBufferContext) : public IndexBufferContext { public: INLINE CLP(IndexBufferContext)(PreparedGraphicsObjects *pgo, GeomPrimitive *data); + ALLOC_DELETED_CHAIN(CLP(IndexBufferContext)); // This is the GL "name" of the data object. GLuint _index; diff --git a/panda/src/glstuff/glOcclusionQueryContext_src.h b/panda/src/glstuff/glOcclusionQueryContext_src.h index 3ae331fee7..d4daae12e9 100644 --- a/panda/src/glstuff/glOcclusionQueryContext_src.h +++ b/panda/src/glstuff/glOcclusionQueryContext_src.h @@ -18,6 +18,7 @@ #include "pandabase.h" #include "occlusionQueryContext.h" +#include "deletedChain.h" class GraphicsStateGuardian; @@ -29,6 +30,7 @@ class EXPCL_GL CLP(OcclusionQueryContext) : public OcclusionQueryContext { public: INLINE CLP(OcclusionQueryContext)(GraphicsStateGuardian *gsg); virtual ~CLP(OcclusionQueryContext)(); + ALLOC_DELETED_CHAIN(CLP(OcclusionQueryContext)); virtual bool is_answer_ready() const; virtual void waiting_for_answer(); diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 46ee22f667..350c544dd5 100755 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -24,6 +24,7 @@ #include "internalName.h" #include "shaderExpansion.h" #include "shaderContext.h" +#include "deletedChain.h" class CLP(GraphicsStateGuardian); @@ -38,6 +39,7 @@ public: CLP(ShaderContext)(ShaderExpansion *s, GSG *gsg); ~CLP(ShaderContext)(); + ALLOC_DELETED_CHAIN(CLP(ShaderContext)); INLINE bool valid(void); void bind(GSG *gsg); diff --git a/panda/src/glstuff/glTextureContext_src.h b/panda/src/glstuff/glTextureContext_src.h index 83b294bf91..f7c4d6a34d 100644 --- a/panda/src/glstuff/glTextureContext_src.h +++ b/panda/src/glstuff/glTextureContext_src.h @@ -18,6 +18,7 @@ #include "pandabase.h" #include "textureContext.h" +#include "deletedChain.h" //////////////////////////////////////////////////////////////////// // Class : GLTextureContext @@ -26,6 +27,7 @@ class EXPCL_GL CLP(TextureContext) : public TextureContext { public: INLINE CLP(TextureContext)(PreparedGraphicsObjects *pgo, Texture *tex); + ALLOC_DELETED_CHAIN(CLP(TextureContext)); // This is the GL "name" of the texture object. GLuint _index; diff --git a/panda/src/glstuff/glVertexBufferContext_src.h b/panda/src/glstuff/glVertexBufferContext_src.h index 8246a22b09..af2f329f5e 100644 --- a/panda/src/glstuff/glVertexBufferContext_src.h +++ b/panda/src/glstuff/glVertexBufferContext_src.h @@ -18,6 +18,7 @@ #include "pandabase.h" #include "vertexBufferContext.h" +#include "deletedChain.h" //////////////////////////////////////////////////////////////////// // Class : GLVertexBufferContext @@ -28,6 +29,7 @@ class EXPCL_GL CLP(VertexBufferContext) : public VertexBufferContext { public: INLINE CLP(VertexBufferContext)(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data); + ALLOC_DELETED_CHAIN(CLP(VertexBufferContext)); // This is the GL "name" of the data object. GLuint _index; diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.h b/panda/src/glxdisplay/glxGraphicsStateGuardian.h index db8c3e3566..8d237a515d 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.h +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.h @@ -62,7 +62,9 @@ extern "C" void (*glXGetProcAddressARB(const GLubyte *procName))( void ); // these functions are defined, and the system glx.h sometimes doesn't // declare these typedefs. typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifndef __EDG__ // Protect the following from the Tau instrumentor. typedef int (* PFNGLXSWAPINTERVALSGIPROC) (int interval); +#endif // __EDG__ //////////////////////////////////////////////////////////////////// // Class : glxGraphicsStateGuardian diff --git a/panda/src/gobj/Sources.pp b/panda/src/gobj/Sources.pp index c21ac3bb19..e701f8d0d7 100644 --- a/panda/src/gobj/Sources.pp +++ b/panda/src/gobj/Sources.pp @@ -96,7 +96,7 @@ material.cxx \ internalName.cxx \ materialPool.cxx matrixLens.cxx \ - occlusionQuery.cxx \ + occlusionQueryContext.cxx \ orthographicLens.cxx \ perspectiveLens.cxx \ preparedGraphicsObjects.cxx \ diff --git a/panda/src/gobj/bufferResidencyTracker.cxx b/panda/src/gobj/bufferResidencyTracker.cxx index a8e32dadfc..c5a70212fd 100644 --- a/panda/src/gobj/bufferResidencyTracker.cxx +++ b/panda/src/gobj/bufferResidencyTracker.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "bufferResidencyTracker.h" +#include "bufferContext.h" #include "clockObject.h" PStatCollector BufferResidencyTracker::_gmem_collector("Graphics memory"); diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index df1cdc09b7..a9f7a6872e 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -39,6 +39,7 @@ #include "pset.h" #include "boundingVolume.h" #include "pStatCollector.h" +#include "deletedChain.h" class GeomContext; class PreparedGraphicsObjects; @@ -62,6 +63,7 @@ protected: PUBLISHED: void operator = (const Geom ©); virtual ~Geom(); + ALLOC_DELETED_CHAIN(Geom); virtual Geom *make_copy() const; @@ -182,6 +184,7 @@ private: INLINE CDataCache(); INLINE CDataCache(const CDataCache ©); virtual ~CDataCache(); + ALLOC_DELETED_CHAIN(CDataCache); virtual CycleData *make_copy() const; virtual TypeHandle get_parent_type() const { return Geom::get_class_type(); @@ -195,7 +198,8 @@ private: }; typedef CycleDataReader CDCacheReader; typedef CycleDataWriter CDCacheWriter; - + +public: // It is not clear why MSVC7 needs this class to be public. class CacheEntry : public GeomCacheEntry { public: INLINE CacheEntry(const GeomVertexData *source_data, @@ -204,6 +208,7 @@ private: const GeomVertexData *source_data, const GeomMunger *modifier); INLINE bool operator < (const CacheEntry &other) const; + ALLOC_DELETED_CHAIN(CacheEntry); virtual void evict_callback(); virtual void output(ostream &out) const; @@ -216,11 +221,13 @@ private: }; typedef pset > Cache; +private: // This is the data that must be cycled between pipeline stages. class EXPCL_PANDA CData : public CycleData { public: INLINE CData(); INLINE CData(const CData ©); + ALLOC_DELETED_CHAIN(CData); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; virtual int complete_pointers(TypedWritable **plist, BamReader *manager); diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index 484cf43006..0b59ec751d 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -20,6 +20,9 @@ #include "pStatTimer.h" #include "bamReader.h" #include "bamWriter.h" +#include "graphicsStateGuardianBase.h" +#include "geomVertexReader.h" +#include "geomVertexWriter.h" TypeHandle GeomLines::_type_handle; diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index e006934c89..6d084def88 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -22,6 +22,7 @@ #include "pStatTimer.h" #include "bamReader.h" #include "bamWriter.h" +#include "graphicsStateGuardianBase.h" TypeHandle GeomLinestrips::_type_handle; diff --git a/panda/src/gobj/geomMunger.I b/panda/src/gobj/geomMunger.I index 69a8162974..a421fd483e 100644 --- a/panda/src/gobj/geomMunger.I +++ b/panda/src/gobj/geomMunger.I @@ -129,81 +129,6 @@ munge_data(const GeomVertexData *data) const { return ((GeomMunger *)this)->munge_data_impl(data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::operator new -// Access: Public -// Description: This implementation of operator new isn't really -// supposed to be called, but it's provided in case -// someone screws up and doesn't define a more -// appropriate operator new (that passes up a valid -// _deleted_chain) for a derived class. Having this -// operator new that passes NULL for _deleted_chain will -// at least allow us to detect the error. -//////////////////////////////////////////////////////////////////// -INLINE void *GeomMunger:: -operator new(size_t size) { - return do_operator_new(size, NULL); -} - -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::operator delete -// Access: Public -// Description: This balances do_operator_new(), below, and adds the -// deleted object to the stored deleted_chain, rather -// than returning its memory to the heap. -//////////////////////////////////////////////////////////////////// -INLINE void GeomMunger:: -operator delete(void *ptr) { - GeomMunger *obj = (GeomMunger *)ptr; - -#ifndef NDEBUG - nassertd(obj->_deleted_chain != (GeomMunger **)NULL) { - delete obj; - return; - } -#endif - - nassertv(obj->_next == (GeomMunger *)NULL); - obj->_next = (*obj->_deleted_chain); - (*obj->_deleted_chain) = obj; -} - -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::do_operator_new -// Access: Protected, Static -// Description: Intended to be called from a derived class's operator -// new method, this allocates a new object from the -// indicated deleted_chain, if there is an object -// available there, or from the heap if not. -// -// In either case, the indicated deleted_chain pointer -// is cleverly stored on the new object, even before its -// constructor is called, so that it can be returned -// there when it is deleted. -//////////////////////////////////////////////////////////////////// -INLINE void *GeomMunger:: -do_operator_new(size_t size, GeomMunger **deleted_chain) { - GeomMunger *obj; - -#ifndef NDEBUG - nassertd(deleted_chain != (GeomMunger **)NULL) { - obj = (GeomMunger *)::operator new(size); - obj->_deleted_chain = NULL; - return obj; - } -#endif - - if ((*deleted_chain) != (GeomMunger *)NULL) { - obj = (*deleted_chain); - (*deleted_chain) = (*deleted_chain)->_next; - } else { - obj = (GeomMunger *)::operator new(size); - } - obj->_deleted_chain = deleted_chain; - - return obj; -} - //////////////////////////////////////////////////////////////////// // Function: GeomMunger::get_registry // Access: Private diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index 408c0771fb..c2ab0d49cc 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "geomMunger.h" +#include "geom.h" #include "geomCacheManager.h" #include "mutexHolder.h" #include "pStatTimer.h" @@ -37,7 +38,6 @@ GeomMunger() : { #ifndef NDEBUG _registered_key = get_registry()->_mungers.end(); - _next = NULL; #endif } @@ -52,7 +52,6 @@ GeomMunger(const GeomMunger ©) : { #ifndef NDEBUG _registered_key = get_registry()->_mungers.end(); - _next = NULL; #endif } diff --git a/panda/src/gobj/geomMunger.h b/panda/src/gobj/geomMunger.h index 3416a5f34b..dc25199d54 100644 --- a/panda/src/gobj/geomMunger.h +++ b/panda/src/gobj/geomMunger.h @@ -89,22 +89,6 @@ protected: virtual int compare_to_impl(const GeomMunger *other) const; virtual int geom_compare_to_impl(const GeomMunger *other) const; -public: - // To minimize overhead, each type of GeomMunger will implement new - // and delete using their own deleted_chain. This is the base class - // implementation, which requires a pointer to deleted_chain be - // stored on each instance. - INLINE void *operator new(size_t size); - INLINE void operator delete(void *ptr); - -protected: - INLINE static void *do_operator_new(size_t size, GeomMunger **_deleted_chain); - -private: - GeomMunger **_deleted_chain; - // This is the next pointer along the deleted_chain. - GeomMunger *_next; - private: class Registry; INLINE static Registry *get_registry(); diff --git a/panda/src/gobj/geomPoints.cxx b/panda/src/gobj/geomPoints.cxx index 7cc8b700fc..b3df7be134 100644 --- a/panda/src/gobj/geomPoints.cxx +++ b/panda/src/gobj/geomPoints.cxx @@ -20,6 +20,7 @@ #include "pStatTimer.h" #include "bamReader.h" #include "bamWriter.h" +#include "graphicsStateGuardianBase.h" TypeHandle GeomPoints::_type_handle; diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index 09e3335293..d0ab28edfc 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -30,6 +30,7 @@ #include "bamWriter.h" #include "ioPtaDatagramInt.h" #include "indent.h" +#include "pStatTimer.h" TypeHandle GeomPrimitive::_type_handle; diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index 2fbdb47563..150cc85377 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -32,6 +32,7 @@ #include "cycleDataReader.h" #include "cycleDataWriter.h" #include "pipelineCycler.h" +#include "deletedChain.h" class GeomVertexData; class PreparedGraphicsObjects; @@ -69,6 +70,7 @@ PUBLISHED: GeomPrimitive(const GeomPrimitive ©); void operator = (const GeomPrimitive ©); virtual ~GeomPrimitive(); + ALLOC_DELETED_CHAIN(GeomPrimitive); virtual PT(GeomPrimitive) make_copy() const=0; @@ -215,6 +217,7 @@ private: public: INLINE CData(); INLINE CData(const CData ©); + ALLOC_DELETED_CHAIN(CData); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; virtual int complete_pointers(TypedWritable **plist, BamReader *manager); diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index 441554bc4e..17bb4243b9 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -21,6 +21,7 @@ #include "pStatTimer.h" #include "bamReader.h" #include "bamWriter.h" +#include "graphicsStateGuardianBase.h" TypeHandle GeomTriangles::_type_handle; diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index 403babc4c3..245715bf2c 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -21,6 +21,7 @@ #include "geomVertexRewriter.h" #include "bamReader.h" #include "bamWriter.h" +#include "graphicsStateGuardianBase.h" TypeHandle GeomTrifans::_type_handle; diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index 95e1b9b9d1..582e568cee 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -22,6 +22,7 @@ #include "pStatTimer.h" #include "bamReader.h" #include "bamWriter.h" +#include "graphicsStateGuardianBase.h" TypeHandle GeomTristrips::_type_handle; diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 20bb81882f..a6b2c3f1be 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -66,6 +66,7 @@ PUBLISHED: GeomVertexArrayData(const GeomVertexArrayData ©); void operator = (const GeomVertexArrayData ©); virtual ~GeomVertexArrayData(); + ALLOC_DELETED_CHAIN(GeomVertexArrayData); INLINE const GeomVertexArrayFormat *get_array_format() const; @@ -120,6 +121,7 @@ private: public: INLINE CData(); INLINE CData(const CData ©); + ALLOC_DELETED_CHAIN(CData); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg, void *extra_data) const; diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index 4a4e9583c5..1942942ecf 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "geomVertexColumn.h" +#include "geomVertexData.h" #include "bamReader.h" #include "bamWriter.h" diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index e30259c52f..8c0adc531e 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "geomVertexData.h" +#include "geom.h" #include "geomVertexReader.h" #include "geomVertexWriter.h" #include "geomVertexRewriter.h" diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 9544b1ed1a..ed2cae30a7 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -40,6 +40,7 @@ #include "pointerTo.h" #include "pmap.h" #include "pvector.h" +#include "deletedChain.h" class FactoryParams; class GeomVertexColumn; @@ -85,6 +86,7 @@ PUBLISHED: const GeomVertexFormat *format); void operator = (const GeomVertexData ©); virtual ~GeomVertexData(); + ALLOC_DELETED_CHAIN(GeomVertexData); INLINE const string &get_name() const; void set_name(const string &name); @@ -208,6 +210,7 @@ private: public: INLINE CDataCache(); INLINE CDataCache(const CDataCache ©); + ALLOC_DELETED_CHAIN(CDataCache); virtual CycleData *make_copy() const; virtual TypeHandle get_parent_type() const { return GeomVertexData::get_class_type(); @@ -218,11 +221,13 @@ private: typedef CycleDataReader CDCacheReader; typedef CycleDataWriter CDCacheWriter; +public: // It is not clear why MSVC7 needs this class to be public. class CacheEntry : public GeomCacheEntry { public: INLINE CacheEntry(const GeomVertexFormat *modifier); INLINE CacheEntry(GeomVertexData *source, const GeomVertexFormat *modifier); + ALLOC_DELETED_CHAIN(CacheEntry); INLINE bool operator < (const CacheEntry &other) const; virtual void evict_callback(); @@ -235,11 +240,13 @@ private: }; typedef pset > Cache; +private: // This is the data that must be cycled between pipeline stages. class EXPCL_PANDA CData : public CycleData { public: INLINE CData(); INLINE CData(const CData ©); + ALLOC_DELETED_CHAIN(CData); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; virtual int complete_pointers(TypedWritable **plist, BamReader *manager); diff --git a/panda/src/gobj/matrixLens.cxx b/panda/src/gobj/matrixLens.cxx index 42e7dec655..5a5a4a1b4b 100644 --- a/panda/src/gobj/matrixLens.cxx +++ b/panda/src/gobj/matrixLens.cxx @@ -18,6 +18,7 @@ #include "matrixLens.h" #include "indent.h" +#include "bamReader.h" TypeHandle MatrixLens::_type_handle; diff --git a/panda/src/gobj/orthographicLens.cxx b/panda/src/gobj/orthographicLens.cxx index e4881e0d8e..be5e61122c 100644 --- a/panda/src/gobj/orthographicLens.cxx +++ b/panda/src/gobj/orthographicLens.cxx @@ -18,6 +18,7 @@ #include "orthographicLens.h" #include "indent.h" +#include "bamReader.h" TypeHandle OrthographicLens::_type_handle; diff --git a/panda/src/gobj/perspectiveLens.cxx b/panda/src/gobj/perspectiveLens.cxx index c99d583ab7..8f3ff68b05 100644 --- a/panda/src/gobj/perspectiveLens.cxx +++ b/panda/src/gobj/perspectiveLens.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "perspectiveLens.h" +#include "bamReader.h" TypeHandle PerspectiveLens::_type_handle; diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 5d3e1e7e96..cafec2cd09 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -26,6 +26,8 @@ #include "geomPrimitive.h" #include "shaderExpansion.h" #include "reMutexHolder.h" +#include "geomContext.h" +#include "shaderContext.h" int PreparedGraphicsObjects::_name_index = 0; diff --git a/panda/src/gobj/shaderContext.cxx b/panda/src/gobj/shaderContext.cxx index a64d19e3cb..5a703df40a 100755 --- a/panda/src/gobj/shaderContext.cxx +++ b/panda/src/gobj/shaderContext.cxx @@ -16,6 +16,10 @@ // //////////////////////////////////////////////////////////////////// +#include "shaderContext.h" +#include "texture.h" +#include "string_utils.h" + TypeHandle ShaderContext::_type_handle; //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/shaderExpansion.cxx b/panda/src/gobj/shaderExpansion.cxx index c05c4c786e..99fa619851 100644 --- a/panda/src/gobj/shaderExpansion.cxx +++ b/panda/src/gobj/shaderExpansion.cxx @@ -18,6 +18,7 @@ #include "pandabase.h" #include "shaderExpansion.h" +#include "preparedGraphicsObjects.h" TypeHandle ShaderExpansion::_type_handle; ShaderExpansion::ExpansionCache ShaderExpansion::_expansion_cache; diff --git a/panda/src/gobj/shaderExpansion.h b/panda/src/gobj/shaderExpansion.h index 6b9474d123..264f68bd83 100644 --- a/panda/src/gobj/shaderExpansion.h +++ b/panda/src/gobj/shaderExpansion.h @@ -20,7 +20,7 @@ #define SHADEREXPANSION_H #include "pandabase.h" -#include "typedWritableReferenceCount.h" +#include "typedReferenceCount.h" #include "namable.h" #include "graphicsStateGuardianBase.h" #include "internalName.h" diff --git a/panda/src/gobj/sliderTable.cxx b/panda/src/gobj/sliderTable.cxx index e745460645..37a67bd2a5 100644 --- a/panda/src/gobj/sliderTable.cxx +++ b/panda/src/gobj/sliderTable.cxx @@ -19,6 +19,7 @@ #include "sliderTable.h" #include "bamReader.h" #include "bamWriter.h" +#include "vertexTransform.h" TypeHandle SliderTable::_type_handle; diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 843a75773b..bfe6d97060 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -19,6 +19,7 @@ #include "pandabase.h" #include "texture.h" #include "config_gobj.h" +#include "config_util.h" #include "texturePool.h" #include "textureContext.h" #include "datagram.h" diff --git a/panda/src/gobj/textureStage.cxx b/panda/src/gobj/textureStage.cxx index fa41b3ca01..a581618e77 100755 --- a/panda/src/gobj/textureStage.cxx +++ b/panda/src/gobj/textureStage.cxx @@ -18,6 +18,8 @@ #include "textureStage.h" #include "internalName.h" +#include "bamReader.h" +#include "bamWriter.h" PT(TextureStage) TextureStage::_default_stage; UpdateSeq TextureStage::_sort_seq; diff --git a/panda/src/gobj/transformBlendTable.h b/panda/src/gobj/transformBlendTable.h index 266d4bd007..b35ae8e469 100644 --- a/panda/src/gobj/transformBlendTable.h +++ b/panda/src/gobj/transformBlendTable.h @@ -32,6 +32,8 @@ #include "cycleDataWriter.h" #include "pipelineCycler.h" +class FactoryParams; + //////////////////////////////////////////////////////////////////// // Class : TransformBlendTable // Description : This structure collects together the different diff --git a/panda/src/gobj/transformTable.h b/panda/src/gobj/transformTable.h index ead3cd7088..210e437066 100644 --- a/panda/src/gobj/transformTable.h +++ b/panda/src/gobj/transformTable.h @@ -30,6 +30,7 @@ #include "cycleDataWriter.h" #include "pipelineCycler.h" +class FactoryParams; //////////////////////////////////////////////////////////////////// // Class : TransformTable diff --git a/panda/src/gobj/userVertexSlider.h b/panda/src/gobj/userVertexSlider.h index 4786336c0b..7f4c46a149 100644 --- a/panda/src/gobj/userVertexSlider.h +++ b/panda/src/gobj/userVertexSlider.h @@ -26,6 +26,8 @@ #include "cycleDataWriter.h" #include "pipelineCycler.h" +class FactoryParams; + //////////////////////////////////////////////////////////////////// // Class : UserVertexSlider // Description : This is a specialization on VertexSlider that diff --git a/panda/src/gobj/userVertexTransform.h b/panda/src/gobj/userVertexTransform.h index bbc94e9590..6c0f682f7e 100644 --- a/panda/src/gobj/userVertexTransform.h +++ b/panda/src/gobj/userVertexTransform.h @@ -26,6 +26,8 @@ #include "cycleDataWriter.h" #include "pipelineCycler.h" +class FactoryParams; + //////////////////////////////////////////////////////////////////// // Class : UserVertexTransform // Description : This is a specialization on VertexTransform that diff --git a/panda/src/gobj/vertexSlider.cxx b/panda/src/gobj/vertexSlider.cxx index 019aebe75a..0bb27a1a83 100644 --- a/panda/src/gobj/vertexSlider.cxx +++ b/panda/src/gobj/vertexSlider.cxx @@ -21,6 +21,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "indent.h" +#include "sliderTable.h" TypeHandle VertexSlider::_type_handle; diff --git a/panda/src/gobj/vertexTransform.cxx b/panda/src/gobj/vertexTransform.cxx index 3821be567e..f1b9a43422 100644 --- a/panda/src/gobj/vertexTransform.cxx +++ b/panda/src/gobj/vertexTransform.cxx @@ -20,6 +20,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "indent.h" +#include "transformTable.h" PipelineCycler VertexTransform::_global_cycler; UpdateSeq VertexTransform::_next_modified; diff --git a/panda/src/linmath/Sources.pp b/panda/src/linmath/Sources.pp index 3cfc96bf00..17ba31236a 100644 --- a/panda/src/linmath/Sources.pp +++ b/panda/src/linmath/Sources.pp @@ -40,9 +40,9 @@ #define INCLUDED_SOURCES \ compose_matrix.cxx config_linmath.cxx coordinateSystem.cxx \ lmatrix.cxx lmatrix3.cxx \ - lmatrix4.cxx lorientation.cxx lorientation lpoint2.cxx \ + lmatrix4.cxx lorientation.cxx lpoint2.cxx \ lpoint3.cxx lpoint4.cxx lquaternion.cxx lrotation.cxx \ - lrotation luse.cxx lvecBase2.cxx lvecBase3.cxx lvecBase4.cxx \ + luse.cxx lvecBase2.cxx lvecBase3.cxx lvecBase4.cxx \ lvector2.cxx lvector3.cxx lvector4.cxx mathNumbers.cxx \ vector_Colorf.cxx vector_LPoint2f.cxx \ vector_LVecBase3f.cxx vector_Normalf.cxx vector_Vertexf.cxx \ diff --git a/panda/src/linmath/compose_matrix_src.cxx b/panda/src/linmath/compose_matrix_src.cxx index 4d39853a97..8acf526b29 100644 --- a/panda/src/linmath/compose_matrix_src.cxx +++ b/panda/src/linmath/compose_matrix_src.cxx @@ -28,6 +28,7 @@ compose_matrix_old_hpr(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVecBase3) &shear, const FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) { + TAU_PROFILE("void compose_matrix_old_hpr(LMatrix3 &, const LVecBase3 &, const LVecBase3 &, const LVecBase3 &)", " ", TAU_USER); mat = FLOATNAME(LMatrix3)::scale_shear_mat(scale, shear, cs) * FLOATNAME(LMatrix3)::rotate_mat_normaxis(hpr[1], FLOATNAME(LVector3)::right(cs), cs) * @@ -46,6 +47,7 @@ compose_matrix_old_hpr(FLOATNAME(LMatrix3) &mat, //////////////////////////////////////////////////////////////////// static void unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { + TAU_PROFILE("void unwind_yup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); typedef FLOATNAME(LMatrix3) Matrix; @@ -126,6 +128,7 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) //////////////////////////////////////////////////////////////////// static void unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { + TAU_PROFILE("void unwind_zup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); typedef FLOATNAME(LMatrix3) Matrix; // Extract the axes from the matrix. @@ -217,6 +220,7 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &shear, FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) { + TAU_PROFILE("bool decompose_matrix_old_hpr(LMatrix3 &, LVecBase3 &, LVecBase3 &, LVecBase3 &)", " ", TAU_USER); if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -323,6 +327,7 @@ compose_matrix_new_hpr(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVecBase3) &shear, const FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) { + TAU_PROFILE("void compose_matrix_new_hpr(LMatrix3 &, const LVecBase3 &, const LVecBase3 &, const LVecBase3 &)", " ", TAU_USER); mat = FLOATNAME(LMatrix3)::scale_shear_mat(scale, shear, cs) * FLOATNAME(LMatrix3)::rotate_mat_normaxis(hpr[2], FLOATNAME(LVector3)::forward(cs), cs) * @@ -341,6 +346,7 @@ compose_matrix_new_hpr(FLOATNAME(LMatrix3) &mat, //////////////////////////////////////////////////////////////////// static void unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { + TAU_PROFILE("void unwind_yup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); typedef FLOATNAME(LMatrix3) Matrix; @@ -421,6 +427,7 @@ unwind_yup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) //////////////////////////////////////////////////////////////////// static void unwind_zup_rotation_new_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { + TAU_PROFILE("void unwind_zup_rotation_new_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); typedef FLOATNAME(LMatrix3) Matrix; // Extract the axes from the matrix. @@ -503,6 +510,7 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &shear, FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) { + TAU_PROFILE("bool decompose_matrix_new_hpr(LMatrix3 &, LVecBase3 &, LVecBase3 &, LVecBase3 &)", " ", TAU_USER); if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -610,6 +618,7 @@ decompose_matrix_new_hpr(const FLOATNAME(LMatrix3) &mat, //////////////////////////////////////////////////////////////////// FLOATNAME(LVecBase3) old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr) { + TAU_PROFILE("LVecBase3 old_to_new_hpr(const LVecBase3 &)", " ", TAU_USER); FLOATNAME(LMatrix3) mat; compose_matrix_old_hpr(mat, FLOATNAME(LVecBase3)(1.0f, 1.0f, 1.0f), @@ -636,6 +645,7 @@ old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr) { //////////////////////////////////////////////////////////////////// FLOATNAME(LVecBase3) new_to_old_hpr(const FLOATNAME(LVecBase3) &new_hpr) { + TAU_PROFILE("LVecBase3 new_to_old_hpr(const LVecBase3 &)", " ", TAU_USER); FLOATNAME(LMatrix3) mat; compose_matrix_new_hpr(mat, FLOATNAME(LVecBase3)(1.0f, 1.0f, 1.0f), diff --git a/panda/src/linmath/lmatrix3_src.I b/panda/src/linmath/lmatrix3_src.I index fd15ea0fe5..71d81eb4d5 100644 --- a/panda/src/linmath/lmatrix3_src.I +++ b/panda/src/linmath/lmatrix3_src.I @@ -45,8 +45,9 @@ FLOATNAME(LMatrix3)() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3):: FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) ©) { - memcpy(_m.data,copy._m.data,sizeof(_m.data)); -// (*this) = copy; + TAU_PROFILE("LMatrix3::LMatrix3(const LMatrix3 &)", " ", TAU_USER); + + memcpy(_m.data,copy._m.data,sizeof(_m.data)); } //////////////////////////////////////////////////////////////////// @@ -56,10 +57,9 @@ FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) ©) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator = (const FLOATNAME(LMatrix3) ©) { + TAU_PROFILE("void LMatrix3::operator = (const LMatrix3 &)", " ", TAU_USER); + memcpy(_m.data,copy._m.data,sizeof(_m.data)); -// set(copy(0, 0), copy(0, 1), copy(0, 2), -// copy(1, 0), copy(1, 1), copy(1, 2), -// copy(2, 0), copy(2, 1), copy(2, 2)); return *this; } @@ -83,6 +83,7 @@ INLINE_LINMATH FLOATNAME(LMatrix3):: FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) { + TAU_PROFILE("LMatrix3::LMatrix3(FLOATTYPE, ...)", " ", TAU_USER); _m.m._00 = e00; _m.m._01 = e01; _m.m._02 = e02; @@ -92,10 +93,6 @@ FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, _m.m._20 = e20; _m.m._21 = e21; _m.m._22 = e22; - -// set(e00, e01, e02, -// e10, e11, e12, -// e20, e21, e22); } //////////////////////////////////////////////////////////////////// @@ -107,6 +104,7 @@ INLINE_LINMATH void FLOATNAME(LMatrix3):: set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22) { + TAU_PROFILE("void LMatrix3::set(FLOATTYPE, ...)", " ", TAU_USER); _m.m._00 = e00; _m.m._01 = e01; _m.m._02 = e02; @@ -116,17 +114,6 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, _m.m._20 = e20; _m.m._21 = e21; _m.m._22 = e22; - /* - _m.m._00 = e00; - _m.m._01 = e01; - _m.m._02 = e02; - _m.m._10 = e10; - _m.m._11 = e11; - _m.m._12 = e12; - _m.m._20 = e20; - _m.m._21 = e21; - _m.m._22 = e22; - */ } //////////////////////////////////////////////////////////////////// @@ -260,6 +247,7 @@ operator () (int row, int col) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LMatrix3):: is_nan() const { + TAU_PROFILE("bool LMatrix3::is_nan()", " ", TAU_USER); return cnan(_m.data[0]) || cnan(_m.data[1]) || cnan(_m.data[2]) || cnan(_m.data[3]) || cnan(_m.data[4]) || cnan(_m.data[5]) || @@ -436,6 +424,7 @@ add_hash(size_t hash) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LMatrix3):: add_hash(size_t hash, FLOATTYPE threshold) const { + TAU_PROFILE("size_t LMatrix3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); float_hash fhasher(threshold); hash = fhasher.add_hash(hash, _m.m._00); @@ -458,9 +447,6 @@ v_res._v.v._0 = v._v.v._0*mat._m.m._00 + v._v.v._1*mat._m.m._10 + v._v.v._2*mat. v_res._v.v._1 = v._v.v._0*mat._m.m._01 + v._v.v._1*mat._m.m._11 + v._v.v._2*mat._m.m._21; \ v_res._v.v._2 = v._v.v._0*mat._m.m._02 + v._v.v._1*mat._m.m._12 + v._v.v._2*mat._m.m._22; -// bugbug: need 2 check if this is correct, or reversed from previous implementation -// before checkin - //////////////////////////////////////////////////////////////////// // Function: LMatrix3::xform // Access: Public @@ -469,19 +455,11 @@ v_res._v.v._2 = v._v.v._0*mat._m.m._02 + v._v.v._1*mat._m.m._12 + v._v.v._2*mat. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: xform(const FLOATNAME(LVecBase3) &v) const { - FLOATNAME(LVecBase3) v_res; - - - - VECTOR3_MATRIX3_PRODUCT(v_res, v,(*this)); - - - - return v_res; - -// return FLOATNAME(LVecBase3)(v.dot(get_col(0)), -// v.dot(get_col(1)), -// v.dot(get_col(2))); + TAU_PROFILE("LVecBase3 LMatrix3::xform(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LVecBase3) v_res; + VECTOR3_MATRIX3_PRODUCT(v_res, v,(*this)); + + return v_res; } //////////////////////////////////////////////////////////////////// @@ -493,18 +471,15 @@ xform(const FLOATNAME(LVecBase3) &v) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LMatrix3):: xform_point(const FLOATNAME(LVecBase2) &v) const { + TAU_PROFILE("LVecBase3 LMatrix3::xform_point(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LVecBase2) v_res; - FLOATNAME(LVecBase2) v_res; - - // v._v.v._2 == 1.0f for this case - - v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + _m.m._20; - v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + _m.m._21; - - return v_res; - -// return FLOATNAME(LVecBase2)(v.dot(get_col2(0)) + _m.m._20, -// v.dot(get_col2(1)) + _m.m._21); + // v._v.v._2 == 1.0f for this case + + v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + _m.m._20; + v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + _m.m._21; + + return v_res; } //////////////////////////////////////////////////////////////////// @@ -516,16 +491,17 @@ xform_point(const FLOATNAME(LVecBase2) &v) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LMatrix3):: xform_vec(const FLOATNAME(LVecBase2) &v) const { + TAU_PROFILE("LVecBase3 LMatrix3::xform_vec(const LVecBase3 &)", " ", TAU_USER); - FLOATNAME(LVecBase2) v_res; - - // v._v.v._2 == 0.0f for this case - - v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10; - v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11; - - return v_res; + FLOATNAME(LVecBase2) v_res; + // v._v.v._2 == 0.0f for this case + + v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10; + v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11; + + return v_res; + // return FLOATNAME(LVecBase2)(v.dot(get_col2(0)), // v.dot(get_col2(1))); } @@ -538,7 +514,7 @@ xform_vec(const FLOATNAME(LVecBase2) &v) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3):: mult_cel(const FLOATNAME(LMatrix3) &other, int row, int col) const { - return get_row(row).dot(other.get_col(col)); + return get_row(row).dot(other.get_col(col)); } @@ -561,49 +537,19 @@ res._m.m._22 = a._m.m._20*b._m.m._02 + a._m.m._21*b._m.m._12 + a._m.m._22*b._m.m //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: operator * (const FLOATNAME(LMatrix3) &other) const { - FLOATNAME(LMatrix3) t; + TAU_PROFILE("LMatrix3 LMatrix3::operator *(const LMatrix3 &)", " ", TAU_USER); + FLOATNAME(LMatrix3) t; - MATRIX3_PRODUCT(t,(*this),other); -/* -typedef union { - struct { - FLOATTYPE _m.m._11, _m.m._12, _m.m._13; - FLOATTYPE _m.m._21, _m.m._22, _m.m._23; - FLOATTYPE _m.m._31, _m.m._32, _m.m._33; - }; - - FLOATTYPE m[3][3]; - } MYMATRIX3; - - FLOATNAME(LMatrix3) t; - - MYMATRIX3 *result_ptr=(MYMATRIX3 *)t.get_m.data(); - MYMATRIX3 *mat1_ptr=(MYMATRIX3 *)this->get_m.data(); - MYMATRIX3 *mat2_ptr=(MYMATRIX3 *)other.get_m.data(); - - MATRIX3_PRODUCT(result_ptr,mat1_ptr,mat2_ptr); -*/ -/* - t(0, 0) = mult_cel(other, 0, 0); - t(0, 1) = mult_cel(other, 0, 1); - t(0, 2) = mult_cel(other, 0, 2); - - t(1, 0) = mult_cel(other, 1, 0); - t(1, 1) = mult_cel(other, 1, 1); - t(1, 2) = mult_cel(other, 1, 2); - - t(2, 0) = mult_cel(other, 2, 0); - t(2, 1) = mult_cel(other, 2, 1); - t(2, 2) = mult_cel(other, 2, 2); -*/ + MATRIX3_PRODUCT(t,(*this),other); return t; } // this = other1 * other2 INLINE_LINMATH void FLOATNAME(LMatrix3):: multiply(const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2) { -// faster than operator * since it writes result in place, avoiding extra copying -// this will fail if you try to mat.multiply(mat,other_mat) + TAU_PROFILE("LMatrix3 multiply(const LMatrix3 &, const LMatrix3 &)", " ", TAU_USER); + // faster than operator * since it writes result in place, avoiding extra copying + // this will fail if you try to mat.multiply(mat,other_mat) nassertv((&other1 != this) && (&other2 != this)); @@ -617,6 +563,7 @@ multiply(const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: operator * (FLOATTYPE scalar) const { + TAU_PROFILE("LMatrix3 operator *(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER); FLOATNAME(LMatrix3) t; t._m.m._00 = _m.m._00 * scalar; @@ -652,6 +599,7 @@ operator / (FLOATTYPE scalar) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator += (const FLOATNAME(LMatrix3) &other) { + TAU_PROFILE("LMatrix3 LMatrix3::operator +=(const LMatrix3 &)", " ", TAU_USER); _m.m._00 += other._m.m._00; _m.m._01 += other._m.m._01; _m.m._02 += other._m.m._02; @@ -674,6 +622,7 @@ operator += (const FLOATNAME(LMatrix3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator -= (const FLOATNAME(LMatrix3) &other) { + TAU_PROFILE("LMatrix3 LMatrix3::operator -=(const LMatrix3 &)", " ", TAU_USER); _m.m._00 -= other._m.m._00; _m.m._01 -= other._m.m._01; _m.m._02 -= other._m.m._02; @@ -696,6 +645,7 @@ operator -= (const FLOATNAME(LMatrix3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator *= (const FLOATNAME(LMatrix3) &other) { + TAU_PROFILE("LMatrix3 LMatrix3::operator *=(const LMatrix3 &)", " ", TAU_USER); (*this) = (*this) * other; // bugbug can we do any optimization here? @@ -709,6 +659,7 @@ operator *= (const FLOATNAME(LMatrix3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator *= (FLOATTYPE scalar) { + TAU_PROFILE("LMatrix3 LMatrix3::operator *=(FLOATTYPE)", " ", TAU_USER); _m.m._00 *= scalar; _m.m._01 *= scalar; _m.m._02 *= scalar; @@ -731,6 +682,7 @@ operator *= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator /= (FLOATTYPE scalar) { + TAU_PROFILE("LMatrix3 LMatrix3::operator /=(FLOATTYPE)", " ", TAU_USER); FLOATTYPE recip_scalar = 1.0f/scalar; _m.m._00 *= recip_scalar; _m.m._01 *= recip_scalar; @@ -754,6 +706,7 @@ operator /= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LMatrix3):: transpose_from(const FLOATNAME(LMatrix3) &other) { + TAU_PROFILE("LMatrix3 LMatrix3::transpose_from(const LMatrix3 &other)", " ", TAU_USER); _m.m._00 = other._m.m._00; _m.m._01 = other._m.m._10; _m.m._02 = other._m.m._20; @@ -775,8 +728,7 @@ transpose_from(const FLOATNAME(LMatrix3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LMatrix3):: transpose_in_place() { -// FLOATNAME(LMatrix3) temp = (*this); -// transpose_from(temp); + TAU_PROFILE("void LMatrix3::transpose_in_place()", " ", TAU_USER); #define SWAP__(x,y) { FLOATTYPE temp = (x); (x) = (y); (y) = temp;} SWAP__(_m.m._01,_m.m._10); @@ -802,8 +754,8 @@ transpose_in_place() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3):: det2(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e10, FLOATTYPE e11) const { -// return (e00 * e11 - e10 * e01); - return DET2(e00,e01,e10,e11); + TAU_PROFILE("FLOATTYPE LMatrix3::det2()", " ", TAU_USER); + return DET2(e00,e01,e10,e11); } //////////////////////////////////////////////////////////////////// @@ -813,12 +765,7 @@ det2(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e10, FLOATTYPE e11) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3):: determinant() const { -/* - return - (*this)(0,0) * det2((*this)(1,1),(*this)(1,2),(*this)(2,1),(*this)(2,2)) - -(*this)(0,1) * det2((*this)(1,0),(*this)(1,2),(*this)(2,0),(*this)(2,2)) - +(*this)(0,2) * det2((*this)(1,0),(*this)(1,1),(*this)(2,0),(*this)(2,1)); -*/ + TAU_PROFILE("FLOATTYPE LMatrix3::determinant()", " ", TAU_USER); return MATRIX3_DETERMINANT(_m.m); } @@ -841,6 +788,7 @@ determinant() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LMatrix3):: invert_from(const FLOATNAME(LMatrix3) &other) { + TAU_PROFILE("bool LMatrix3::invert_from(const LMatrix3 &)", " ", TAU_USER); FLOATTYPE other_det = MATRIX3_DETERMINANT(other._m.m); @@ -881,6 +829,7 @@ invert_from(const FLOATNAME(LMatrix3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LMatrix3):: invert_in_place() { + TAU_PROFILE("bool LMatrix3::invert_in_place()", " ", TAU_USER); FLOATNAME(LMatrix3) temp = (*this); return invert_from(temp); } @@ -919,6 +868,7 @@ translate_mat(FLOATTYPE tx, FLOATTYPE ty) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: rotate_mat(FLOATTYPE angle) { + TAU_PROFILE("LMatrix3 LMatrix3::rotate_mat(FLOATTYPE)", " ", TAU_USER); FLOATTYPE angle_rad=deg_2_rad(angle); FLOATTYPE s,c; csincos(angle_rad,&s,&c); @@ -962,6 +912,7 @@ scale_mat(FLOATTYPE sx, FLOATTYPE sy) { INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis, CoordinateSystem cs) { + TAU_PROFILE("LMatrix3 LMatrix3::rotate_mat(FLOATTYPE, LVecBase3, CoordinateSystem)", " ", TAU_USER); if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -1039,6 +990,7 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis, INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { + TAU_PROFILE("LMatrix3 LMatrix3::rotate_mat_normaxis(FLOATTYPE, LVecBase3, CoordinateSystem)", " ", TAU_USER); if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -1201,6 +1153,7 @@ transpose(const FLOATNAME(LMatrix3) &a) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) invert(const FLOATNAME(LMatrix3) &a) { + TAU_PROFILE("LMatrix3 invert(const LMatrix3 &)", " ", TAU_USER); FLOATNAME(LMatrix3) result; bool nonsingular = result.invert_from(a); #ifndef NDEBUG diff --git a/panda/src/linmath/lmatrix3_src.cxx b/panda/src/linmath/lmatrix3_src.cxx index 3b96af33b5..d84c927b42 100644 --- a/panda/src/linmath/lmatrix3_src.cxx +++ b/panda/src/linmath/lmatrix3_src.cxx @@ -60,6 +60,7 @@ FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_shear_mat(const FLOATNAME(LVecBase3) &scale, const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { + TAU_PROFILE("LMatrix3 LMatrix3::scale_shear_mat(const LVecBase3 &, const LVecBase3 &)", " ", TAU_USER); if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -133,6 +134,7 @@ scale_shear_mat(const FLOATNAME(LVecBase3) &scale, //////////////////////////////////////////////////////////////////// const FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: convert_mat(CoordinateSystem from, CoordinateSystem to) { + TAU_PROFILE("LMatrix3 LMatrix3::convert_mat(CoordinateSystem, CoordinateSystem)", " ", TAU_USER); if (from == CS_default) { from = get_default_coordinate_system(); } @@ -198,6 +200,7 @@ convert_mat(CoordinateSystem from, CoordinateSystem to) { //////////////////////////////////////////////////////////////////// void FLOATNAME(LMatrix3):: fill(FLOATTYPE fill_value) { + TAU_PROFILE("void LMatrix3::fill(FLOATTYPE)", " ", TAU_USER); set(fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value); @@ -214,6 +217,7 @@ fill(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// int FLOATNAME(LMatrix3):: compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { + TAU_PROFILE("int LMatrix3::compare_to(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER); for (int i = 0; i < 9; i++) { if (!IS_THRESHOLD_COMPEQ(_m.data[i], other._m.data[i], threshold)) { return (_m.data[i] < other._m.data[i]) ? -1 : 1; @@ -230,6 +234,7 @@ compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// bool FLOATNAME(LMatrix3):: almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { + TAU_PROFILE("bool LMatrix3::almost_equal(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER); return (IS_THRESHOLD_EQUAL((*this)(0, 0), other(0, 0), threshold) && IS_THRESHOLD_EQUAL((*this)(0, 1), other(0, 1), threshold) && IS_THRESHOLD_EQUAL((*this)(0, 2), other(0, 2), threshold) && @@ -318,6 +323,7 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// void FLOATNAME(LMatrix3):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { + TAU_PROFILE("void LMatrix3::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { hashgen.add_fp(get_cell(i,j), threshold); diff --git a/panda/src/linmath/lmatrix3_src.h b/panda/src/linmath/lmatrix3_src.h index 9d060501be..6b41676bf5 100644 --- a/panda/src/linmath/lmatrix3_src.h +++ b/panda/src/linmath/lmatrix3_src.h @@ -38,6 +38,7 @@ PUBLISHED: FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22); + ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix3)); void fill(FLOATTYPE fill_value); INLINE_LINMATH void set( diff --git a/panda/src/linmath/lmatrix4_src.I b/panda/src/linmath/lmatrix4_src.I index 18fb32f716..219758232e 100644 --- a/panda/src/linmath/lmatrix4_src.I +++ b/panda/src/linmath/lmatrix4_src.I @@ -45,8 +45,9 @@ FLOATNAME(LMatrix4)() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix4) ©) { + TAU_PROFILE("LMatrix4::LMatrix4(const LMatrix4 &)", " ", TAU_USER); + memcpy(_m.data,copy._m.data,sizeof(_m.data)); -// (*this) = copy; } //////////////////////////////////////////////////////////////////// @@ -56,14 +57,10 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix4) ©) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator = (const FLOATNAME(LMatrix4) ©) { - //xxx888 + TAU_PROFILE("void LMatrix4::operator = (const LMatrix4 &)", " ", TAU_USER); + memcpy(_m.data,copy._m.data,sizeof(_m.data)); -// set(copy(0, 0), copy(0, 1), copy(0, 2), copy(0, 3), -// copy(1, 0), copy(1, 1), copy(1, 2), copy(1, 3), -// copy(2, 0), copy(2, 1), copy(2, 2), copy(2, 3), -// copy(3, 0), copy(3, 1), copy(3, 2), copy(3, 3)); return *this; - //xxx000 } //////////////////////////////////////////////////////////////////// @@ -87,6 +84,7 @@ FLOATNAME(LMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23, FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33) { + TAU_PROFILE("LMatrix4::LMatrix4(FLOATTYPE, ...)", " ", TAU_USER); _m.m._00 = e00; _m.m._01 = e01; @@ -116,6 +114,7 @@ FLOATNAME(LMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3) { + TAU_PROFILE("void LMatrix4::LMatrix4(const LMatrix3 &)", " ", TAU_USER); _m.m._00 = upper3._m.m._00; _m.m._01 = upper3._m.m._01; @@ -136,11 +135,6 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3) { _m.m._31 = 0.0f; _m.m._32 = 0.0f; _m.m._33 = 1.0f; - -// set(upper3(0, 0), upper3(0, 1), upper3(0, 2), 0.0f, -// upper3(1, 0), upper3(1, 1), upper3(1, 2), 0.0f, -// upper3(2, 0), upper3(2, 1), upper3(2, 2), 0.0f, -// 0.0f, 0.0f, 0.0f, 1.0f); } //////////////////////////////////////////////////////////////////// @@ -151,6 +145,7 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3) { INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3, const FLOATNAME(LVecBase3) &trans) { + TAU_PROFILE("void LMatrix4::LMatrix4(upper3, const LVecBase3 &)", " ", TAU_USER); _m.m._00 = upper3._m.m._00; _m.m._01 = upper3._m.m._01; @@ -171,11 +166,6 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3, _m.m._31 = trans._v.v._1; _m.m._32 = trans._v.v._2; _m.m._33 = 1.0f; - -// set(upper3(0, 0), upper3(0, 1), upper3(0, 2), 0.0f, -// upper3(1, 0), upper3(1, 1), upper3(1, 2), 0.0f, -// upper3(2, 0), upper3(2, 1), upper3(2, 2), 0.0f, -// trans[0], trans[1], trans[2], 1.0f); } //////////////////////////////////////////////////////////////////// @@ -187,6 +177,7 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3, //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LMatrix4):: fill(FLOATTYPE fill_value) { + TAU_PROFILE("void LMatrix4::fill(FLOATTYPE)", " ", TAU_USER); set(fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, fill_value, @@ -203,6 +194,7 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23, FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33) { + TAU_PROFILE("void LMatrix4::set(FLOATTYPE, ...)", " ", TAU_USER); _m.m._00 = e00; _m.m._01 = e01; @@ -232,6 +224,7 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LMatrix4):: set_upper_3(const FLOATNAME(LMatrix3) &upper3) { + TAU_PROFILE("void LMatrix4::set_upper_3(const LMatrix3 &)", " ", TAU_USER); _m.m._00 = upper3(0, 0); _m.m._01 = upper3(0, 1); _m.m._02 = upper3(0, 2); @@ -252,6 +245,7 @@ set_upper_3(const FLOATNAME(LMatrix3) &upper3) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix4):: get_upper_3() const { + TAU_PROFILE("LMatrix3 LMatrix4::get_upper_3()", " ", TAU_USER); return FLOATNAME(LMatrix3) (_m.m._00, _m.m._01, _m.m._02, _m.m._10, _m.m._11, _m.m._12, @@ -411,6 +405,7 @@ operator () (int row, int col) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LMatrix4):: is_nan() const { + TAU_PROFILE("bool LMatrix4::is_nan()", " ", TAU_USER); return cnan(_m.data[0]) || cnan(_m.data[1]) || cnan(_m.data[2]) || cnan(_m.data[3]) || cnan(_m.data[4]) || cnan(_m.data[5]) || cnan(_m.data[6]) || cnan(_m.data[7]) || @@ -588,6 +583,7 @@ add_hash(size_t hash) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LMatrix4):: add_hash(size_t hash, FLOATTYPE threshold) const { + TAU_PROFILE("size_t LMatrix4::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); float_hash fhasher(threshold); hash = fhasher.add_hash(hash, _m.m._00); @@ -627,16 +623,11 @@ v_res._v.v._3 = v._v.v._0*mat._m.m._03 + v._v.v._1*mat._m.m._13 + v._v.v._2*mat. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LMatrix4):: xform(const FLOATNAME(LVecBase4) &v) const { - FLOATNAME(LVecBase4) v_res; - - VECTOR4_MATRIX4_PRODUCT(v_res, v,(*this)); - return v_res; - -/* return FLOATNAME(LVecBase4)(v.dot(get_col(0)), - v.dot(get_col(1)), - v.dot(get_col(2)), - v.dot(get_col(3))); -*/ + TAU_PROFILE("LVecBase3 LMatrix4::xform(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LVecBase4) v_res; + + VECTOR4_MATRIX4_PRODUCT(v_res, v,(*this)); + return v_res; } //////////////////////////////////////////////////////////////////// @@ -648,22 +639,16 @@ xform(const FLOATNAME(LVecBase4) &v) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_point(const FLOATNAME(LVecBase3) &v) const { + TAU_PROFILE("LVecBase3 LMatrix4::xform_point(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LVecBase3) v_res; - FLOATNAME(LVecBase3) v_res; - - // v._v.v._3 == 1.0f for this case - - v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + v._v.v._2*_m.m._20 + _m.m._30; - v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + v._v.v._2*_m.m._21 + _m.m._31; - v_res._v.v._2 = v._v.v._0*_m.m._02 + v._v.v._1*_m.m._12 + v._v.v._2*_m.m._22 + _m.m._32; - - return v_res; - -/* - return FLOATNAME(LVecBase3)(v.dot(get_col3(0)) + _m.m._30, - v.dot(get_col3(1)) + _m.m._31, - v.dot(get_col3(2)) + _m.m._32); -*/ + // v._v.v._3 == 1.0f for this case + + v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + v._v.v._2*_m.m._20 + _m.m._30; + v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + v._v.v._2*_m.m._21 + _m.m._31; + v_res._v.v._2 = v._v.v._0*_m.m._02 + v._v.v._1*_m.m._12 + v._v.v._2*_m.m._22 + _m.m._32; + + return v_res; } //////////////////////////////////////////////////////////////////// @@ -675,20 +660,16 @@ xform_point(const FLOATNAME(LVecBase3) &v) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_vec(const FLOATNAME(LVecBase3) &v) const { - FLOATNAME(LVecBase3) v_res; - - // v._v.v._3 == 0.0f for this case - - v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + v._v.v._2*_m.m._20; - v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + v._v.v._2*_m.m._21; - v_res._v.v._2 = v._v.v._0*_m.m._02 + v._v.v._1*_m.m._12 + v._v.v._2*_m.m._22; - - return v_res; -/* - return FLOATNAME(LVecBase3)(v.dot(get_col3(0)), - v.dot(get_col3(1)), - v.dot(get_col3(2))); -*/ + TAU_PROFILE("LVecBase3 LMatrix4::xform_vec(const LVecBase3 &)", " ", TAU_USER); + FLOATNAME(LVecBase3) v_res; + + // v._v.v._3 == 0.0f for this case + + v_res._v.v._0 = v._v.v._0*_m.m._00 + v._v.v._1*_m.m._10 + v._v.v._2*_m.m._20; + v_res._v.v._1 = v._v.v._0*_m.m._01 + v._v.v._1*_m.m._11 + v._v.v._2*_m.m._21; + v_res._v.v._2 = v._v.v._0*_m.m._02 + v._v.v._1*_m.m._12 + v._v.v._2*_m.m._22; + + return v_res; } //////////////////////////////////////////////////////////////////// @@ -730,60 +711,18 @@ res._m.m._33 = a._m.m._30*b._m.m._03 + a._m.m._31*b._m.m._13 + a._m.m._32*b._m.m //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: operator * (const FLOATNAME(LMatrix4) &other) const { - FLOATNAME(LMatrix4) t; - - MATRIX4_PRODUCT(t,(*this),other); -/* -typedef union { - struct { - FLOATTYPE _m.m._11, _m.m._12, _m.m._13, _m.m._14; - FLOATTYPE _m.m._21, _m.m._22, _m.m._23, _m.m._24; - FLOATTYPE _m.m._31, _m.m._32, _m.m._33, _m.m._34; - FLOATTYPE _m.m._41, _m.m._42, _m.m._43, _m.m._44; - }; - - FLOATTYPE m[4][4]; - } MYMATRIX4; - - FLOATNAME(LMatrix4) t; - - MYMATRIX4 *result_ptr=(MYMATRIX4 *)t.get_m.data(); - MYMATRIX4 *mat1_ptr=(MYMATRIX4 *)this->get_m.data(); - MYMATRIX4 *mat2_ptr=(MYMATRIX4 *)other.get_m.data(); - - MATRIX4_PRODUCT(result_ptr,mat1_ptr,mat2_ptr); -*/ - -/* - - t(0, 0) = mult_cel(other, 0, 0); - t(0, 1) = mult_cel(other, 0, 1); - t(0, 2) = mult_cel(other, 0, 2); - t(0, 3) = mult_cel(other, 0, 3); - - t(1, 0) = mult_cel(other, 1, 0); - t(1, 1) = mult_cel(other, 1, 1); - t(1, 2) = mult_cel(other, 1, 2); - t(1, 3) = mult_cel(other, 1, 3); - - t(2, 0) = mult_cel(other, 2, 0); - t(2, 1) = mult_cel(other, 2, 1); - t(2, 2) = mult_cel(other, 2, 2); - t(2, 3) = mult_cel(other, 2, 3); - - t(3, 0) = mult_cel(other, 3, 0); - t(3, 1) = mult_cel(other, 3, 1); - t(3, 2) = mult_cel(other, 3, 2); - t(3, 3) = mult_cel(other, 3, 3); -*/ + TAU_PROFILE("LMatrix4 LMatrix4::operator *(const LMatrix4 &)", " ", TAU_USER); + FLOATNAME(LMatrix4) t; + MATRIX4_PRODUCT(t,(*this),other); return t; } // this = other1 * other2 INLINE_LINMATH void FLOATNAME(LMatrix4):: multiply(const FLOATNAME(LMatrix4) &other1, const FLOATNAME(LMatrix4) &other2) { -// faster than operator * since it writes result in place, avoiding extra copying -// this will fail if you try to mat.multiply(mat,other_mat) + TAU_PROFILE("LMatrix4 multiply(const LMatrix4 &, const LMatrix4 &)", " ", TAU_USER); + // faster than operator * since it writes result in place, avoiding extra copying + // this will fail if you try to mat.multiply(mat,other_mat) nassertv((&other1 != this) && (&other2 != this)); MATRIX4_PRODUCT((*this),other1,other2); @@ -796,6 +735,7 @@ multiply(const FLOATNAME(LMatrix4) &other1, const FLOATNAME(LMatrix4) &other2) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: operator * (FLOATTYPE scalar) const { + TAU_PROFILE("LMatrix4 operator *(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER); FLOATNAME(LMatrix4) t; t._m.m._00 = _m.m._00 * scalar; @@ -828,30 +768,8 @@ operator * (FLOATTYPE scalar) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: operator / (FLOATTYPE scalar) const { - FLOATNAME(LMatrix4) t; FLOATTYPE recip_scalar = 1.0f/scalar; - - t._m.m._00 = _m.m._00 * recip_scalar; - t._m.m._01 = _m.m._01 * recip_scalar; - t._m.m._02 = _m.m._02 * recip_scalar; - t._m.m._03 = _m.m._03 * recip_scalar; - - t._m.m._10 = _m.m._10 * recip_scalar; - t._m.m._11 = _m.m._11 * recip_scalar; - t._m.m._12 = _m.m._12 * recip_scalar; - t._m.m._13 = _m.m._13 * recip_scalar; - - t._m.m._20 = _m.m._20 * recip_scalar; - t._m.m._21 = _m.m._21 * recip_scalar; - t._m.m._22 = _m.m._22 * recip_scalar; - t._m.m._23 = _m.m._23 * recip_scalar; - - t._m.m._30 = _m.m._30 * recip_scalar; - t._m.m._31 = _m.m._31 * recip_scalar; - t._m.m._32 = _m.m._32 * recip_scalar; - t._m.m._33 = _m.m._33 * recip_scalar; - - return t; + return (*this) * recip_scalar; } //////////////////////////////////////////////////////////////////// @@ -861,6 +779,7 @@ operator / (FLOATTYPE scalar) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator += (const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("LMatrix4 LMatrix4::operator +=(const LMatrix4 &)", " ", TAU_USER); _m.m._00 += other._m.m._00; _m.m._01 += other._m.m._01; _m.m._02 += other._m.m._02; @@ -891,6 +810,7 @@ operator += (const FLOATNAME(LMatrix4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator -= (const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("LMatrix4 LMatrix4::operator -=(const LMatrix4 &)", " ", TAU_USER); _m.m._00 -= other._m.m._00; _m.m._01 -= other._m.m._01; _m.m._02 -= other._m.m._02; @@ -921,6 +841,7 @@ operator -= (const FLOATNAME(LMatrix4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator *= (const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("LMatrix4 LMatrix4::operator *=(const LMatrix4 &)", " ", TAU_USER); (*this) = (*this) * other; return *this; } @@ -932,6 +853,7 @@ operator *= (const FLOATNAME(LMatrix4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator *= (FLOATTYPE scalar) { + TAU_PROFILE("LMatrix4 LMatrix4::operator *=(FLOATTYPE)", " ", TAU_USER); _m.m._00 *= scalar; _m.m._01 *= scalar; _m.m._02 *= scalar; @@ -962,6 +884,7 @@ operator *= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator /= (FLOATTYPE scalar) { + TAU_PROFILE("LMatrix4 LMatrix4::operator /=(FLOATTYPE)", " ", TAU_USER); FLOATTYPE recip_scalar = 1.0f/scalar; _m.m._00 *= recip_scalar; _m.m._01 *= recip_scalar; @@ -994,6 +917,7 @@ operator /= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LMatrix4):: transpose_from(const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("LMatrix4 LMatrix4::transpose_from(const LMatrix4 &other)", " ", TAU_USER); _m.m._00 = other._m.m._00; _m.m._01 = other._m.m._10; _m.m._02 = other._m.m._20; @@ -1022,8 +946,7 @@ transpose_from(const FLOATNAME(LMatrix4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LMatrix4):: transpose_in_place() { -// FLOATNAME(LMatrix4) temp = (*this); -// transpose_from(temp); + TAU_PROFILE("void LMatrix4::transpose_in_place()", " ", TAU_USER); #define SWAP__(x,y) { FLOATTYPE temp = (x); (x) = (y); (y) = temp;} SWAP__(_m.m._01,_m.m._10); @@ -1053,6 +976,7 @@ transpose_in_place() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LMatrix4):: invert_from(const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("bool LMatrix4::invert_from(const LMatrix4 &)", " ", TAU_USER); if (IS_NEARLY_EQUAL(other._m.m._03, 0.0f) && IS_NEARLY_EQUAL(other._m.m._13, 0.0f) && IS_NEARLY_EQUAL(other._m.m._23, 0.0f) && @@ -1103,6 +1027,7 @@ invert_from(const FLOATNAME(LMatrix4) &other) { // (transpose upper 3x3 and take negative of translation component) INLINE_LINMATH bool FLOATNAME(LMatrix4):: invert_affine_from(const FLOATNAME(LMatrix4) &other) { + TAU_PROFILE("bool LMatrix4::invert_affine_from(const LMatrix4 &)", " ", TAU_USER); FLOATNAME(LMatrix3) rot; // probably could use transpose here @@ -1111,33 +1036,22 @@ invert_affine_from(const FLOATNAME(LMatrix4) &other) { } set_upper_3(rot); -// set_col(3, FLOATNAME(LVecBase4)(0.0f, 0.0f, 0.0f, 1.0f)); _m.m._03 = 0.0f; _m.m._13 = 0.0f; _m.m._23 = 0.0f; _m.m._33 = 1.0f; - // compute -C*inv(A) -/* - for (int i = 0; i < 3; i++) { - (*this)(3, i) = 0.0f; - for (int j = 0; j < 3; j++) { - (*this)(3, i) -= other(3, j) * (*this)(j, i); - } - } -*/ - - _m.m._30 = -(other._m.m._30 * _m.m._00 + + _m.m._30 = -(other._m.m._30 * _m.m._00 + other._m.m._31 * _m.m._10 + other._m.m._32 * _m.m._20); - - _m.m._31 = -(other._m.m._30 * _m.m._01 + - other._m.m._31 * _m.m._11 + + + _m.m._31 = -(other._m.m._30 * _m.m._01 + + other._m.m._31 * _m.m._11 + other._m.m._32 * _m.m._21); - - _m.m._32 = -(other._m.m._30 * _m.m._02 + - other._m.m._31 * _m.m._12 + + + _m.m._32 = -(other._m.m._30 * _m.m._02 + + other._m.m._31 * _m.m._12 + other._m.m._32 * _m.m._22); return true; @@ -1152,6 +1066,7 @@ invert_affine_from(const FLOATNAME(LMatrix4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LMatrix4):: invert_in_place() { + TAU_PROFILE("bool LMatrix4::invert_in_place()", " ", TAU_USER); FLOATNAME(LMatrix4) temp = (*this); return invert_from(temp); } @@ -1191,8 +1106,9 @@ translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz) { // degrees counterclockwise about the indicated vector. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: -rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis, +rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { + TAU_PROFILE("LMatrix4 LMatrix4::rotate_mat(FLOATTYPE, const LVecBase3 &, cs)", " ", TAU_USER); if (cs == CS_default) { cs = get_default_coordinate_system(); @@ -1210,24 +1126,13 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis, FLOATTYPE axis_2 = axis._v.v._2; // Normalize the axis. - -/* - // hack check for prenormalization, only works for simple unit vecs, - // which is what we usually pass in anyway. screws up if you happen to - // pass in something like (.5,.5,0). need to add flag parameter so caller - // can request normalization if needed - - if((cabs(axis_0)+cabs(axis_1)+cabs(axis_2)) != 1.0f) { -*/ - - FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2; - nassertr(length_sq != 0.0f, ident_mat()); - FLOATTYPE recip_length = 1.0f/csqrt(length_sq); - - axis_0 *= recip_length; - axis_1 *= recip_length; - axis_2 *= recip_length; -// } + FLOATTYPE length_sq = axis_0 * axis_0 + axis_1 * axis_1 + axis_2 * axis_2; + nassertr(length_sq != 0.0f, ident_mat()); + FLOATTYPE recip_length = 1.0f/csqrt(length_sq); + + axis_0 *= recip_length; + axis_1 *= recip_length; + axis_2 *= recip_length; FLOATTYPE angle_rad=deg_2_rad(angle); FLOATTYPE s,c; @@ -1278,6 +1183,7 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis, INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { + TAU_PROFILE("LMatrix4 LMatrix4::rotate_mat_normaxis(FLOATTYPE, const LVecBase3 &, cs)", " ", TAU_USER); FLOATNAME(LMatrix4) mat; rotate_mat_normaxis(angle,axis,mat,cs); @@ -1287,6 +1193,8 @@ rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, INLINE_LINMATH void FLOATNAME(LMatrix4):: rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, FLOATNAME(LMatrix4) &result_mat, CoordinateSystem cs) { + TAU_PROFILE("void LMatrix4::rotate_mat_normaxis(FLOATTYPE, const LVecBase3 &, LMatrix4 &, cs)", " ", TAU_USER); + if (cs == CS_default) { cs = get_default_coordinate_system(); @@ -1494,6 +1402,7 @@ transpose(const FLOATNAME(LMatrix4) &a) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LMatrix4) invert(const FLOATNAME(LMatrix4) &a) { + TAU_PROFILE("LMatrix4 invert(const LMatrix4 &)", " ", TAU_USER); FLOATNAME(LMatrix4) result; bool nonsingular = result.invert_from(a); #ifndef NDEBUG diff --git a/panda/src/linmath/lmatrix4_src.cxx b/panda/src/linmath/lmatrix4_src.cxx index 6e0191cfc7..32ca8a4c3a 100644 --- a/panda/src/linmath/lmatrix4_src.cxx +++ b/panda/src/linmath/lmatrix4_src.cxx @@ -62,6 +62,7 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ly_to_rz_mat = //////////////////////////////////////////////////////////////////// const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: convert_mat(CoordinateSystem from, CoordinateSystem to) { + TAU_PROFILE("LMatrix4 LMatrix4::convert_mat(CoordinateSystem, CoordinateSystem)", " ", TAU_USER); if (from == CS_default) { from = get_default_coordinate_system(); } @@ -129,6 +130,7 @@ convert_mat(CoordinateSystem from, CoordinateSystem to) { //////////////////////////////////////////////////////////////////// int FLOATNAME(LMatrix4):: compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { + TAU_PROFILE("int LMatrix4::compare_to(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER); // We compare values in reverse order, since the last row of the // matrix is most likely to be different between different matrices. for (int i = 15; i >= 0; i--) { @@ -147,6 +149,7 @@ compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// bool FLOATNAME(LMatrix4):: almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { + TAU_PROFILE("bool LMatrix4::almost_equal(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER); return (IS_THRESHOLD_EQUAL((*this)(0, 0), other(0, 0), threshold) && IS_THRESHOLD_EQUAL((*this)(0, 1), other(0, 1), threshold) && IS_THRESHOLD_EQUAL((*this)(0, 2), other(0, 2), threshold) && @@ -268,6 +271,7 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// void FLOATNAME(LMatrix4):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { + TAU_PROFILE("void LMatrix4::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { hashgen.add_fp(get_cell(i,j), threshold); @@ -282,6 +286,7 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// bool FLOATNAME(LMatrix4):: decompose_mat(int index[4]) { + TAU_PROFILE("bool LMatrix4::decompose_mat(int[4])", " ", TAU_USER); int i, j, k; FLOATTYPE vv[4]; for (i = 0; i < 4; i++) { @@ -359,6 +364,7 @@ decompose_mat(int index[4]) { //////////////////////////////////////////////////////////////////// bool FLOATNAME(LMatrix4):: back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const { + TAU_PROFILE("bool LMatrix4::back_sub_mat(int[4], LMatrix4 &, int)", " ", TAU_USER); int ii = -1; int i, j; for (i = 0; i < 4; i++) { diff --git a/panda/src/linmath/lmatrix4_src.h b/panda/src/linmath/lmatrix4_src.h index d665546b67..daa538a627 100644 --- a/panda/src/linmath/lmatrix4_src.h +++ b/panda/src/linmath/lmatrix4_src.h @@ -35,6 +35,7 @@ PUBLISHED: FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23, FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33); + ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix4)); // Construct a 4x4 matrix given a 3x3 rotation matrix and an optional // translation component. @@ -135,7 +136,7 @@ PUBLISHED: translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz); INLINE_LINMATH static FLOATNAME(LMatrix4) rotate_mat(FLOATTYPE angle, - FLOATNAME(LVecBase3) axis, + const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs = CS_default); INLINE_LINMATH static FLOATNAME(LMatrix4) rotate_mat_normaxis(FLOATTYPE angle, diff --git a/panda/src/linmath/lorientation_src.I b/panda/src/linmath/lorientation_src.I index 5e68556a90..4d3e4bdb5c 100644 --- a/panda/src/linmath/lorientation_src.I +++ b/panda/src/linmath/lorientation_src.I @@ -86,11 +86,11 @@ FLOATNAME(LOrientation)(const FLOATNAME(LMatrix4) &m) { // Function: LOrientation::operator * // Access: public // Description: Orientation * rotation = Orientation -// Applies an rotation to an orientation. +// Applies a rotation to an orientation. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LOrientation) FLOATNAME(LOrientation):: -operator *(const FLOATNAME(LRotation)& other) const { - return multiply(other); +operator * (const FLOATNAME(LRotation) &other) const { + return multiply((FLOATNAME(LOrientation) &)other); } //////////////////////////////////////////////////////////////////// @@ -101,7 +101,7 @@ operator *(const FLOATNAME(LRotation)& other) const { // simply return the rhs. //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LOrientation) FLOATNAME(LOrientation):: -operator *(const FLOATNAME(LQuaternion)& other) const { +operator * (const FLOATNAME(LQuaternion) &other) const { nassert_raise("LOrientation * LQuaternion is undefined; use LOrientation * LRotation or LQuaternion * LQuaternion"); - return multiply(other); + return multiply((FLOATNAME(LOrientation) &)other); } diff --git a/panda/src/linmath/lorientation_src.h b/panda/src/linmath/lorientation_src.h index 28f94ea820..382da757e0 100644 --- a/panda/src/linmath/lorientation_src.h +++ b/panda/src/linmath/lorientation_src.h @@ -16,6 +16,8 @@ // //////////////////////////////////////////////////////////////////// +class FLOATNAME(LRotation); + //////////////////////////////////////////////////////////////////////// // Class : LOrientation // Description : This is a unit quaternion representing an orientation. @@ -30,10 +32,10 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LOrientation)(const FLOATNAME(LMatrix4) &); INLINE_LINMATH FLOATNAME(LOrientation) - operator *(const FLOATNAME(LRotation)& other) const; + operator * (const FLOATNAME(LRotation) &other) const; INLINE_LINMATH FLOATNAME(LOrientation) - operator *(const FLOATNAME(LQuaternion)& other) const; + operator * (const FLOATNAME(LQuaternion) &other) const; public: static TypeHandle get_class_type() { diff --git a/panda/src/linmath/lvecBase2_src.I b/panda/src/linmath/lvecBase2_src.I index 343e57d9b0..5d9a3e4806 100644 --- a/panda/src/linmath/lvecBase2_src.I +++ b/panda/src/linmath/lvecBase2_src.I @@ -33,6 +33,7 @@ FLOATNAME(LVecBase2)() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2):: FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) ©) { + TAU_PROFILE("LVecBase2::LVecBase2(LVecBase2 &)", " ", TAU_USER); _v.v._0 = copy._v.v._0; _v.v._1 = copy._v.v._1; // (*this) = copy; @@ -45,6 +46,7 @@ FLOATNAME(LVecBase2)(const FLOATNAME(LVecBase2) ©) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2):: operator = (const FLOATNAME(LVecBase2) ©) { + TAU_PROFILE("void LVecBase2::operator = (LVecBase2 &)", " ", TAU_USER); _v.v._0 = copy._v.v._0; _v.v._1 = copy._v.v._1; // set(copy[0], copy[1]); @@ -79,6 +81,7 @@ FLOATNAME(LVecBase2)(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2):: FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y) { + TAU_PROFILE("void LVecBase2::operator = (FLOATTYPE, ...)", " ", TAU_USER); _v.v._0 = x; _v.v._1 = y; // set(x, y); @@ -153,6 +156,7 @@ operator [](int i) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase2):: is_nan() const { + TAU_PROFILE("bool LVecBase2::is_nan()", " ", TAU_USER); return cnan(_v.v._0) || cnan(_v.v._1); } @@ -324,6 +328,7 @@ end() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase2):: fill(FLOATTYPE fill_value) { + TAU_PROFILE("void LVecBase2::fill()", " ", TAU_USER); _v.v._0 = fill_value; _v.v._1 = fill_value; } @@ -335,6 +340,7 @@ fill(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase2):: set(FLOATTYPE x, FLOATTYPE y) { + TAU_PROFILE("void LVecBase2::set()", " ", TAU_USER); _v.v._0 = x; _v.v._1 = y; } @@ -346,6 +352,7 @@ set(FLOATTYPE x, FLOATTYPE y) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: dot(const FLOATNAME(LVecBase2) &other) const { + TAU_PROFILE("FLOATTYPE LVecBase2::dot()", " ", TAU_USER); return _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1; } @@ -360,6 +367,7 @@ dot(const FLOATNAME(LVecBase2) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase2):: operator < (const FLOATNAME(LVecBase2) &other) const { + TAU_PROFILE("bool LVecBase2::operator <(const LVecBase2 &)", " ", TAU_USER); return (compare_to(other) < 0); } @@ -370,6 +378,7 @@ operator < (const FLOATNAME(LVecBase2) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase2):: operator == (const FLOATNAME(LVecBase2) &other) const { + TAU_PROFILE("bool LVecBase2::operator ==(const LVecBase2 &)", " ", TAU_USER); return (_v.v._0 == other._v.v._0 && _v.v._1 == other._v.v._1); } @@ -392,6 +401,7 @@ operator != (const FLOATNAME(LVecBase2) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH int FLOATNAME(LVecBase2):: compare_to(const FLOATNAME(LVecBase2) &other) const { + TAU_PROFILE("int LVecBase2::compare_to(const LVecBase2 &)", " ", TAU_USER); return compare_to(other, NEARLY_ZERO(FLOATTYPE)); } @@ -406,6 +416,7 @@ compare_to(const FLOATNAME(LVecBase2) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH int FLOATNAME(LVecBase2):: compare_to(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { + TAU_PROFILE("int LVecBase2::compare_to(const LVecBase2 &, FLOATTYPE)", " ", TAU_USER); if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) { return (_v.v._0 < other._v.v._0) ? -1 : 1; } @@ -422,6 +433,7 @@ compare_to(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase2):: get_hash() const { + TAU_PROFILE("size_t LVecBase2::get_hash()", " ", TAU_USER); return add_hash(0); } @@ -432,6 +444,7 @@ get_hash() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase2):: get_hash(FLOATTYPE threshold) const { + TAU_PROFILE("size_t LVecBase2::get_hash(FLOATTYPE)", " ", TAU_USER); return add_hash(0, threshold); } @@ -442,6 +455,7 @@ get_hash(FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase2):: add_hash(size_t hash) const { + TAU_PROFILE("size_t LVecBase2::add_hash(size_t)", " ", TAU_USER); return add_hash(hash, NEARLY_ZERO(FLOATTYPE)); } @@ -452,6 +466,7 @@ add_hash(size_t hash) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase2):: add_hash(size_t hash, FLOATTYPE threshold) const { + TAU_PROFILE("LVecBase2::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); float_hash fhasher(threshold); hash = fhasher.add_hash(hash, _v.v._0); hash = fhasher.add_hash(hash, _v.v._1); @@ -565,6 +580,7 @@ operator /= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: fmax(const FLOATNAME(LVecBase2) &other) { + TAU_PROFILE("LVecBase2::fmax()", " ", TAU_USER); return FLOATNAME(LVecBase2)(_v.v._0 > other._v.v._0 ? _v.v._0 : other._v.v._0, _v.v._1 > other._v.v._1 ? _v.v._1 : other._v.v._1); } @@ -576,6 +592,7 @@ fmax(const FLOATNAME(LVecBase2) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: fmin(const FLOATNAME(LVecBase2) &other) { + TAU_PROFILE("LVecBase2::fmin()", " ", TAU_USER); return FLOATNAME(LVecBase2)(_v.v._0 < other._v.v._0 ? _v.v._0 : other._v.v._0, _v.v._1 < other._v.v._1 ? _v.v._1 : other._v.v._1); } @@ -588,6 +605,7 @@ fmin(const FLOATNAME(LVecBase2) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase2):: almost_equal(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { + TAU_PROFILE("bool LVecBase2::almost_equal(LVecBase2 &, FLOATTYPE)", " ", TAU_USER); return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) && IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold)); } @@ -600,6 +618,7 @@ almost_equal(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase2):: almost_equal(const FLOATNAME(LVecBase2) &other) const { + TAU_PROFILE("bool LVecBase2::almost_equal(LVecBase2 &)", " ", TAU_USER); return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } diff --git a/panda/src/linmath/lvecBase2_src.h b/panda/src/linmath/lvecBase2_src.h index a83368738a..1700ace82e 100644 --- a/panda/src/linmath/lvecBase2_src.h +++ b/panda/src/linmath/lvecBase2_src.h @@ -35,6 +35,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVecBase2) &operator = (FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y); + ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase2)); INLINE_LINMATH static const FLOATNAME(LVecBase2) &zero(); INLINE_LINMATH static const FLOATNAME(LVecBase2) &unit_x(); diff --git a/panda/src/linmath/lvecBase3_src.I b/panda/src/linmath/lvecBase3_src.I index 35e3886630..096e7449c1 100644 --- a/panda/src/linmath/lvecBase3_src.I +++ b/panda/src/linmath/lvecBase3_src.I @@ -32,6 +32,7 @@ FLOATNAME(LVecBase3)() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3):: FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) ©) { + TAU_PROFILE("LVecBase3::LVecBase3(LVecBase3 &)", " ", TAU_USER); _v.v._0 = copy._v.v._0; _v.v._1 = copy._v.v._1; _v.v._2 = copy._v.v._2; @@ -45,6 +46,7 @@ FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase3) ©) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3):: operator = (const FLOATNAME(LVecBase3) ©) { + TAU_PROFILE("void LVecBase3::operator =(LVecBase3 &)", " ", TAU_USER); _v.v._0 = copy._v.v._0; _v.v._1 = copy._v.v._1; _v.v._2 = copy._v.v._2; @@ -80,6 +82,7 @@ FLOATNAME(LVecBase3)(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3):: FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { + TAU_PROFILE("void LVecBase3::operator = (FLOATTYPE, ...)", " ", TAU_USER); _v.v._0 = x; _v.v._1 = y; _v.v._2 = z; @@ -165,6 +168,7 @@ operator [](int i) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase3):: is_nan() const { + TAU_PROFILE("bool LVecBase3::is_nan()", " ", TAU_USER); return cnan(_v.v._0) || cnan(_v.v._1) || cnan(_v.v._2); } @@ -366,6 +370,7 @@ end() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase3):: fill(FLOATTYPE fill_value) { + TAU_PROFILE("void LVecBase3::fill()", " ", TAU_USER); _v.v._0 = fill_value; _v.v._1 = fill_value; _v.v._2 = fill_value; @@ -378,6 +383,7 @@ fill(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase3):: set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { + TAU_PROFILE("void LVecBase3::set()", " ", TAU_USER); _v.v._0 = x; _v.v._1 = y; _v.v._2 = z; @@ -391,6 +397,7 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: length() const { + TAU_PROFILE("FLOATTYPE LVecBase3::length()", " ", TAU_USER); return csqrt((*this).dot(*this)); } @@ -402,6 +409,7 @@ length() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: length_squared() const { + TAU_PROFILE("FLOATTYPE LVecBase3::length_squared()", " ", TAU_USER); return (*this).dot(*this); } @@ -414,6 +422,7 @@ length_squared() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase3):: normalize() { + TAU_PROFILE("bool LVecBase3::normalize()", " ", TAU_USER); FLOATTYPE l2 = length_squared(); if (l2 == (FLOATTYPE)0.0f) { set(0.0f, 0.0f, 0.0f); @@ -433,6 +442,7 @@ normalize() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: dot(const FLOATNAME(LVecBase3) &other) const { + TAU_PROFILE("FLOATTYPE LVecBase3::dot()", " ", TAU_USER); return _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1 + _v.v._2 * other._v.v._2; } @@ -443,6 +453,7 @@ dot(const FLOATNAME(LVecBase3) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3):: cross(const FLOATNAME(LVecBase3) &other) const { + TAU_PROFILE("LVecBase3 LVecBase3::cross()", " ", TAU_USER); return FLOATNAME(LVecBase3)(_v.v._1 * other._v.v._2 - other._v.v._1 * _v.v._2, other._v.v._0 * _v.v._2 - _v.v._0 * other._v.v._2, _v.v._0 * other._v.v._1 - other._v.v._0 * _v.v._1); @@ -459,6 +470,7 @@ cross(const FLOATNAME(LVecBase3) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase3):: operator < (const FLOATNAME(LVecBase3) &other) const { + TAU_PROFILE("bool LVecBase3::operator <(const LVecBase3 &)", " ", TAU_USER); return (compare_to(other) < 0); } @@ -469,6 +481,7 @@ operator < (const FLOATNAME(LVecBase3) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase3):: operator == (const FLOATNAME(LVecBase3) &other) const { + TAU_PROFILE("bool LVecBase3::operator ==(const LVecBase3 &)", " ", TAU_USER); return (_v.v._0 == other._v.v._0 && _v.v._1 == other._v.v._1 && _v.v._2 == other._v.v._2); @@ -540,6 +553,7 @@ get_standardized_hpr() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH int FLOATNAME(LVecBase3):: compare_to(const FLOATNAME(LVecBase3) &other) const { + TAU_PROFILE("int LVecBase3::compare_to(const LVecBase3 &)", " ", TAU_USER); return compare_to(other, NEARLY_ZERO(FLOATTYPE)); } @@ -554,6 +568,7 @@ compare_to(const FLOATNAME(LVecBase3) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH int FLOATNAME(LVecBase3):: compare_to(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const { + TAU_PROFILE("int LVecBase3::compare_to(const LVecBase3 &, FLOATTYPE)", " ", TAU_USER); if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) { return (_v.v._0 < other._v.v._0) ? -1 : 1; } @@ -573,6 +588,7 @@ compare_to(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase3):: get_hash() const { + TAU_PROFILE("size_t LVecBase3::get_hash()", " ", TAU_USER); return add_hash(0); } @@ -583,6 +599,7 @@ get_hash() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase3):: get_hash(FLOATTYPE threshold) const { + TAU_PROFILE("size_t LVecBase3::get_hash(FLOATTYPE)", " ", TAU_USER); return add_hash(0, threshold); } @@ -593,6 +610,7 @@ get_hash(FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase3):: add_hash(size_t hash) const { + TAU_PROFILE("size_t LVecBase3::add_hash(size_t)", " ", TAU_USER); return add_hash(hash, NEARLY_ZERO(FLOATTYPE)); } @@ -603,6 +621,7 @@ add_hash(size_t hash) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase3):: add_hash(size_t hash, FLOATTYPE threshold) const { + TAU_PROFILE("LVecBase3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); float_hash fhasher(threshold); hash = fhasher.add_hash(hash, _v.v._0); hash = fhasher.add_hash(hash, _v.v._1); @@ -725,6 +744,7 @@ operator /= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3):: fmax(const FLOATNAME(LVecBase3) &other) { + TAU_PROFILE("LVecBase3::fmax()", " ", TAU_USER); return FLOATNAME(LVecBase3)(_v.v._0 > other._v.v._0 ? _v.v._0 : other._v.v._0, _v.v._1 > other._v.v._1 ? _v.v._1 : other._v.v._1, _v.v._2 > other._v.v._2 ? _v.v._2 : other._v.v._2); @@ -737,6 +757,7 @@ fmax(const FLOATNAME(LVecBase3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3):: fmin(const FLOATNAME(LVecBase3) &other) { + TAU_PROFILE("LVecBase3::fmin()", " ", TAU_USER); return FLOATNAME(LVecBase3)(_v.v._0 < other._v.v._0 ? _v.v._0 : other._v.v._0, _v.v._1 < other._v.v._1 ? _v.v._1 : other._v.v._1, _v.v._2 < other._v.v._2 ? _v.v._2 : other._v.v._2); @@ -760,6 +781,7 @@ cross_into(const FLOATNAME(LVecBase3) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase3):: almost_equal(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const { + TAU_PROFILE("bool LVecBase3::almost_equal(LVecBase3 &, FLOATTYPE)", " ", TAU_USER); return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) && IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold) && IS_THRESHOLD_EQUAL(_v.v._2, other._v.v._2, threshold)); @@ -773,6 +795,7 @@ almost_equal(const FLOATNAME(LVecBase3) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase3):: almost_equal(const FLOATNAME(LVecBase3) &other) const { + TAU_PROFILE("bool LVecBase3::almost_equal(LVecBase3 &)", " ", TAU_USER); return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } @@ -811,6 +834,7 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase3):: generate_hash(ChecksumHashGenerator &hashgen) const { + TAU_PROFILE("LVecBase3::generate_hash(ChecksumHashGenerator &)", " ", TAU_USER); generate_hash(hashgen, NEARLY_ZERO(FLOATTYPE)); } @@ -821,6 +845,7 @@ generate_hash(ChecksumHashGenerator &hashgen) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase3):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { + TAU_PROFILE("LVecBase3::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); hashgen.add_fp(_v.v._0, threshold); hashgen.add_fp(_v.v._1, threshold); hashgen.add_fp(_v.v._2, threshold); diff --git a/panda/src/linmath/lvecBase3_src.h b/panda/src/linmath/lvecBase3_src.h index eb418d3f91..b61c467361 100644 --- a/panda/src/linmath/lvecBase3_src.h +++ b/panda/src/linmath/lvecBase3_src.h @@ -32,6 +32,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVecBase3) &operator = (FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); + ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase3)); INLINE_LINMATH static const FLOATNAME(LVecBase3) &zero(); INLINE_LINMATH static const FLOATNAME(LVecBase3) &unit_x(); diff --git a/panda/src/linmath/lvecBase4_src.I b/panda/src/linmath/lvecBase4_src.I index ed163b508c..deacc52a9f 100644 --- a/panda/src/linmath/lvecBase4_src.I +++ b/panda/src/linmath/lvecBase4_src.I @@ -33,6 +33,7 @@ FLOATNAME(LVecBase4)() { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) ©) { + TAU_PROFILE("LVecBase4::LVecBase4(LVecBase4 &)", " ", TAU_USER); _v.v._0 = copy._v.v._0; _v.v._1 = copy._v.v._1; _v.v._2 = copy._v.v._2; @@ -47,6 +48,7 @@ FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase4) ©) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4):: operator = (const FLOATNAME(LVecBase4) ©) { + TAU_PROFILE("void LVecBase4::operator = (LVecBase4 &)", " ", TAU_USER); _v.v._0 = copy._v.v._0; _v.v._1 = copy._v.v._1; _v.v._2 = copy._v.v._2; @@ -83,6 +85,7 @@ FLOATNAME(LVecBase4)(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { + TAU_PROFILE("void LVecBase4::operator = (FLOATTYPE, ...)", " ", TAU_USER); _v.v._0 = x; _v.v._1 = y; _v.v._2 = z; @@ -179,6 +182,7 @@ operator [](int i) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase4):: is_nan() const { + TAU_PROFILE("bool LVecBase4::is_nan()", " ", TAU_USER); return cnan(_v.v._0) || cnan(_v.v._1) || cnan(_v.v._2) || cnan(_v.v._3); } @@ -410,6 +414,7 @@ end() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase4):: fill(FLOATTYPE fill_value) { + TAU_PROFILE("void LVecBase4::fill()", " ", TAU_USER); _v.v._0 = fill_value; _v.v._1 = fill_value; _v.v._2 = fill_value; @@ -423,6 +428,7 @@ fill(FLOATTYPE fill_value) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase4):: set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { + TAU_PROFILE("void LVecBase4::set()", " ", TAU_USER); _v.v._0 = x; _v.v._1 = y; _v.v._2 = z; @@ -436,6 +442,7 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: dot(const FLOATNAME(LVecBase4) &other) const { + TAU_PROFILE("FLOATTYPE LVecBase4::dot()", " ", TAU_USER); return _v.v._0 * other._v.v._0 + _v.v._1 * other._v.v._1 + _v.v._2 * other._v.v._2 + _v.v._3 * other._v.v._3; @@ -452,6 +459,7 @@ dot(const FLOATNAME(LVecBase4) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase4):: operator < (const FLOATNAME(LVecBase4) &other) const { + TAU_PROFILE("bool LVecBase4::operator <(const LVecBase4 &)", " ", TAU_USER); return (compare_to(other) < 0); } @@ -462,6 +470,7 @@ operator < (const FLOATNAME(LVecBase4) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase4):: operator == (const FLOATNAME(LVecBase4) &other) const { + TAU_PROFILE("bool LVecBase4::operator ==(const LVecBase4 &)", " ", TAU_USER); return (_v.v._0 == other._v.v._0 && _v.v._1 == other._v.v._1 && _v.v._2 == other._v.v._2 && @@ -486,6 +495,7 @@ operator != (const FLOATNAME(LVecBase4) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH int FLOATNAME(LVecBase4):: compare_to(const FLOATNAME(LVecBase4) &other) const { + TAU_PROFILE("int LVecBase4::compare_to(const LVecBase4 &)", " ", TAU_USER); return compare_to(other, NEARLY_ZERO(FLOATTYPE)); } @@ -500,6 +510,7 @@ compare_to(const FLOATNAME(LVecBase4) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH int FLOATNAME(LVecBase4):: compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { + TAU_PROFILE("int LVecBase4::compare_to(const LVecBase4 &, FLOATTYPE)", " ", TAU_USER); if (!IS_THRESHOLD_COMPEQ(_v.v._0, other._v.v._0, threshold)) { return (_v.v._0 < other._v.v._0) ? -1 : 1; } @@ -522,6 +533,7 @@ compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase4):: get_hash() const { + TAU_PROFILE("size_t LVecBase4::get_hash()", " ", TAU_USER); return add_hash(0); } @@ -532,6 +544,7 @@ get_hash() const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase4):: get_hash(FLOATTYPE threshold) const { + TAU_PROFILE("size_t LVecBase4::get_hash(FLOATTYPE)", " ", TAU_USER); return add_hash(0, threshold); } @@ -542,6 +555,7 @@ get_hash(FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase4):: add_hash(size_t hash) const { + TAU_PROFILE("size_t LVecBase4::add_hash(size_t)", " ", TAU_USER); return add_hash(hash, NEARLY_ZERO(FLOATTYPE)); } @@ -552,6 +566,7 @@ add_hash(size_t hash) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH size_t FLOATNAME(LVecBase4):: add_hash(size_t hash, FLOATTYPE threshold) const { + TAU_PROFILE("LVecBase4::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); float_hash fhasher(threshold); hash = fhasher.add_hash(hash, _v.v._0); hash = fhasher.add_hash(hash, _v.v._1); @@ -683,6 +698,7 @@ operator /= (FLOATTYPE scalar) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: fmax(const FLOATNAME(LVecBase4) &other) { + TAU_PROFILE("LVecBase4::fmax()", " ", TAU_USER); return FLOATNAME(LVecBase4)(_v.v._0 > other._v.v._0 ? _v.v._0 : other._v.v._0, _v.v._1 > other._v.v._1 ? _v.v._1 : other._v.v._1, _v.v._2 > other._v.v._2 ? _v.v._2 : other._v.v._2, @@ -696,6 +712,7 @@ fmax(const FLOATNAME(LVecBase4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: fmin(const FLOATNAME(LVecBase4) &other) { + TAU_PROFILE("LVecBase4::fmin()", " ", TAU_USER); return FLOATNAME(LVecBase4)(_v.v._0 < other._v.v._0 ? _v.v._0 : other._v.v._0, _v.v._1 < other._v.v._1 ? _v.v._1 : other._v.v._1, _v.v._2 < other._v.v._2 ? _v.v._2 : other._v.v._2, @@ -710,6 +727,7 @@ fmin(const FLOATNAME(LVecBase4) &other) { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase4):: almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { + TAU_PROFILE("bool LVecBase4::almost_equal(LVecBase4 &, FLOATTYPE)", " ", TAU_USER); return (IS_THRESHOLD_EQUAL(_v.v._0, other._v.v._0, threshold) && IS_THRESHOLD_EQUAL(_v.v._1, other._v.v._1, threshold) && IS_THRESHOLD_EQUAL(_v.v._2, other._v.v._2, threshold) && @@ -724,6 +742,7 @@ almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH bool FLOATNAME(LVecBase4):: almost_equal(const FLOATNAME(LVecBase4) &other) const { + TAU_PROFILE("bool LVecBase4::almost_equal(LVecBase4 &)", " ", TAU_USER); return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } @@ -763,6 +782,7 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase4):: generate_hash(ChecksumHashGenerator &hashgen) const { + TAU_PROFILE("LVecBase4::generate_hash(ChecksumHashGenerator &)", " ", TAU_USER); generate_hash(hashgen, NEARLY_ZERO(FLOATTYPE)); } @@ -773,6 +793,7 @@ generate_hash(ChecksumHashGenerator &hashgen) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH void FLOATNAME(LVecBase4):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { + TAU_PROFILE("LVecBase4::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); hashgen.add_fp(_v.v._0, threshold); hashgen.add_fp(_v.v._1, threshold); hashgen.add_fp(_v.v._2, threshold); diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h index 818c38bb2d..c1881623c1 100644 --- a/panda/src/linmath/lvecBase4_src.h +++ b/panda/src/linmath/lvecBase4_src.h @@ -32,6 +32,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVecBase4) &operator = (FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); + ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase4)); INLINE_LINMATH static const FLOATNAME(LVecBase4) &zero(); INLINE_LINMATH static const FLOATNAME(LVecBase4) &unit_x(); diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index 13f1c3c134..0601a15270 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -47,6 +47,7 @@ public: const LPoint3f &fur, const LPoint3f &ful, const LPoint3f &nll, const LPoint3f &nlr, const LPoint3f &nur, const LPoint3f &nul); + ALLOC_DELETED_CHAIN(BoundingHexahedron); virtual BoundingVolume *make_copy() const; virtual LPoint3f get_min() const; diff --git a/panda/src/mathutil/boundingLine.h b/panda/src/mathutil/boundingLine.h index bd39120561..ddd0b965e3 100644 --- a/panda/src/mathutil/boundingLine.h +++ b/panda/src/mathutil/boundingLine.h @@ -38,6 +38,7 @@ class EXPCL_PANDA BoundingLine : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingLine(); INLINE_MATHUTIL BoundingLine(const LPoint3f &a, const LPoint3f &b); + ALLOC_DELETED_CHAIN(BoundingLine); public: virtual BoundingVolume *make_copy() const; diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index 67b48d8196..55ff397501 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -36,6 +36,7 @@ class EXPCL_PANDA BoundingPlane : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingPlane(); INLINE_MATHUTIL BoundingPlane(const Planef &plane); + ALLOC_DELETED_CHAIN(BoundingPlane); public: virtual BoundingVolume *make_copy() const; diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index e74e125846..1a862bf961 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -19,6 +19,7 @@ #include "boundingSphere.h" #include "boundingHexahedron.h" #include "boundingLine.h" +#include "boundingPlane.h" #include "config_mathutil.h" #include "dcast.h" diff --git a/panda/src/mathutil/boundingSphere.h b/panda/src/mathutil/boundingSphere.h index a614eb8b21..02d7d4635c 100644 --- a/panda/src/mathutil/boundingSphere.h +++ b/panda/src/mathutil/boundingSphere.h @@ -33,6 +33,7 @@ class EXPCL_PANDA BoundingSphere : public FiniteBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingSphere(); INLINE_MATHUTIL BoundingSphere(const LPoint3f ¢er, float radius); + ALLOC_DELETED_CHAIN(BoundingSphere); public: virtual BoundingVolume *make_copy() const; diff --git a/panda/src/mathutil/boundingVolume.h b/panda/src/mathutil/boundingVolume.h index 6fa6bc6c31..b18b0a5f78 100644 --- a/panda/src/mathutil/boundingVolume.h +++ b/panda/src/mathutil/boundingVolume.h @@ -23,6 +23,7 @@ #include "typedObject.h" #include "typedReferenceCount.h" +#include "deletedChain.h" class BoundingSphere; class BoundingHexahedron; diff --git a/panda/src/net/Sources.pp b/panda/src/net/Sources.pp index a66095d832..1714505b58 100644 --- a/panda/src/net/Sources.pp +++ b/panda/src/net/Sources.pp @@ -22,7 +22,7 @@ queuedConnectionReader.h recentConnectionReader.h \ queuedReturn.h queuedReturn.I - #define INCLUDED_SOURCES \ \ + #define INCLUDED_SOURCES \ config_net.cxx connection.cxx connectionListener.cxx \ connectionManager.cxx connectionReader.cxx \ connectionWriter.cxx datagramQueue.cxx datagramTCPHeader.cxx \ diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index 5161ca0052..1e447c4cbf 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -18,6 +18,7 @@ #include "connectionWriter.h" #include "connectionManager.h" +#include "datagramTCPHeader.h" #include "pprerror.h" #include "config_net.h" diff --git a/panda/src/parametrics/nurbsCurveResult.cxx b/panda/src/parametrics/nurbsCurveResult.cxx index 36cf63dd6c..1300c593ff 100644 --- a/panda/src/parametrics/nurbsCurveResult.cxx +++ b/panda/src/parametrics/nurbsCurveResult.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "nurbsCurveResult.h" +#include "nurbsVertex.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/parametrics/nurbsSurfaceResult.cxx b/panda/src/parametrics/nurbsSurfaceResult.cxx index 3441ebe7bc..d5c5b23791 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.cxx +++ b/panda/src/parametrics/nurbsSurfaceResult.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "nurbsSurfaceResult.h" +#include "nurbsVertex.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/particlesystem/colorInterpolationManager.h b/panda/src/particlesystem/colorInterpolationManager.h index a824c2ee76..27d379187f 100755 --- a/panda/src/particlesystem/colorInterpolationManager.h +++ b/panda/src/particlesystem/colorInterpolationManager.h @@ -22,6 +22,7 @@ #include "luse.h" #include "pvector.h" #include "typedObject.h" +#include "typedReferenceCount.h" //////////////////////////////////////////////////////////////////// // Class : ColorInterpolationFunction diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index dc8017a101..c4a1713e6d 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -32,6 +32,7 @@ #include "textureCollection.h" #include "nodePathCollection.h" #include "indent.h" +#include "config_particlesystem.h" //////////////////////////////////////////////////////////////////// // Function : SpriteParticleRenderer::SpriteParticleRenderer diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 8e66eb5e3e..e15f563246 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -164,6 +164,19 @@ ConfigVariableBool auto_break_cycles "is false, you must explicitly call TransformState.clear_cache() " "from time to time to prevent gradual memory bloat.")); +ConfigVariableBool transform_cache +("transform-cache", true, + PRC_DESC("Set this true to enable the cache of TransformState objects. " + "Using the cache saves time computing transforms and inverse " + "transforms, but imposes some overhead for maintaining the " + "cache itself.")); + +ConfigVariableBool state_cache +("state-cache", true, + PRC_DESC("Set this true to enable the cache of RenderState objects, " + "similar to the TransformState cache controlled via " + "transform-cache.")); + ConfigVariableInt max_collect_vertices ("max-collect-vertices", 1024, PRC_DESC("Specifies the maximum number of vertices that are allowed to be " diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 6e5fd62515..25070d8cdd 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -43,6 +43,8 @@ extern ConfigVariableBool compose_componentwise; extern ConfigVariableBool uniquify_matrix; extern ConfigVariableBool paranoid_const; extern ConfigVariableBool auto_break_cycles; +extern ConfigVariableBool transform_cache; +extern ConfigVariableBool state_cache; extern ConfigVariableInt max_collect_vertices; extern ConfigVariableInt max_collect_indices; diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index 9ff4b4871f..6689245eca 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "cullPlanes.h" +#include "cullTraverserData.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/cullPlanes.h b/panda/src/pgraph/cullPlanes.h index 22696d7b89..07e4e5b095 100644 --- a/panda/src/pgraph/cullPlanes.h +++ b/panda/src/pgraph/cullPlanes.h @@ -26,6 +26,7 @@ #include "boundingPlane.h" #include "pointerTo.h" #include "luse.h" +#include "deletedChain.h" //////////////////////////////////////////////////////////////////// // Class : CullPlanes @@ -51,6 +52,7 @@ protected: public: INLINE ~CullPlanes(); + ALLOC_DELETED_CHAIN(CullPlanes); INLINE bool is_empty() const; diff --git a/panda/src/pgraph/cullableObject.I b/panda/src/pgraph/cullableObject.I index a8cc61f78b..a9e867d38f 100644 --- a/panda/src/pgraph/cullableObject.I +++ b/panda/src/pgraph/cullableObject.I @@ -120,55 +120,6 @@ draw(GraphicsStateGuardianBase *gsg) { _geom->draw(gsg, _munger, _munged_data); } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::operator new -// Access: Public -// Description: Allocates the memory for a new CullableObject. This -// is specialized here to provide for fast allocation of -// these things (since we may create and destroy -// thousands of these each frame). -//////////////////////////////////////////////////////////////////// -INLINE void *CullableObject:: -operator new(size_t size) { - if (_deleted_chain != (CullableObject *)NULL) { - CullableObject *obj = _deleted_chain; - _deleted_chain = _deleted_chain->_next; - return obj; - } -#ifndef NDEBUG - _num_ever_allocated++; -#endif // NDEBUG - return ::operator new(size); -} - -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::operator delete -// Access: Public -// Description: Frees the memory for a deleted CullableObject. This -// is specialized here to provide for fast allocation of -// these things (since we may create and destroy -// thousands of these each frame). -//////////////////////////////////////////////////////////////////// -INLINE void CullableObject:: -operator delete(void *ptr) { - CullableObject *obj = (CullableObject *)ptr; - obj->_next = _deleted_chain; - _deleted_chain = obj; -} - -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::get_num_ever_allocated -// Access: Published, Static -// Description: Returns the number of CullableObject pointers ever -// simultaneously allocated; these are now either in -// active use or have been recycled into the deleted -// CullableObject pool to be used again. -//////////////////////////////////////////////////////////////////// -INLINE int CullableObject:: -get_num_ever_allocated() { - return _num_ever_allocated; -} - //////////////////////////////////////////////////////////////////// // Function: CullableObject::SortPoints::Constructor // Access: Public diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index f1fa05defa..09f027f488 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -38,8 +38,6 @@ PStatCollector CullableObject::_munge_points_pcollector("*:Munge:Points"); PStatCollector CullableObject::_munge_light_vector_pcollector("*:Munge:Light Vector"); -CullableObject *CullableObject::_deleted_chain = (CullableObject *)NULL; -int CullableObject::_num_ever_allocated = 0; TypeHandle CullableObject::_type_handle; //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/cullableObject.h b/panda/src/pgraph/cullableObject.h index 813dfce307..288bb067c1 100644 --- a/panda/src/pgraph/cullableObject.h +++ b/panda/src/pgraph/cullableObject.h @@ -32,6 +32,7 @@ #include "geomNode.h" #include "cullTraverserData.h" #include "pStatCollector.h" +#include "deletedChain.h" class CullTraverser; @@ -65,18 +66,10 @@ public: public: ~CullableObject(); + ALLOC_DELETED_CHAIN(CullableObject); - // We will allocate and destroy hundreds or thousands of these a - // frame during the normal course of rendering. As an optimization, - // then, we implement operator new and delete here to minimize this - // overhead. - INLINE void *operator new(size_t size); - INLINE void operator delete(void *ptr); void output(ostream &out) const; -PUBLISHED: - INLINE static int get_num_ever_allocated(); - public: CPT(Geom) _geom; PT(GeomMunger) _munger; @@ -112,9 +105,6 @@ private: const PointData *_array; }; - static CullableObject *_deleted_chain; - static int _num_ever_allocated; - static PStatCollector _munge_points_pcollector; static PStatCollector _munge_light_vector_pcollector; diff --git a/panda/src/pgraph/findApproxLevelEntry.I b/panda/src/pgraph/findApproxLevelEntry.I index 017e027cc3..3a58a41353 100644 --- a/panda/src/pgraph/findApproxLevelEntry.I +++ b/panda/src/pgraph/findApproxLevelEntry.I @@ -101,50 +101,3 @@ INLINE bool FindApproxLevelEntry:: is_solution(int increment) const { return (_i + increment >= _approx_path.get_num_components()); } - -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::operator new -// Access: Public -// Description: Allocates the memory for a new FindApproxLevelEntry. -// This is specialized here to provide for fast -// allocation of these things. -//////////////////////////////////////////////////////////////////// -INLINE void *FindApproxLevelEntry:: -operator new(size_t size) { - if (_deleted_chain != (FindApproxLevelEntry *)NULL) { - FindApproxLevelEntry *obj = _deleted_chain; - _deleted_chain = _deleted_chain->_next; - return obj; - } -#ifndef NDEBUG - _num_ever_allocated++; -#endif // NDEBUG - return ::operator new(size); -} - -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::operator delete -// Access: Public -// Description: Frees the memory for a deleted FindApproxLevelEntry. -// This is specialized here to provide for fast -// allocation of these things. -//////////////////////////////////////////////////////////////////// -INLINE void FindApproxLevelEntry:: -operator delete(void *ptr) { - FindApproxLevelEntry *obj = (FindApproxLevelEntry *)ptr; - obj->_next = _deleted_chain; - _deleted_chain = obj; -} - -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::get_num_ever_allocated -// Access: Published, Static -// Description: Returns the number of FindApproxLevelEntry pointers -// ever simultaneously allocated; these are now either -// in active use or have been recycled into the deleted -// FindApproxLevelEntry pool to be used again. -//////////////////////////////////////////////////////////////////// -INLINE int FindApproxLevelEntry:: -get_num_ever_allocated() { - return _num_ever_allocated; -} diff --git a/panda/src/pgraph/findApproxLevelEntry.cxx b/panda/src/pgraph/findApproxLevelEntry.cxx index ac49608040..3f9b465d8b 100644 --- a/panda/src/pgraph/findApproxLevelEntry.cxx +++ b/panda/src/pgraph/findApproxLevelEntry.cxx @@ -21,10 +21,6 @@ #include "pandaNode.h" #include "indent.h" -FindApproxLevelEntry *FindApproxLevelEntry::_deleted_chain = (FindApproxLevelEntry *)NULL; -int FindApproxLevelEntry::_num_ever_allocated = 0; - - //////////////////////////////////////////////////////////////////// // Function: FindApproxLevelEntry::output // Access: Public diff --git a/panda/src/pgraph/findApproxLevelEntry.h b/panda/src/pgraph/findApproxLevelEntry.h index f11dd225d0..a23a8d46a1 100644 --- a/panda/src/pgraph/findApproxLevelEntry.h +++ b/panda/src/pgraph/findApproxLevelEntry.h @@ -42,6 +42,7 @@ public: FindApproxLevelEntry *next); INLINE FindApproxLevelEntry(const FindApproxLevelEntry ©); INLINE void operator = (const FindApproxLevelEntry ©); + ALLOC_DELETED_CHAIN(FindApproxLevelEntry); INLINE bool next_is_stashed(int increment) const; @@ -53,15 +54,6 @@ public: int increment) const; INLINE bool is_solution(int increment) const; - // We will allocate and destroy thousands of these during a typical - // NodePath::find() or find_all_matches() operation. As an - // optimization, then, we implement operator new and delete here to - // minimize this overhead. - INLINE void *operator new(size_t size); - INLINE void operator delete(void *ptr); - - INLINE static int get_num_ever_allocated(); - void output(ostream &out) const; void write_level(ostream &out, int indent_level) const; @@ -76,10 +68,6 @@ public: int _i; FindApproxPath &_approx_path; FindApproxLevelEntry *_next; - -private: - static FindApproxLevelEntry *_deleted_chain; - static int _num_ever_allocated; }; INLINE ostream & diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 5aa272cbf1..f72b9dea4b 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -24,6 +24,7 @@ #include "colorAttrib.h" #include "colorScaleAttrib.h" #include "texMatrixAttrib.h" +#include "textureAttrib.h" #include "bamReader.h" #include "bamWriter.h" #include "datagram.h" diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index a2b655e493..718a80070c 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -30,6 +30,7 @@ #include "cycleDataStageReader.h" #include "cycleDataStageWriter.h" #include "pmutex.h" +#include "deletedChain.h" //////////////////////////////////////////////////////////////////// // Class : NodePathComponent @@ -56,6 +57,7 @@ private: public: INLINE ~NodePathComponent(); + ALLOC_DELETED_CHAIN(NodePathComponent); INLINE PandaNode *get_node() const; INLINE bool has_key() const; @@ -85,6 +87,7 @@ private: public: INLINE CData(); CData(const CData ©); + ALLOC_DELETED_CHAIN(CData); virtual CycleData *make_copy() const; virtual TypeHandle get_parent_type() const { return NodePathComponent::get_class_type(); diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 887fdfac1e..474f75e12e 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -42,6 +42,7 @@ #include "pointerToArray.h" #include "pnotify.h" #include "updateSeq.h" +#include "deletedChain.h" #ifdef HAVE_PYTHON @@ -373,6 +374,7 @@ private: INLINE CDataLight(); CDataLight(const CDataLight ©); virtual ~CDataLight(); + ALLOC_DELETED_CHAIN(CDataLight); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; @@ -400,6 +402,7 @@ private: INLINE CDataHeavy(); CDataHeavy(const CDataHeavy ©); virtual ~CDataHeavy(); + ALLOC_DELETED_CHAIN(CDataHeavy); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; @@ -462,6 +465,7 @@ private: INLINE CDataBounds(); CDataBounds(const CDataBounds ©); virtual ~CDataBounds(); + ALLOC_DELETED_CHAIN(CDataBounds); virtual CycleData *make_copy() const; virtual TypeHandle get_parent_type() const { @@ -502,6 +506,7 @@ private: INLINE CDataLinks(); CDataLinks(const CDataLinks ©); virtual ~CDataLinks(); + ALLOC_DELETED_CHAIN(CDataLinks); virtual CycleData *make_copy() const; virtual void write_datagram(BamWriter *manager, Datagram &dg) const; diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 2c18c23fa7..f2dbc713b3 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -263,6 +263,12 @@ return_new(RenderAttrib *attrib) { // for anything else. nassertr(attrib->_saved_entry == _attribs->end(), attrib); +#ifndef NDEBUG + if (!state_cache) { + return attrib; + } +#endif + #ifndef NDEBUG if (paranoid_const) { nassertr(validate_attribs(), attrib); diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index fba5d5680f..bfd53d8092 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -566,6 +566,12 @@ CPT(RenderEffects) RenderEffects:: return_new(RenderEffects *state) { nassertr(state != (RenderEffects *)NULL, state); +#ifndef NDEBUG + if (!state_cache) { + return state; + } +#endif + #ifndef NDEBUG if (paranoid_const) { nassertr(validate_states(), state); diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index d471e9d48b..a4ba8f431a 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -83,15 +83,14 @@ has_cull_callback() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int RenderState:: +INLINE void RenderState:: cache_ref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::cache_ref(); + NodeCachedReferenceCount::cache_ref(); consider_update_pstats(old_referenced_bits); - return result; #else // DO_PSTATS - return NodeCachedReferenceCount::cache_ref(); + NodeCachedReferenceCount::cache_ref(); #endif // DO_PSTATS } @@ -100,11 +99,11 @@ cache_ref() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int RenderState:: +INLINE bool RenderState:: cache_unref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::cache_unref(); + bool result = NodeCachedReferenceCount::cache_unref(); consider_update_pstats(old_referenced_bits); return result; #else // DO_PSTATS @@ -117,15 +116,14 @@ cache_unref() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int RenderState:: +INLINE void RenderState:: node_ref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::node_ref(); + NodeCachedReferenceCount::node_ref(); consider_update_pstats(old_referenced_bits); - return result; #else // DO_PSTATS - return NodeCachedReferenceCount::node_ref(); + NodeCachedReferenceCount::node_ref(); #endif // DO_PSTATS } @@ -134,11 +132,11 @@ node_ref() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int RenderState:: +INLINE bool RenderState:: node_unref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::node_unref(); + bool result = NodeCachedReferenceCount::node_unref(); consider_update_pstats(old_referenced_bits); return result; #else // DO_PSTATS @@ -433,10 +431,12 @@ is_destructing() const { //////////////////////////////////////////////////////////////////// INLINE void RenderState:: consider_update_pstats(int old_referenced_bits) const { +#ifdef DO_PSTATS int new_referenced_bits = get_referenced_bits(); if (old_referenced_bits != new_referenced_bits) { update_pstats(old_referenced_bits, new_referenced_bits); } +#endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index ad9ea01b72..1b8dd8601c 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -37,6 +37,7 @@ #include "compareTo.h" #include "reMutexHolder.h" #include "thread.h" +#include "attribSlots.h" ReMutex *RenderState::_states_lock = NULL; RenderState::States *RenderState::_states = NULL; @@ -318,6 +319,12 @@ compose(const RenderState *other) const { return this; } +#ifndef NDEBUG + if (!state_cache) { + return do_compose(other); + } +#endif // NDEBUG + ReMutexHolder holder(*_states_lock); // Is this composition already cached? @@ -398,6 +405,12 @@ invert_compose(const RenderState *other) const { return make_empty(); } +#ifndef NDEBUG + if (!state_cache) { + return do_invert_compose(other); + } +#endif // NDEBUG + ReMutexHolder holder(*_states_lock); // Is this composition already cached? @@ -591,7 +604,7 @@ get_override(TypeHandle type) const { // PT(TransformState) is a template class, and will call // the appropriate method even though it is non-virtual. //////////////////////////////////////////////////////////////////// -int RenderState:: +bool RenderState:: unref() const { ReMutexHolder holder(*_states_lock); @@ -1058,6 +1071,12 @@ CPT(RenderState) RenderState:: return_new(RenderState *state) { nassertr(state != (RenderState *)NULL, state); +#ifndef NDEBUG + if (!state_cache) { + return state; + } +#endif + #ifndef NDEBUG if (paranoid_const) { nassertr(validate_states(), state); @@ -1644,6 +1663,7 @@ determine_cull_callback() { //////////////////////////////////////////////////////////////////// void RenderState:: update_pstats(int old_referenced_bits, int new_referenced_bits) { +#ifdef DO_PSTATS if ((old_referenced_bits & R_node) != 0) { _node_counter.sub_level(1); } else if ((old_referenced_bits & R_cache) != 0) { @@ -1654,6 +1674,7 @@ update_pstats(int old_referenced_bits, int new_referenced_bits) { } else if ((new_referenced_bits & R_cache) != 0) { _cache_counter.add_level(1); } +#endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 3ff2b0c5bb..59dddba010 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -33,6 +33,7 @@ #include "weakPointerTo.h" #include "shaderExpansion.h" #include "reMutex.h" +#include "deletedChain.h" class GraphicsStateGuardianBase; class FogAttrib; @@ -68,6 +69,7 @@ private: public: virtual ~RenderState(); + ALLOC_DELETED_CHAIN(RenderState); PUBLISHED: bool operator < (const RenderState &other) const; @@ -108,12 +110,12 @@ PUBLISHED: const RenderAttrib *get_attrib(TypeHandle type) const; int get_override(TypeHandle type) const; - int unref() const; + bool unref() const; - INLINE int cache_ref() const; - INLINE int cache_unref() const; - INLINE int node_ref() const; - INLINE int node_unref() const; + INLINE void cache_ref() const; + INLINE bool cache_unref() const; + INLINE void node_ref() const; + INLINE bool node_unref() const; void output(ostream &out) const; void write(ostream &out, int indent_level) const; diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index ea180fab7c..b54407b213 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -24,6 +24,7 @@ #include "pointerTo.h" #include "plist.h" #include "pmap.h" +#include "geomNode.h" PStatCollector SceneGraphReducer::_flatten_collector("*:Flatten:flatten"); PStatCollector SceneGraphReducer::_apply_collector("*:Flatten:apply"); diff --git a/panda/src/pgraph/shader.h b/panda/src/pgraph/shader.h index 0fae0ac19a..6bf10ea0e9 100644 --- a/panda/src/pgraph/shader.h +++ b/panda/src/pgraph/shader.h @@ -21,10 +21,11 @@ #include "pandabase.h" #include "typedWritableReferenceCount.h" +#include "shaderExpansion.h" #include "pointerTo.h" #include "dcast.h" -class ShaderExpansion; +class RenderState; //////////////////////////////////////////////////////////////////// // Class : Shader diff --git a/panda/src/pgraph/shaderInput.h b/panda/src/pgraph/shaderInput.h index a0a258f71f..c2abf52ff8 100644 --- a/panda/src/pgraph/shaderInput.h +++ b/panda/src/pgraph/shaderInput.h @@ -23,6 +23,8 @@ #include "typedWritableReferenceCount.h" #include "pointerTo.h" #include "nodePath.h" +#include "texture.h" +#include "internalName.h" //////////////////////////////////////////////////////////////////// // Class : ShaderInput diff --git a/panda/src/pgraph/transformState.I b/panda/src/pgraph/transformState.I index 8441edafcc..11df5bbb08 100644 --- a/panda/src/pgraph/transformState.I +++ b/panda/src/pgraph/transformState.I @@ -679,15 +679,14 @@ get_geom_rendering(int geom_rendering) const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int TransformState:: +INLINE void TransformState:: cache_ref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::cache_ref(); + NodeCachedReferenceCount::cache_ref(); consider_update_pstats(old_referenced_bits); - return result; #else // DO_PSTATS - return NodeCachedReferenceCount::cache_ref(); + NodeCachedReferenceCount::cache_ref(); #endif // DO_PSTATS } @@ -696,11 +695,11 @@ cache_ref() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int TransformState:: +INLINE bool TransformState:: cache_unref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::cache_unref(); + bool result = NodeCachedReferenceCount::cache_unref(); consider_update_pstats(old_referenced_bits); return result; #else // DO_PSTATS @@ -713,15 +712,14 @@ cache_unref() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int TransformState:: +INLINE void TransformState:: node_ref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::node_ref(); + NodeCachedReferenceCount::node_ref(); consider_update_pstats(old_referenced_bits); - return result; #else // DO_PSTATS - return NodeCachedReferenceCount::node_ref(); + NodeCachedReferenceCount::node_ref(); #endif // DO_PSTATS } @@ -730,11 +728,11 @@ node_ref() const { // Access: Published // Description: Overrides this method to update PStats appropriately. //////////////////////////////////////////////////////////////////// -INLINE int TransformState:: +INLINE bool TransformState:: node_unref() const { #ifdef DO_PSTATS int old_referenced_bits = get_referenced_bits(); - int result = NodeCachedReferenceCount::node_unref(); + bool result = NodeCachedReferenceCount::node_unref(); consider_update_pstats(old_referenced_bits); return result; #else // DO_PSTATS @@ -903,10 +901,12 @@ is_destructing() const { //////////////////////////////////////////////////////////////////// INLINE void TransformState:: consider_update_pstats(int old_referenced_bits) const { +#ifdef DO_PSTATS int new_referenced_bits = get_referenced_bits(); if (old_referenced_bits != new_referenced_bits) { update_pstats(old_referenced_bits, new_referenced_bits); } +#endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index 40432c8824..ef3760a9a9 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -636,6 +636,12 @@ compose(const TransformState *other) const { return other; } +#ifndef NDEBUG + if (!transform_cache) { + return do_compose(other); + } +#endif // NDEBUG + ReMutexHolder holder(*_states_lock); // Is this composition already cached? @@ -724,6 +730,12 @@ invert_compose(const TransformState *other) const { return make_identity(); } +#ifndef NDEBUG + if (!transform_cache) { + return do_invert_compose(other); + } +#endif // NDEBUG + ReMutexHolder holder(*_states_lock); // Is this composition already cached? @@ -791,7 +803,7 @@ invert_compose(const TransformState *other) const { // PT(TransformState) is a template class, and will call // the appropriate method even though it is non-virtual. //////////////////////////////////////////////////////////////////// -int TransformState:: +bool TransformState:: unref() const { ReMutexHolder holder(*_states_lock); @@ -1282,6 +1294,12 @@ CPT(TransformState) TransformState:: return_new(TransformState *state) { nassertr(state != (TransformState *)NULL, state); +#ifndef NDEBUG + if (!transform_cache) { + return state; + } +#endif + #ifndef NDEBUG if (paranoid_const) { nassertr(validate_states(), state); @@ -1837,6 +1855,7 @@ calc_mat() { //////////////////////////////////////////////////////////////////// void TransformState:: update_pstats(int old_referenced_bits, int new_referenced_bits) { +#ifdef DO_PSTATS if ((old_referenced_bits & R_node) != 0) { _node_counter.sub_level(1); } else if ((old_referenced_bits & R_cache) != 0) { @@ -1847,6 +1866,7 @@ update_pstats(int old_referenced_bits, int new_referenced_bits) { } else if ((new_referenced_bits & R_cache) != 0) { _cache_counter.add_level(1); } +#endif // DO_PSTATS } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 453536ecba..8d9073fd10 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -31,6 +31,7 @@ #include "geomEnums.h" #include "reMutex.h" #include "config_pgraph.h" +#include "deletedChain.h" class GraphicsStateGuardianBase; class FactoryParams; @@ -67,6 +68,7 @@ private: public: virtual ~TransformState(); + ALLOC_DELETED_CHAIN(TransformState); PUBLISHED: INLINE bool operator < (const TransformState &other) const; @@ -168,12 +170,12 @@ PUBLISHED: INLINE int get_geom_rendering(int geom_rendering) const; - int unref() const; + bool unref() const; - INLINE int cache_ref() const; - INLINE int cache_unref() const; - INLINE int node_ref() const; - INLINE int node_unref() const; + INLINE void cache_ref() const; + INLINE bool cache_unref() const; + INLINE void node_ref() const; + INLINE bool node_unref() const; void output(ostream &out) const; void write(ostream &out, int indent_level) const; diff --git a/panda/src/pgui/pgButton.cxx b/panda/src/pgui/pgButton.cxx index 96d5cfa499..f936e03a29 100644 --- a/panda/src/pgui/pgButton.cxx +++ b/panda/src/pgui/pgButton.cxx @@ -76,31 +76,31 @@ make_copy() const { } //////////////////////////////////////////////////////////////////// -// Function: PGButton::enter +// Function: PGButton::enter_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse enters the region. //////////////////////////////////////////////////////////////////// void PGButton:: -enter(const MouseWatcherParameter ¶m) { +enter_region(const MouseWatcherParameter ¶m) { if (get_active()) { set_state(_button_down ? S_depressed : S_rollover); } - PGItem::enter(param); + PGItem::enter_region(param); } //////////////////////////////////////////////////////////////////// -// Function: PGButton::exit +// Function: PGButton::exit_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse exits the region. //////////////////////////////////////////////////////////////////// void PGButton:: -exit(const MouseWatcherParameter ¶m) { +exit_region(const MouseWatcherParameter ¶m) { if (get_active()) { set_state(S_ready); } - PGItem::exit(param); + PGItem::exit_region(param); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgui/pgButton.h b/panda/src/pgui/pgButton.h index dc818ea674..07e5dda20f 100644 --- a/panda/src/pgui/pgButton.h +++ b/panda/src/pgui/pgButton.h @@ -44,8 +44,8 @@ protected: public: virtual PandaNode *make_copy() const; - virtual void enter(const MouseWatcherParameter ¶m); - virtual void exit(const MouseWatcherParameter ¶m); + virtual void enter_region(const MouseWatcherParameter ¶m); + virtual void exit_region(const MouseWatcherParameter ¶m); virtual void press(const MouseWatcherParameter ¶m, bool background); virtual void release(const MouseWatcherParameter ¶m, bool background); diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index a28fe4b6d6..42386c4c25 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -420,7 +420,7 @@ activate_region(const LMatrix4f &transform, int sort, } //////////////////////////////////////////////////////////////////// -// Function: PGItem::enter +// Function: PGItem::enter_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse enters the region. The mouse is only @@ -429,7 +429,7 @@ activate_region(const LMatrix4f &transform, int sort, // region before entering the inner one. //////////////////////////////////////////////////////////////////// void PGItem:: -enter(const MouseWatcherParameter ¶m) { +enter_region(const MouseWatcherParameter ¶m) { PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_enter_event(); play_sound(event); @@ -443,7 +443,7 @@ enter(const MouseWatcherParameter ¶m) { } //////////////////////////////////////////////////////////////////// -// Function: PGItem::exit +// Function: PGItem::exit_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse exits the region. The mouse is only considered @@ -452,7 +452,7 @@ enter(const MouseWatcherParameter ¶m) { // entering the inner one. //////////////////////////////////////////////////////////////////// void PGItem:: -exit(const MouseWatcherParameter ¶m) { +exit_region(const MouseWatcherParameter ¶m) { PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_exit_event(); play_sound(event); @@ -466,7 +466,7 @@ exit(const MouseWatcherParameter ¶m) { } //////////////////////////////////////////////////////////////////// -// Function: PGItem::within +// Function: PGItem::within_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse moves within the boundaries of the region, even @@ -476,7 +476,7 @@ exit(const MouseWatcherParameter ¶m) { // region. //////////////////////////////////////////////////////////////////// void PGItem:: -within(const MouseWatcherParameter ¶m) { +within_region(const MouseWatcherParameter ¶m) { PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_within_event(); play_sound(event); @@ -490,14 +490,14 @@ within(const MouseWatcherParameter ¶m) { } //////////////////////////////////////////////////////////////////// -// Function: PGItem::without +// Function: PGItem::without_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse moves completely outside the boundaries of the // region. See within(). //////////////////////////////////////////////////////////////////// void PGItem:: -without(const MouseWatcherParameter ¶m) { +without_region(const MouseWatcherParameter ¶m) { PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_without_event(); play_sound(event); diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index 2a753ebf79..0507399ee3 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -77,10 +77,10 @@ public: const ClipPlaneAttrib *cpa); INLINE PGMouseWatcherRegion *get_region() const; - virtual void enter(const MouseWatcherParameter ¶m); - virtual void exit(const MouseWatcherParameter ¶m); - virtual void within(const MouseWatcherParameter ¶m); - virtual void without(const MouseWatcherParameter ¶m); + virtual void enter_region(const MouseWatcherParameter ¶m); + virtual void exit_region(const MouseWatcherParameter ¶m); + virtual void within_region(const MouseWatcherParameter ¶m); + virtual void without_region(const MouseWatcherParameter ¶m); virtual void focus_in(); virtual void focus_out(); virtual void press(const MouseWatcherParameter ¶m, bool background); diff --git a/panda/src/pgui/pgItemNotify.cxx b/panda/src/pgui/pgItemNotify.cxx index 2dd959622f..e4522904c6 100644 --- a/panda/src/pgui/pgItemNotify.cxx +++ b/panda/src/pgui/pgItemNotify.cxx @@ -69,7 +69,7 @@ item_draw_mask_changed(PGItem *) { // Function: PGItemNotify::item_enter // Access: Protected, Virtual // Description: Called whenever the "enter" event is triggered on a -// watched PGItem. See PGItem::enter(). +// watched PGItem. See PGItem::enter_region(). //////////////////////////////////////////////////////////////////// void PGItemNotify:: item_enter(PGItem *, const MouseWatcherParameter &) { @@ -79,7 +79,7 @@ item_enter(PGItem *, const MouseWatcherParameter &) { // Function: PGItemNotify::item_exit // Access: Protected, Virtual // Description: Called whenever the "exit" event is triggered on a -// watched PGItem. See PGItem::exit(). +// watched PGItem. See PGItem::exit_region(). //////////////////////////////////////////////////////////////////// void PGItemNotify:: item_exit(PGItem *, const MouseWatcherParameter &) { @@ -89,7 +89,7 @@ item_exit(PGItem *, const MouseWatcherParameter &) { // Function: PGItemNotify::item_within // Access: Protected, Virtual // Description: Called whenever the "within" event is triggered on a -// watched PGItem. See PGItem::within(). +// watched PGItem. See PGItem::within_region(). //////////////////////////////////////////////////////////////////// void PGItemNotify:: item_within(PGItem *, const MouseWatcherParameter &) { @@ -99,7 +99,7 @@ item_within(PGItem *, const MouseWatcherParameter &) { // Function: PGItemNotify::item_without // Access: Protected, Virtual // Description: Called whenever the "without" event is triggered on a -// watched PGItem. See PGItem::without(). +// watched PGItem. See PGItem::without_region(). //////////////////////////////////////////////////////////////////// void PGItemNotify:: item_without(PGItem *, const MouseWatcherParameter &) { diff --git a/panda/src/pgui/pgItemNotify.h b/panda/src/pgui/pgItemNotify.h index 89883601e9..2b3445bac3 100644 --- a/panda/src/pgui/pgItemNotify.h +++ b/panda/src/pgui/pgItemNotify.h @@ -20,8 +20,10 @@ #define PGITEMNOTIFY_H #include "pandabase.h" +#include "pset.h" class PGItem; +class MouseWatcherParameter; //////////////////////////////////////////////////////////////////// // Class : PGItemNotify diff --git a/panda/src/pgui/pgMouseWatcherRegion.cxx b/panda/src/pgui/pgMouseWatcherRegion.cxx index c984bf9c87..37eac11188 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.cxx +++ b/panda/src/pgui/pgMouseWatcherRegion.cxx @@ -49,7 +49,7 @@ PGMouseWatcherRegion:: //////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::enter +// Function: PGMouseWatcherRegion::enter_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse enters the region. The mouse is only @@ -58,14 +58,14 @@ PGMouseWatcherRegion:: // region before entering the inner one. //////////////////////////////////////////////////////////////////// void PGMouseWatcherRegion:: -enter(const MouseWatcherParameter ¶m) { +enter_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { - _item->enter(param); + _item->enter_region(param); } } //////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::exit +// Function: PGMouseWatcherRegion::exit_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse exits the region. The mouse is only considered @@ -74,14 +74,14 @@ enter(const MouseWatcherParameter ¶m) { // entering the inner one. //////////////////////////////////////////////////////////////////// void PGMouseWatcherRegion:: -exit(const MouseWatcherParameter ¶m) { +exit_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { - _item->exit(param); + _item->exit_region(param); } } //////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::within +// Function: PGMouseWatcherRegion::within_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse moves within the boundaries of the region, even @@ -91,23 +91,23 @@ exit(const MouseWatcherParameter ¶m) { // region. //////////////////////////////////////////////////////////////////// void PGMouseWatcherRegion:: -within(const MouseWatcherParameter ¶m) { +within_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { - _item->within(param); + _item->within_region(param); } } //////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::without +// Function: PGMouseWatcherRegion::without_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse moves completely outside the boundaries of the -// region. See within(). +// region. See within_region(). //////////////////////////////////////////////////////////////////// void PGMouseWatcherRegion:: -without(const MouseWatcherParameter ¶m) { +without_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { - _item->without(param); + _item->without_region(param); } } diff --git a/panda/src/pgui/pgMouseWatcherRegion.h b/panda/src/pgui/pgMouseWatcherRegion.h index 6f84005537..f2518ee661 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.h +++ b/panda/src/pgui/pgMouseWatcherRegion.h @@ -37,10 +37,10 @@ public: PGMouseWatcherRegion(PGItem *item); virtual ~PGMouseWatcherRegion(); - virtual void enter(const MouseWatcherParameter ¶m); - virtual void exit(const MouseWatcherParameter ¶m); - virtual void within(const MouseWatcherParameter ¶m); - virtual void without(const MouseWatcherParameter ¶m); + virtual void enter_region(const MouseWatcherParameter ¶m); + virtual void exit_region(const MouseWatcherParameter ¶m); + virtual void within_region(const MouseWatcherParameter ¶m); + virtual void without_region(const MouseWatcherParameter ¶m); virtual void press(const MouseWatcherParameter ¶m); virtual void release(const MouseWatcherParameter ¶m); virtual void keystroke(const MouseWatcherParameter ¶m); diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 73aa0aeb65..4ca5f5e00d 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -82,7 +82,7 @@ child_integrate(Physical *physical, // global forces f_cur = forces.begin(); - unsigned int index = 0; + // unsigned int index = 0; for (; f_cur != forces.end(); ++f_cur) { AngularForce *cur_force = *f_cur; diff --git a/panda/src/physics/linearFrictionForce.cxx b/panda/src/physics/linearFrictionForce.cxx index 2735f072ce..52cf3bccb8 100644 --- a/panda/src/physics/linearFrictionForce.cxx +++ b/panda/src/physics/linearFrictionForce.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "linearFrictionForce.h" +#include "config_physics.h" TypeHandle LinearFrictionForce::_type_handle; diff --git a/panda/src/physics/physicsCollisionHandler.cxx b/panda/src/physics/physicsCollisionHandler.cxx index 440d2044d7..0b155c4667 100755 --- a/panda/src/physics/physicsCollisionHandler.cxx +++ b/panda/src/physics/physicsCollisionHandler.cxx @@ -21,6 +21,8 @@ #include "collisionEntry.h" #include "collisionPolygon.h" #include "config_collide.h" +#include "config_physics.h" +#include "actorNode.h" #include "dcast.h" TypeHandle PhysicsCollisionHandler::_type_handle; diff --git a/panda/src/pipeline/Sources.pp b/panda/src/pipeline/Sources.pp index 90027aac56..11fda8a9da 100644 --- a/panda/src/pipeline/Sources.pp +++ b/panda/src/pipeline/Sources.pp @@ -2,6 +2,8 @@ #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m prc:c +#define SELECT_TAU select.tau + #begin lib_target #define TARGET pipeline @@ -14,6 +16,7 @@ conditionVarDummyImpl.h conditionVarDummyImpl.I \ conditionVarImpl.h \ conditionVarNsprImpl.h conditionVarNsprImpl.I \ + conditionVarLinuxImpl.h conditionVarLinuxImpl.I \ conditionVarPosixImpl.h conditionVarPosixImpl.I \ conditionVarWin32Impl.h conditionVarWin32Impl.I \ config_pipeline.h \ @@ -41,6 +44,7 @@ reMutexHolder.I reMutexHolder.h \ threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ threadNsprImpl.h threadNsprImpl.I \ + threadLinuxImpl.h threadLinuxImpl.I \ threadPosixImpl.h threadPosixImpl.I \ threadWin32Impl.h threadWin32Impl.I \ threadPriority.h @@ -51,6 +55,7 @@ conditionVarDirect.cxx \ conditionVarDummyImpl.cxx \ conditionVarNsprImpl.cxx \ + conditionVarLinuxImpl.cxx \ conditionVarPosixImpl.cxx \ conditionVarWin32Impl.cxx \ config_pipeline.cxx \ @@ -76,6 +81,7 @@ reMutexHolder.cxx \ thread.cxx threadDummyImpl.cxx \ threadNsprImpl.cxx \ + threadLinuxImpl.cxx \ threadPosixImpl.cxx \ threadWin32Impl.cxx @@ -86,6 +92,7 @@ conditionVarDummyImpl.h conditionVarDummyImpl.I \ conditionVarImpl.h \ conditionVarNsprImpl.h conditionVarNsprImpl.I \ + conditionVarLinuxImpl.h conditionVarLinuxImpl.I \ conditionVarPosixImpl.h conditionVarPosixImpl.I \ conditionVarWin32Impl.h conditionVarWin32Impl.I \ config_pipeline.h \ @@ -113,6 +120,7 @@ reMutexHolder.I reMutexHolder.h \ threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ threadNsprImpl.h threadNsprImpl.I \ + threadLinuxImpl.h threadLinuxImpl.I \ threadPosixImpl.h threadPosixImpl.I \ threadWin32Impl.h threadWin32Impl.I \ threadPriority.h @@ -124,7 +132,7 @@ #begin test_bin_target #define TARGET test_threaddata - #define LOCAL_LIBS $[LOCAL_LIBS] express + #define LOCAL_LIBS $[LOCAL_LIBS] pipeline #define OTHER_LIBS dtoolutil:c dtool:m pystub #define SOURCES \ @@ -135,7 +143,7 @@ #begin test_bin_target #define TARGET test_diners - #define LOCAL_LIBS $[LOCAL_LIBS] express + #define LOCAL_LIBS $[LOCAL_LIBS] pipeline #define OTHER_LIBS dtoolutil:c dtool:m dtoolconfig:m pystub #define SOURCES \ @@ -143,3 +151,14 @@ #end test_bin_target + +#begin test_bin_target + #define TARGET test_mutex + #define LOCAL_LIBS $[LOCAL_LIBS] pipeline + #define OTHER_LIBS dtoolutil:c dtool:m dtoolconfig:m pystub + + #define SOURCES \ + test_mutex.cxx + +#end test_bin_target + diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index edab6a9754..b80ebb5035 100755 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -18,6 +18,7 @@ #include "conditionVarDebug.h" #include "thread.h" +#include "config_pipeline.h" #ifdef DEBUG_THREADS @@ -85,11 +86,21 @@ wait() { _mutex._global_mutex.release(); return; } + + if (thread_cat.is_spam()) { + thread_cat.spam() + << *Thread::get_current_thread() << " waiting on " << *this << "\n"; + } _mutex.do_release(); _impl.wait(); _mutex.do_lock(); + if (thread_cat.is_spam()) { + thread_cat.spam() + << *Thread::get_current_thread() << " awake on " << *this << "\n"; + } + _mutex._global_mutex.release(); } @@ -121,6 +132,11 @@ signal() { return; } + if (thread_cat.is_spam()) { + thread_cat.spam() + << *Thread::get_current_thread() << " signalling " << *this << "\n"; + } + _impl.signal(); _mutex._global_mutex.release(); } @@ -133,7 +149,7 @@ signal() { //////////////////////////////////////////////////////////////////// void ConditionVarDebug:: output(ostream &out) const { - out << "ConditionVar " << (void *)this; + out << "ConditionVar " << (void *)this << " on " << _mutex; } #endif // DEBUG_THREADS diff --git a/panda/src/pipeline/conditionVarDirect.I b/panda/src/pipeline/conditionVarDirect.I index d2e4532612..75c3d30cad 100755 --- a/panda/src/pipeline/conditionVarDirect.I +++ b/panda/src/pipeline/conditionVarDirect.I @@ -104,6 +104,7 @@ get_mutex() const { //////////////////////////////////////////////////////////////////// INLINE void ConditionVarDirect:: wait() { + TAU_PROFILE("ConditionVarDirect::wait()", " ", TAU_USER); _impl.wait(); } @@ -125,5 +126,6 @@ wait() { //////////////////////////////////////////////////////////////////// INLINE void ConditionVarDirect:: signal() { + TAU_PROFILE("ConditionVarDirect::signal()", " ", TAU_USER); _impl.signal(); } diff --git a/panda/src/pipeline/conditionVarDirect.cxx b/panda/src/pipeline/conditionVarDirect.cxx index a5198522e1..d0b5f3722e 100755 --- a/panda/src/pipeline/conditionVarDirect.cxx +++ b/panda/src/pipeline/conditionVarDirect.cxx @@ -28,7 +28,7 @@ //////////////////////////////////////////////////////////////////// void ConditionVarDirect:: output(ostream &out) const { - out << "ConditionVar " << (void *)this; + out << "ConditionVar " << (void *)this << " on " << _mutex; } #endif // !DEBUG_THREADS diff --git a/panda/src/pipeline/conditionVarImpl.h b/panda/src/pipeline/conditionVarImpl.h index fb449f552d..9c35a530f5 100644 --- a/panda/src/pipeline/conditionVarImpl.h +++ b/panda/src/pipeline/conditionVarImpl.h @@ -32,6 +32,11 @@ typedef ConditionVarDummyImpl ConditionVarImpl; #include "conditionVarWin32Impl.h" typedef ConditionVarWin32Impl ConditionVarImpl; +#elif defined(THREAD_LINUX_IMPL) + +#include "conditionVarLinuxImpl.h" +typedef ConditionVarLinuxImpl ConditionVarImpl; + #elif defined(THREAD_POSIX_IMPL) #include "conditionVarPosixImpl.h" diff --git a/panda/src/pipeline/conditionVarLinuxImpl.I b/panda/src/pipeline/conditionVarLinuxImpl.I new file mode 100644 index 0000000000..0c1dd28c7c --- /dev/null +++ b/panda/src/pipeline/conditionVarLinuxImpl.I @@ -0,0 +1,39 @@ +// Filename: conditionVarLinuxImpl.I +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: ConditionVarLinuxImpl::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ConditionVarLinuxImpl:: +ConditionVarLinuxImpl(MutexLinuxImpl &mutex) : + _mutex(mutex) +{ + _counter = 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: ConditionVarLinuxImpl::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ConditionVarLinuxImpl:: +~ConditionVarLinuxImpl() { +} diff --git a/panda/src/pipeline/conditionVarLinuxImpl.cxx b/panda/src/pipeline/conditionVarLinuxImpl.cxx new file mode 100644 index 0000000000..6c1a594aba --- /dev/null +++ b/panda/src/pipeline/conditionVarLinuxImpl.cxx @@ -0,0 +1,55 @@ +// Filename: conditionVarLinuxImpl.cxx +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "selectThreadImpl.h" + +#ifdef THREAD_LINUX_IMPL + +#include "conditionVarLinuxImpl.h" + +#include +#include +#include + +//////////////////////////////////////////////////////////////////// +// Function: ConditionVarLinuxImpl::wait +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void ConditionVarLinuxImpl:: +wait() { + // Grab the current value of the counter before we release the + // mutex. + PN_int32 orig_counter = _counter; + _mutex.release(); + syscall(SYS_futex, &_counter, FUTEX_WAIT, orig_counter, (void *)NULL); + _mutex.lock(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ConditionVarLinuxImpl::signal +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void ConditionVarLinuxImpl:: +signal() { + AtomicAdjust::inc(_counter); + syscall(SYS_futex, &_counter, FUTEX_WAKE, 1); +} + +#endif // THREAD_LINUX_IMPL diff --git a/panda/src/pipeline/conditionVarLinuxImpl.h b/panda/src/pipeline/conditionVarLinuxImpl.h new file mode 100644 index 0000000000..cbc3fcdbaa --- /dev/null +++ b/panda/src/pipeline/conditionVarLinuxImpl.h @@ -0,0 +1,53 @@ +// Filename: conditionVarLinuxImpl.h +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef CONDITIONVARLINUXIMPL_H +#define CONDITIONVARLINUXIMPL_H + +#include "pandabase.h" +#include "selectThreadImpl.h" + +#ifdef THREAD_LINUX_IMPL + +#include "mutexLinuxImpl.h" +#include "pnotify.h" + +class MutexLinuxImpl; + +//////////////////////////////////////////////////////////////////// +// Class : ConditionVarLinuxImpl +// Description : Uses Linux threads to implement a conditionVar. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA ConditionVarLinuxImpl { +public: + INLINE ConditionVarLinuxImpl(MutexLinuxImpl &mutex); + INLINE ~ConditionVarLinuxImpl(); + + void wait(); + void signal(); + +private: + MutexLinuxImpl &_mutex; + PN_int32 _counter; +}; + +#include "conditionVarLinuxImpl.I" + +#endif // THREAD_LINUX_IMPL + +#endif diff --git a/panda/src/pipeline/conditionVarPosixImpl.I b/panda/src/pipeline/conditionVarPosixImpl.I index a7171b60c4..ff9006bf63 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.I +++ b/panda/src/pipeline/conditionVarPosixImpl.I @@ -26,6 +26,7 @@ INLINE ConditionVarPosixImpl:: ConditionVarPosixImpl(MutexPosixImpl &mutex) : _mutex(mutex) { + TAU_PROFILE("ConditionVarPosixImpl::ConditionVarPosixImpl()", " ", TAU_USER); int result = pthread_cond_init(&_cvar, NULL); nassertv(result == 0); } @@ -37,6 +38,7 @@ ConditionVarPosixImpl(MutexPosixImpl &mutex) : //////////////////////////////////////////////////////////////////// INLINE ConditionVarPosixImpl:: ~ConditionVarPosixImpl() { + TAU_PROFILE("ConditionVarPosixImpl::~ConditionVarPosixImpl()", " ", TAU_USER); int result = pthread_cond_destroy(&_cvar); nassertv(result == 0); } @@ -48,6 +50,7 @@ INLINE ConditionVarPosixImpl:: //////////////////////////////////////////////////////////////////// INLINE void ConditionVarPosixImpl:: wait() { + TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER); int result = pthread_cond_wait(&_cvar, &_mutex._lock); nassertv(result == 0); } @@ -59,6 +62,7 @@ wait() { //////////////////////////////////////////////////////////////////// INLINE void ConditionVarPosixImpl:: signal() { + TAU_PROFILE("ConditionVarPosixImpl::signal()", " ", TAU_USER); int result = pthread_cond_signal(&_cvar); nassertv(result == 0); } diff --git a/panda/src/pipeline/conditionVarPosixImpl.cxx b/panda/src/pipeline/conditionVarPosixImpl.cxx index 495b0cc94d..480900eedc 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.cxx +++ b/panda/src/pipeline/conditionVarPosixImpl.cxx @@ -18,8 +18,8 @@ #include "selectThreadImpl.h" -#ifdef THREAD_NSPR_IMPL +#ifdef THREAD_POSIX_IMPL -#include "conditionVarNsprImpl.h" +#include "conditionVarPosixImpl.h" -#endif // THREAD_NSPR_IMPL +#endif // THREAD_POSIX_IMPL diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 58952c7971..250edc4191 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -32,6 +32,24 @@ ConfigureFn(config_pipeline) { init_libpipeline(); } +ConfigVariableInt thread_stack_size +("thread-stack-size", 16384, + PRC_DESC("Specifies the size, in bytes, of the stack that will be created " + "for each newly-created thread. Not all thread implementations " + "respect this value.")); + +ConfigVariableBool threads_always_global +("threads-always-global", false, + PRC_DESC("Set this true to override the application's 'global' setting " + "for each created thread, and create every thread with global " + "true. Also see threads-never-global.")); + +ConfigVariableBool threads_never_global +("threads-never-global", false, + PRC_DESC("Set this true to override the application's 'global' setting " + "for each created thread, and create every thread with global " + "false. Also see threads-always-global.")); + //////////////////////////////////////////////////////////////////// // Function: init_libpipeline // Description: Initializes the library. This must be called at diff --git a/panda/src/pipeline/config_pipeline.h b/panda/src/pipeline/config_pipeline.h index 95d956d673..d3fb189c5b 100644 --- a/panda/src/pipeline/config_pipeline.h +++ b/panda/src/pipeline/config_pipeline.h @@ -22,11 +22,17 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" #include "dconfig.h" +#include "configVariableInt.h" +#include "configVariableBool.h" ConfigureDecl(config_pipeline, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(pipeline, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(thread, EXPCL_PANDA, EXPTP_PANDA); +extern ConfigVariableInt thread_stack_size; +extern ConfigVariableBool threads_always_global; +extern ConfigVariableBool threads_never_global; + extern EXPCL_PANDA void init_libpipeline(); #endif // CONFIG_PIPELINE_H diff --git a/panda/src/pipeline/mutexDebug.I b/panda/src/pipeline/mutexDebug.I index 640342c288..5ccf8e0974 100755 --- a/panda/src/pipeline/mutexDebug.I +++ b/panda/src/pipeline/mutexDebug.I @@ -68,6 +68,7 @@ operator = (const MutexDebug ©) { //////////////////////////////////////////////////////////////////// INLINE void MutexDebug:: lock() const { + TAU_PROFILE("MutexDebug::lock()", " ", TAU_USER); _global_mutex.lock(); ((MutexDebug *)this)->do_lock(); _global_mutex.release(); @@ -85,6 +86,7 @@ lock() const { //////////////////////////////////////////////////////////////////// INLINE void MutexDebug:: release() const { + TAU_PROFILE("MutexDebug::release()", " ", TAU_USER); _global_mutex.lock(); ((MutexDebug *)this)->do_release(); _global_mutex.release(); @@ -102,6 +104,7 @@ release() const { //////////////////////////////////////////////////////////////////// INLINE bool MutexDebug:: debug_is_locked() const { + TAU_PROFILE("MutexDebug::debug_is_locked()", " ", TAU_USER); _global_mutex.lock(); bool is_locked = do_debug_is_locked(); _global_mutex.release(); diff --git a/panda/src/pipeline/mutexDirect.I b/panda/src/pipeline/mutexDirect.I index 7f4a1a661b..828e569576 100755 --- a/panda/src/pipeline/mutexDirect.I +++ b/panda/src/pipeline/mutexDirect.I @@ -72,6 +72,7 @@ operator = (const MutexDirect ©) { //////////////////////////////////////////////////////////////////// INLINE void MutexDirect:: lock() const { + TAU_PROFILE("MutexDirect::lock()", " ", TAU_USER); ((MutexDirect *)this)->_impl.lock(); } @@ -87,6 +88,7 @@ lock() const { //////////////////////////////////////////////////////////////////// INLINE void MutexDirect:: release() const { + TAU_PROFILE("MutexDirect::release()", " ", TAU_USER); ((MutexDirect *)this)->_impl.release(); } diff --git a/panda/src/pipeline/mutexDirect.h b/panda/src/pipeline/mutexDirect.h index 7796b1e382..69e18f820a 100644 --- a/panda/src/pipeline/mutexDirect.h +++ b/panda/src/pipeline/mutexDirect.h @@ -21,6 +21,7 @@ #include "pandabase.h" #include "mutexImpl.h" +#include "pnotify.h" class Thread; diff --git a/panda/src/pipeline/pipeline_composite1.cxx b/panda/src/pipeline/pipeline_composite1.cxx index deaa4a231d..c683ca889e 100644 --- a/panda/src/pipeline/pipeline_composite1.cxx +++ b/panda/src/pipeline/pipeline_composite1.cxx @@ -3,6 +3,7 @@ #include "conditionVarDirect.cxx" #include "conditionVarDummyImpl.cxx" #include "conditionVarNsprImpl.cxx" +#include "conditionVarLinuxImpl.cxx" #include "conditionVarPosixImpl.cxx" #include "conditionVarWin32Impl.cxx" #include "config_pipeline.cxx" diff --git a/panda/src/pipeline/pipeline_composite2.cxx b/panda/src/pipeline/pipeline_composite2.cxx index c71a0046c5..92827f81fc 100644 --- a/panda/src/pipeline/pipeline_composite2.cxx +++ b/panda/src/pipeline/pipeline_composite2.cxx @@ -10,9 +10,11 @@ #include "pipelineCyclerTrueImpl.cxx" #include "pmutex.cxx" #include "reMutex.cxx" +#include "reMutexDirect.cxx" #include "reMutexHolder.cxx" #include "thread.cxx" #include "threadDummyImpl.cxx" #include "threadNsprImpl.cxx" +#include "threadLinuxImpl.cxx" #include "threadPosixImpl.cxx" #include "threadWin32Impl.cxx" diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index 30818055e9..7703731b0f 100755 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -23,7 +23,15 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE ReMutexDirect:: -ReMutexDirect() { +ReMutexDirect() +#ifndef HAVE_REMUTEXIMPL + : _cvar(_global_lock) +#endif +{ +#ifndef HAVE_REMUTEXIMPL + _locking_thread = NULL; + _lock_count = 0; +#endif } //////////////////////////////////////////////////////////////////// @@ -41,7 +49,11 @@ INLINE ReMutexDirect:: // Description: Do not attempt to copy reMutexes. //////////////////////////////////////////////////////////////////// INLINE ReMutexDirect:: -ReMutexDirect(const ReMutexDirect ©) { +ReMutexDirect(const ReMutexDirect ©) +#ifndef HAVE_REMUTEXIMPL + : _cvar(_global_lock) +#endif +{ nassertv(false); } @@ -55,7 +67,6 @@ operator = (const ReMutexDirect ©) { nassertv(false); } -#ifdef HAVE_REMUTEXIMPL //////////////////////////////////////////////////////////////////// // Function: ReMutexDirect::lock // Access: Public @@ -73,11 +84,13 @@ operator = (const ReMutexDirect ©) { //////////////////////////////////////////////////////////////////// INLINE void ReMutexDirect:: lock() const { - ((ReMutexDirect *)this)->_impl.lock(); -} -#endif // HAVE_REMUTEXIMPL - #ifdef HAVE_REMUTEXIMPL + ((ReMutexDirect *)this)->_impl.lock(); +#else + ((ReMutexDirect *)this)->do_lock(); +#endif // HAVE_REMUTEXIMPL +} + //////////////////////////////////////////////////////////////////// // Function: ReMutexDirect::release // Access: Public @@ -90,9 +103,12 @@ lock() const { //////////////////////////////////////////////////////////////////// INLINE void ReMutexDirect:: release() const { +#ifdef HAVE_REMUTEXIMPL ((ReMutexDirect *)this)->_impl.release(); -} +#else + ((ReMutexDirect *)this)->do_release(); #endif // HAVE_REMUTEXIMPL +} //////////////////////////////////////////////////////////////////// // Function: ReMutexDirect::debug_is_locked diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index f31ad6f52f..aa39927961 100755 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -22,25 +22,30 @@ MutexImpl ReMutexDirect::_global_lock; #endif // !HAVE_REMUTEXIMPL -#ifndef HAVE_REMUTEXIMPL //////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::lock +// Function: ReMutexDirect::output // Access: Public -// Description: Grabs the reMutex if it is available. If it is not -// available, blocks until it becomes available, then -// grabs it. In either case, the function does not -// return until the reMutex is held; you should then call -// unlock(). -// -// This method is considered const so that you can lock -// and unlock const reMutexes, mainly to allow thread-safe -// access to otherwise const data. -// -// Also see ReMutexHolder. +// Description: This method is declared virtual in MutexDebug, but +// non-virtual in ReMutexDirect. //////////////////////////////////////////////////////////////////// void ReMutexDirect:: -lock() const { - _global_mutex.lock(); +output(ostream &out) const { + out << "ReMutex " << (void *)this; +} + +#ifndef HAVE_REMUTEXIMPL +//////////////////////////////////////////////////////////////////// +// Function: ReMutexDirect::do_lock +// Access: Private +// Description: The private implementation of lock(), for the case in +// which the underlying lock system does not provide a +// reentrant mutex (and therefore we have to build this +// functionality on top of the existing non-reentrant +// mutex). +//////////////////////////////////////////////////////////////////// +void ReMutexDirect:: +do_lock() { + _global_lock.lock(); if (_locking_thread == (Thread *)NULL) { // The mutex is not already locked by anyone. Lock it. @@ -62,32 +67,36 @@ lock() const { while (_locking_thread != (Thread *)NULL) { _cvar.wait(); } - + _locking_thread = Thread::get_current_thread(); ++_lock_count; nassertd(_lock_count == 1) { } } - _global_mutex.release(); + _global_lock.release(); } #endif // !HAVE_REMUTEXIMPL #ifndef HAVE_REMUTEXIMPL //////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::release -// Access: Public -// Description: +// Function: ReMutexDirect::do_release +// Access: Private +// Description: The private implementation of release(), for the case +// in which the underlying lock system does not provide +// a reentrant mutex (and therefore we have to build +// this functionality on top of the existing +// non-reentrant mutex). //////////////////////////////////////////////////////////////////// void ReMutexDirect:: -release() { - _global_mutex.lock(); +do_release() { + _global_lock.lock(); if (_locking_thread != Thread::get_current_thread()) { ostringstream ostr; ostr << *_locking_thread << " attempted to release " << *this << " which it does not own"; nassert_raise(ostr.str()); - _global_mutex.release(); + _global_lock.release(); return; } @@ -100,17 +109,6 @@ release() { _locking_thread = (Thread *)NULL; _cvar.signal(); } - _global_mutex.release(); + _global_lock.release(); } #endif // !HAVE_REMUTEXIMPL - -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::output -// Access: Public -// Description: This method is declared virtual in MutexDebug, but -// non-virtual in ReMutexDirect. -//////////////////////////////////////////////////////////////////// -void ReMutexDirect:: -output(ostream &out) const { - out << "ReMutex " << (void *)this; -} diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index 23f9ccbfce..74da24b57f 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -40,13 +40,8 @@ private: INLINE void operator = (const ReMutexDirect ©); public: -#ifdef HAVE_REMUTEXIMPL INLINE void lock() const; INLINE void release() const; -#else - void lock() const; - void release() const; -#endif INLINE bool debug_is_locked() const; @@ -58,6 +53,9 @@ private: #else // If we don't have a reentrant mutex, we have to hand-roll one. + void do_lock(); + void do_release(); + Thread *_locking_thread; int _lock_count; ConditionVarImpl _cvar; diff --git a/panda/src/pipeline/select.tau b/panda/src/pipeline/select.tau new file mode 100644 index 0000000000..304f2be02f --- /dev/null +++ b/panda/src/pipeline/select.tau @@ -0,0 +1,3 @@ +BEGIN_EXCLUDE_LIST +void *ThreadPosixImpl::root_func# +END_EXCLUDE_LIST diff --git a/panda/src/pipeline/test_diners.cxx b/panda/src/pipeline/test_diners.cxx index b2f2675dd0..8de951b212 100644 --- a/panda/src/pipeline/test_diners.cxx +++ b/panda/src/pipeline/test_diners.cxx @@ -25,6 +25,8 @@ #include "conditionVar.h" #include "mutexHolder.h" #include "pointerTo.h" +#include "referenceCount.h" +#include "trueClock.h" #ifdef WIN32_VC // Under Windows, the rand() function seems to return a sequence @@ -33,7 +35,7 @@ static int last_rand = 0; #endif /* __WIN32__ */ -#define PRINTMSG(x) { MutexHolder l(Mutex::_notify_mutex); x; } +#define PRINTMSG(x) { MutexHolder l(Mutex::_notify_mutex); x << flush; } Mutex rand_mutex; @@ -72,7 +74,7 @@ ConditionVar room_condition(room_mutex); int room_occupancy = 0; class philosopher; -PT(philosopher) phils[N_DINERS]; +PT(Thread) phils[N_DINERS]; class philosopher : public Thread { private: @@ -88,27 +90,25 @@ private: int r = l+1; if (r == N_DINERS) r = 0; - /* if (l & 1) { int t = l; l = r; r = t; } - */ PRINTMSG(cerr << "Philosopher #" << _id << " has entered the room." - << endl); + << "\n"); int count = (int)random_f(10.0) + 1; while (--count) { chopsticks[r].lock(); Thread::sleep(1); chopsticks[l].lock(); PRINTMSG(cerr << "Philosopher #" << _id - << " is eating spaghetti now." << endl); + << " is eating spaghetti now.\n"); Thread::sleep(random_f(3.0)); chopsticks[l].release(); chopsticks[r].release(); PRINTMSG(cerr << "Philosopher #" << _id - << " is pondering about life." << endl); + << " is pondering about life.\n"); Thread::sleep(random_f(3.0)); } room_mutex.lock(); @@ -117,7 +117,7 @@ private: room_condition.signal(); room_mutex.release(); PRINTMSG(cerr << "Philosopher #" << _id << " has left the room (" - << room_occupancy << " left)." << endl); + << room_occupancy << " left).\n"); } inline void* make_arg(const int i) { return (void*)new int(i); } @@ -131,8 +131,18 @@ public: } }; -int main(int, char**) -{ +int +main(int argc, char *argv[]) { + double has_run_time = false; + double run_time = 0.0; + if (argc > 1) { + run_time = atof(argv[1]); + cerr << "Running for " << run_time << " seconds\n"; + has_run_time = true; + } else { + cerr << "Running indefinitely\n"; + } + int i; room_mutex.lock(); for (i=0; istart(TP_normal, false, false); } room_occupancy = N_DINERS; - while (1) { + + TrueClock *clock = TrueClock::get_global_ptr(); + double start_time = clock->get_short_time(); + double end_time = start_time + run_time; + + while (!has_run_time || clock->get_short_time() < end_time) { while (room_occupancy == N_DINERS) { PRINTMSG(cerr << "main thread about to block " << room_occupancy - << endl); + << "\n"); room_condition.wait(); } // hmm.. someone left the room. room_mutex.release(); // sleep for a while and then create a new philosopher - PRINTMSG(cerr << "main thread sleep" << endl); + PRINTMSG(cerr << "main thread sleep\n"); Thread::sleep(2.0); - PRINTMSG(cerr << "main thread wake up" << endl); + PRINTMSG(cerr << "main thread wake up\n"); room_mutex.lock(); for (i=0; istart(TP_normal, false, false); ++room_occupancy; } + + PRINTMSG(cerr << "Waiting for philosophers to finish\n"); + + while (room_occupancy != 0) { + room_condition.wait(); + } + + room_mutex.release(); + + cerr << "Exiting.\n"; + return 0; } diff --git a/panda/src/pipeline/test_mutex.cxx b/panda/src/pipeline/test_mutex.cxx new file mode 100644 index 0000000000..e2b813c886 --- /dev/null +++ b/panda/src/pipeline/test_mutex.cxx @@ -0,0 +1,70 @@ +// Filename: test_mutex.cxx +// Created by: drose (29Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "pandabase.h" +#include "thread.h" +#include "pmutex.h" +#include "mutexHolder.h" +#include "pointerTo.h" +#include "trueClock.h" + +static const double thread_duration = 5.0; + +class MyThread : public Thread { +public: + MyThread(const string &name, MutexImpl &m1, double period) : + Thread(name, name), + _m1(m1), _period(period) + { + } + + virtual void thread_main() { + TrueClock *clock = TrueClock::get_global_ptr(); + double start = clock->get_short_time(); + double end = start + thread_duration; + while (clock->get_short_time() < end) { + _m1.lock(); + Thread::sleep(_period); + _m1.release(); + } + } + + MutexImpl &_m1; + double _period; +}; + +int +main(int argc, char *argv[]) { + MutexImpl _m1; + + _m1.lock(); + _m1.release(); + + cerr << "Making threads.\n"; + MyThread *a = new MyThread("a", _m1, 1.0); + MyThread *b = new MyThread("b", _m1, 0.9); + + cerr << "Starting threads.\n"; + a->start(TP_normal, true, true); + b->start(TP_normal, true, true); + + a->join(); + b->join(); + + exit(0); +} diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index ba51a7723c..efa0e6ea9c 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -38,7 +38,7 @@ private: ThreadWithData:: ThreadWithData(const string &name, int parameter) : - Thread(name), + Thread(name, name), _parameter(parameter) { MutexHolder holder(cout_mutex); diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index fffd11e2c0..69a6080932 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -134,26 +134,6 @@ get_pipeline_stage() const { return _pipeline_stage; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::set_pipeline_stage -// Access: Published -// Description: Specifies the Pipeline stage number associated with -// this thread. The default stage is 0 if no stage is -// specified otherwise. -// -// This must be a value in the range [0 -// .. pipeline->get_num_stages() - 1]. It specifies the -// values that this thread observes for all pipelined -// data. Typically, an application thread will leave -// this at 0, but a render thread may set it to 1 or 2 -// (to operate on the previous frame's data, or the -// second previous frame's data). -//////////////////////////////////////////////////////////////////// -INLINE void Thread:: -set_pipeline_stage(int pipeline_stage) { - _pipeline_stage = pipeline_stage; -} - //////////////////////////////////////////////////////////////////// // Function: Thread::set_min_pipeline_stage // Access: Published @@ -163,7 +143,7 @@ set_pipeline_stage(int pipeline_stage) { //////////////////////////////////////////////////////////////////// INLINE void Thread:: set_min_pipeline_stage(int min_pipeline_stage) { - _pipeline_stage = max(_pipeline_stage, min_pipeline_stage); + set_pipeline_stage(max(_pipeline_stage, min_pipeline_stage)); } //////////////////////////////////////////////////////////////////// @@ -212,6 +192,7 @@ get_external_thread() { //////////////////////////////////////////////////////////////////// INLINE Thread *Thread:: get_current_thread() { + TAU_PROFILE("Thread *Thread::get_current_thread()", " ", TAU_USER); #ifndef HAVE_THREADS return get_main_thread(); #else // HAVE_THREADS @@ -233,12 +214,13 @@ get_current_thread() { //////////////////////////////////////////////////////////////////// INLINE int Thread:: get_current_pipeline_stage() { -#if !defined(HAVE_THREADS) || !defined(DO_PIPELINING) - // Without threads or pipelining, the result is always 0. + TAU_PROFILE("int Thread::get_current_pipeline_stage()", " ", TAU_USER); +#ifndef THREADED_PIPELINE + // Without threaded pipelining, the result is always 0. return 0; #else return get_current_thread()->get_pipeline_stage(); -#endif // !HAVE_THREADS || !DO_PIPELINING +#endif // !THREADED_PIPELINE } //////////////////////////////////////////////////////////////////// @@ -263,41 +245,10 @@ is_threading_supported() { //////////////////////////////////////////////////////////////////// INLINE void Thread:: sleep(double seconds) { + TAU_PROFILE("void Thread::sleep(double)", " ", TAU_USER); ThreadImpl::sleep(seconds); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::start -// Access: Public -// Description: Starts the thread executing. It is only valid to -// call this once. -// -// The thread will begin executing its thread_main() -// function, and will terminate when thread_main() -// returns. -// -// priority is intended as a hint to the relative -// importance of this thread, and global should be set -// true if the thread will perform a lot of blocking -// I/O, or false otherwise (see the NSPR documentation -// on global vs. local threads for more on this). Both -// of these parameters may be ignored by the thread -// implementation. -// -// joinable should be set true if you intend to call -// join() to wait for the thread to terminate, or false -// if you don't care and you will never call join(). -// -// The return value is true if the thread is -// successfully started, false otherwise. -//////////////////////////////////////////////////////////////////// -INLINE bool Thread:: -start(ThreadPriority priority, bool global, bool joinable) { - nassertr(!_started, false); - _started = _impl.start(priority, global, joinable); - return _started; -} - //////////////////////////////////////////////////////////////////// // Function: Thread::interrupt // Access: Public @@ -321,6 +272,7 @@ interrupt() { //////////////////////////////////////////////////////////////////// INLINE void Thread:: join() { + TAU_PROFILE("void Thread::join()", " ", TAU_USER); _impl.join(); } diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index d1e72c357d..80bd690651 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -19,6 +19,7 @@ #include "thread.h" #include "mainThread.h" #include "externalThread.h" +#include "config_pipeline.h" Thread *Thread::_main_thread; Thread *Thread::_external_thread; @@ -77,6 +78,35 @@ bind_thread(const string &name, const string &sync_name) { return thread; } +//////////////////////////////////////////////////////////////////// +// Function: Thread::set_pipeline_stage +// Access: Published +// Description: Specifies the Pipeline stage number associated with +// this thread. The default stage is 0 if no stage is +// specified otherwise. +// +// This must be a value in the range [0 +// .. pipeline->get_num_stages() - 1]. It specifies the +// values that this thread observes for all pipelined +// data. Typically, an application thread will leave +// this at 0, but a render thread may set it to 1 or 2 +// (to operate on the previous frame's data, or the +// second previous frame's data). +//////////////////////////////////////////////////////////////////// +void Thread:: +set_pipeline_stage(int pipeline_stage) { +#ifdef THREADED_PIPELINE + _pipeline_stage = pipeline_stage; +#else + if (pipeline_stage != 0) { + pipeline_cat.warning() + << "Requested pipeline stage " << pipeline_stage + << " but multithreaded render pipelines not enabled in build.\n"; + } + _pipeline_stage = 0; +#endif +} + //////////////////////////////////////////////////////////////////// // Function: Thread::output // Access: Published, Virtual @@ -87,6 +117,51 @@ output(ostream &out) const { out << get_type() << " " << get_name(); } +//////////////////////////////////////////////////////////////////// +// Function: Thread::start +// Access: Public +// Description: Starts the thread executing. It is only valid to +// call this once. +// +// The thread will begin executing its thread_main() +// function, and will terminate when thread_main() +// returns. +// +// priority is intended as a hint to the relative +// importance of this thread, and global should be set +// true if the thread will perform a lot of blocking +// I/O, or false otherwise (see the NSPR documentation +// on global vs. local threads for more on this). Both +// of these parameters may be ignored by the thread +// implementation. +// +// joinable should be set true if you intend to call +// join() to wait for the thread to terminate, or false +// if you don't care and you will never call join(). +// +// The return value is true if the thread is +// successfully started, false otherwise. +//////////////////////////////////////////////////////////////////// +bool Thread:: +start(ThreadPriority priority, bool global, bool joinable) { + nassertr(!_started, false); + + if (threads_always_global) { + global = true; + } else if (threads_never_global) { + global = false; + } + + _started = _impl.start(priority, global, joinable); + + if (!_started) { + thread_cat.warning() + << *this << " could not be started!\n"; + } + + return _started; +} + //////////////////////////////////////////////////////////////////// // Function: Thread::init_main_thread // Access: Private, Static diff --git a/panda/src/pipeline/thread.h b/panda/src/pipeline/thread.h index 4fabbfca27..ccf46dbe1f 100644 --- a/panda/src/pipeline/thread.h +++ b/panda/src/pipeline/thread.h @@ -66,7 +66,7 @@ PUBLISHED: INLINE void set_pstats_index(int pstats_index); INLINE int get_pipeline_stage() const; - INLINE void set_pipeline_stage(int pipeline_stage); + void set_pipeline_stage(int pipeline_stage); INLINE void set_min_pipeline_stage(int min_pipeline_stage); INLINE static Thread *get_main_thread(); @@ -79,7 +79,7 @@ PUBLISHED: virtual void output(ostream &out) const; public: - INLINE bool start(ThreadPriority priority, bool global, bool joinable); + bool start(ThreadPriority priority, bool global, bool joinable); INLINE void interrupt(); INLINE void join(); @@ -128,6 +128,7 @@ private: friend class ThreadDummyImpl; friend class ThreadWin32Impl; + friend class ThreadLinuxImpl; friend class ThreadPosixImpl; friend class ThreadNsprImpl; }; diff --git a/panda/src/pipeline/threadImpl.h b/panda/src/pipeline/threadImpl.h index 45925fb9b4..bc5aa58167 100644 --- a/panda/src/pipeline/threadImpl.h +++ b/panda/src/pipeline/threadImpl.h @@ -32,6 +32,11 @@ typedef ThreadDummyImpl ThreadImpl; #include "threadWin32Impl.h" typedef ThreadWin32Impl ThreadImpl; +#elif defined(THREAD_LINUX_IMPL) + +#include "threadLinuxImpl.h" +typedef ThreadLinuxImpl ThreadImpl; + #elif defined(THREAD_POSIX_IMPL) #include "threadPosixImpl.h" diff --git a/panda/src/pipeline/threadLinuxImpl.I b/panda/src/pipeline/threadLinuxImpl.I new file mode 100644 index 0000000000..896779bf6c --- /dev/null +++ b/panda/src/pipeline/threadLinuxImpl.I @@ -0,0 +1,66 @@ +// Filename: threadLinuxImpl.I +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ThreadLinuxImpl:: +ThreadLinuxImpl(Thread *parent_obj) : + _cv(_mutex), + _parent_obj(parent_obj) +{ + _thread = 0; + _joinable = false; + _status = S_new; + _stack = NULL; +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::prepare_for_exit +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void ThreadLinuxImpl:: +prepare_for_exit() { +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::is_threading_supported +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ThreadLinuxImpl:: +is_threading_supported() { + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::sleep +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void ThreadLinuxImpl:: +sleep(double seconds) { + struct timespec rqtp; + rqtp.tv_sec = time_t(seconds); + rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0); + nanosleep(&rqtp, NULL); +} diff --git a/panda/src/pipeline/threadLinuxImpl.cxx b/panda/src/pipeline/threadLinuxImpl.cxx new file mode 100644 index 0000000000..dcb6c65604 --- /dev/null +++ b/panda/src/pipeline/threadLinuxImpl.cxx @@ -0,0 +1,260 @@ +// Filename: threadLinuxImpl.cxx +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "threadLinuxImpl.h" +#include "selectThreadImpl.h" + +#ifdef THREAD_LINUX_IMPL + +#include "pointerTo.h" +#include "config_pipeline.h" + +#include +#include +#include +#include +#include // for perror + +MutexLinuxImpl ThreadLinuxImpl::_thread_pointers_lock; +ThreadLinuxImpl::ThreadPointers ThreadLinuxImpl::_thread_pointers; +bool ThreadLinuxImpl::_got_main_thread_pointer; + +inline static pid_t gettid() { +#ifdef __i386__ + pid_t ret; + __asm__("int $0x80" : "=a" (ret) : "0" (224) /* SYS_gettid */); + return ret; +#else +#error only i386 supported right now. +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +ThreadLinuxImpl:: +~ThreadLinuxImpl() { + if (thread_cat.is_debug()) { + thread_cat.debug() << "Deleting thread " << _parent_obj->get_name() << "\n"; + } + + if (_stack != NULL) { + delete[] _stack; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::start +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +bool ThreadLinuxImpl:: +start(ThreadPriority priority, bool global, bool joinable) { + _mutex.lock(); + if (thread_cat.is_debug()) { + thread_cat.debug() << "Starting " << *_parent_obj << "\n"; + } + + nassertd(_status == S_new && _thread == 0 && _stack == NULL) { + _mutex.release(); + return false; + } + + _joinable = joinable; + _status = S_start_called; + + if (!_got_main_thread_pointer) { + // If we haven't spawned any threads yet, this must be the main + // thread. + bind_thread(Thread::get_main_thread()); + _got_main_thread_pointer = true; + } + + // Increment the parent object's reference count first. The thread + // will eventually decrement it when it terminates. + _parent_obj->ref(); + + _stack = new unsigned char[thread_stack_size]; + + int flags = SIGCHLD | CLONE_PARENT | CLONE_VM; + if (!global) { + // Make a thread that uses the same pid as the parent. + flags |= CLONE_SIGHAND | CLONE_THREAD; + } + + _thread = + clone(&root_func, _stack + thread_stack_size, + flags, (void *)this); + + if (_thread == -1) { + // Oops, we couldn't start the thread. Be sure to decrement the + // reference count we incremented above, and return false to + // indicate failure. + perror("clone"); + unref_delete(_parent_obj); + _mutex.release(); + return false; + } + + _mutex.release(); + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::interrupt +// Access: Public +// Description: Sends an interrupt message to the thread. This will +// interrupt any blocking-type system calls the thread +// may be waiting on, such as I/O, so that the thread +// may continue some other processing. The specific +// behavior is implementation dependent. +//////////////////////////////////////////////////////////////////// +void ThreadLinuxImpl:: +interrupt() { +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::join +// Access: Public +// Description: Blocks the calling process until the thread +// terminates. If the thread has already terminated, +// this returns immediately. +//////////////////////////////////////////////////////////////////// +void ThreadLinuxImpl:: +join() { + _mutex.lock(); + nassertd(_joinable && _status != S_new) { + _mutex.release(); + return; + } + + while (_status != S_finished) { + _cv.wait(); + } + _mutex.release(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::get_current_thread +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +Thread *ThreadLinuxImpl:: +get_current_thread() { + if (!_got_main_thread_pointer) { + // If we haven't spawned any threads yet, this must be the main + // thread. + bind_thread(Thread::get_main_thread()); + _got_main_thread_pointer = true; + return Thread::get_main_thread(); + } + + _thread_pointers_lock.lock(); + Thread *result = NULL; + + ThreadPointers::const_iterator ti; + pid_t my_tid = gettid(); + ti = _thread_pointers.find(my_tid); + if (ti != _thread_pointers.end()) { + result = (*ti).second; + } + _thread_pointers_lock.release(); + + nassertr(result != NULL, NULL); + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::bind_thread +// Access: Public, Static +// Description: Associates the indicated Thread object with the +// currently-executing thread. You should not call this +// directly; use Thread::bind_thread() instead. +//////////////////////////////////////////////////////////////////// +void ThreadLinuxImpl:: +bind_thread(Thread *thread) { + _thread_pointers_lock.lock(); + pid_t my_tid = gettid(); + bool inserted = _thread_pointers.insert(ThreadPointers::value_type(my_tid, thread)).second; + _thread_pointers_lock.release(); + nassertv(inserted); +} + +//////////////////////////////////////////////////////////////////// +// Function: ThreadLinuxImpl::root_func +// Access: Private, Static +// Description: The entry point of each thread. +//////////////////////////////////////////////////////////////////// +int ThreadLinuxImpl:: +root_func(void *data) { + ThreadLinuxImpl *self = (ThreadLinuxImpl *)data; + + { + _thread_pointers_lock.lock(); + pid_t my_tid = gettid(); + + bool inserted = _thread_pointers.insert(ThreadPointers::value_type(my_tid, self->_parent_obj)).second; + nassertd(inserted) { + _thread_pointers_lock.release(); + return 1; + } + _thread_pointers_lock.release(); + } + + { + self->_mutex.lock(); + nassertd(self->_status == S_start_called) { + self->_mutex.release(); + return 1; + } + + self->_status = S_running; + self->_cv.signal(); + self->_mutex.release(); + } + + self->_parent_obj->thread_main(); + + if (thread_cat.is_debug()) { + thread_cat.debug() + << "Terminating thread " << self->_parent_obj->get_name() + << ", count = " << self->_parent_obj->get_ref_count() << "\n"; + } + + { + self->_mutex.lock(); + nassertd(self->_status == S_running) { + self->_mutex.release(); + return 1; + } + self->_status = S_finished; + self->_cv.signal(); + self->_mutex.release(); + } + + // Now drop the parent object reference that we grabbed in start(). + // This might delete the parent object, and in turn, delete the + // ThreadLinuxImpl object. + unref_delete(self->_parent_obj); + + return 0; +} + +#endif // THREAD_LINUX_IMPL diff --git a/panda/src/pipeline/threadLinuxImpl.h b/panda/src/pipeline/threadLinuxImpl.h new file mode 100644 index 0000000000..034f8b613d --- /dev/null +++ b/panda/src/pipeline/threadLinuxImpl.h @@ -0,0 +1,84 @@ +// Filename: threadLinuxImpl.h +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef THREADLINUXIMPL_H +#define THREADLINUXIMPL_H + +#include "pandabase.h" +#include "selectThreadImpl.h" + +#ifdef THREAD_LINUX_IMPL + +#include "pnotify.h" +#include "threadPriority.h" +#include "mutexLinuxImpl.h" +#include "conditionVarLinuxImpl.h" + +class Thread; + +//////////////////////////////////////////////////////////////////// +// Class : ThreadLinuxImpl +// Description : Uses low-level Linux-specific calls to implement +// threads. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA ThreadLinuxImpl { +public: + INLINE ThreadLinuxImpl(Thread *parent_obj); + ~ThreadLinuxImpl(); + + bool start(ThreadPriority priority, bool global, bool joinable); + void interrupt(); + void join(); + + INLINE static void prepare_for_exit(); + + static Thread *get_current_thread(); + static void bind_thread(Thread *thread); + INLINE static bool is_threading_supported(); + INLINE static void sleep(double seconds); + +private: + static int root_func(void *data); + + enum Status { + S_new, + S_start_called, + S_running, + S_finished + }; + + MutexLinuxImpl _mutex; + ConditionVarLinuxImpl _cv; + Thread *_parent_obj; + int _thread; + bool _joinable; + Status _status; + unsigned char *_stack; + + // per-thread data. + typedef pmap ThreadPointers; + static ThreadPointers _thread_pointers; + static MutexLinuxImpl _thread_pointers_lock; + static bool _got_main_thread_pointer; +}; + +#include "threadLinuxImpl.I" + +#endif // THREAD_LINUX_IMPL + +#endif diff --git a/panda/src/pipeline/threadNsprImpl.cxx b/panda/src/pipeline/threadNsprImpl.cxx index 73e5b48a2e..96adeb41f6 100644 --- a/panda/src/pipeline/threadNsprImpl.cxx +++ b/panda/src/pipeline/threadNsprImpl.cxx @@ -90,7 +90,7 @@ bool ThreadNsprImpl:: start(ThreadPriority priority, bool global, bool joinable) { _mutex.lock(); if (thread_cat.is_debug()) { - thread_cat.debug() << "Starting thread " << _parent_obj->get_name() << "\n"; + thread_cat.debug() << "Starting " << *_parent_obj << "\n"; } nassertd(_thread == (PRThread *)NULL) { _mutex.release(); diff --git a/panda/src/pipeline/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I index 6ea6c74071..70fa1ce4d9 100644 --- a/panda/src/pipeline/threadPosixImpl.I +++ b/panda/src/pipeline/threadPosixImpl.I @@ -47,6 +47,7 @@ prepare_for_exit() { //////////////////////////////////////////////////////////////////// INLINE Thread *ThreadPosixImpl:: get_current_thread() { + TAU_PROFILE("Thread *ThreadPosixImpl::get_current_thread()", " ", TAU_USER); if (!_got_pt_ptr_index) { init_pt_ptr_index(); } @@ -86,6 +87,7 @@ is_threading_supported() { //////////////////////////////////////////////////////////////////// INLINE void ThreadPosixImpl:: sleep(double seconds) { + TAU_PROFILE("void ThreadPosixImpl::sleep(double)", " ", TAU_USER); struct timespec rqtp; rqtp.tv_sec = time_t(seconds); rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0); diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index 483bc38a3b..3fb1fc6d16 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -21,9 +21,9 @@ #ifdef THREAD_POSIX_IMPL +#include "thread.h" #include "pointerTo.h" #include "config_pipeline.h" - #include pthread_key_t ThreadPosixImpl::_pt_ptr_index = 0; @@ -60,7 +60,7 @@ bool ThreadPosixImpl:: start(ThreadPriority priority, bool global, bool joinable) { _mutex.lock(); if (thread_cat.is_debug()) { - thread_cat.debug() << "Starting thread " << _parent_obj->get_name() << "\n"; + thread_cat.debug() << "Starting " << *_parent_obj << "\n"; } nassertd(_status == S_new) { @@ -94,7 +94,7 @@ start(ThreadPriority priority, bool global, bool joinable) { struct sched_param param; int current_policy = SCHED_OTHER; - result = pthread_attr_setschedpolicy(&attr, SCHED_OTHER); + result = pthread_attr_setschedpolicy(&attr, current_policy); if (result != 0) { thread_cat.warning() << "Unable to set scheduling policy.\n"; @@ -185,44 +185,49 @@ join() { //////////////////////////////////////////////////////////////////// void *ThreadPosixImpl:: root_func(void *data) { - ThreadPosixImpl *self = (ThreadPosixImpl *)data; - int result = pthread_setspecific(_pt_ptr_index, self->_parent_obj); - nassertr(result == 0, NULL); - + TAU_REGISTER_THREAD(); { - self->_mutex.lock(); - nassertd(self->_status == S_start_called) { - self->_mutex.release(); - return NULL; - } + TAU_PROFILE("void ThreadPosixImpl::root_func()", " ", TAU_USER); + + ThreadPosixImpl *self = (ThreadPosixImpl *)data; + int result = pthread_setspecific(_pt_ptr_index, self->_parent_obj); + nassertr(result == 0, NULL); + + { + self->_mutex.lock(); + nassertd(self->_status == S_start_called) { + self->_mutex.release(); + return NULL; + } - self->_status = S_running; - self->_mutex.release(); - } - - self->_parent_obj->thread_main(); - - if (thread_cat.is_debug()) { - thread_cat.debug() - << "Terminating thread " << self->_parent_obj->get_name() - << ", count = " << self->_parent_obj->get_ref_count() << "\n"; - } - - { - self->_mutex.lock(); - nassertd(self->_status == S_running) { + self->_status = S_running; self->_mutex.release(); - return NULL; } - self->_status = S_finished; - self->_mutex.release(); + + self->_parent_obj->thread_main(); + + if (thread_cat.is_debug()) { + thread_cat.debug() + << "Terminating thread " << self->_parent_obj->get_name() + << ", count = " << self->_parent_obj->get_ref_count() << "\n"; + } + + { + self->_mutex.lock(); + nassertd(self->_status == S_running) { + self->_mutex.release(); + return NULL; + } + self->_status = S_finished; + self->_mutex.release(); + } + + // Now drop the parent object reference that we grabbed in start(). + // This might delete the parent object, and in turn, delete the + // ThreadPosixImpl object. + unref_delete(self->_parent_obj); } - - // Now drop the parent object reference that we grabbed in start(). - // This might delete the parent object, and in turn, delete the - // ThreadPosixImpl object. - unref_delete(self->_parent_obj); - + return NULL; } diff --git a/panda/src/pipeline/threadWin32Impl.I b/panda/src/pipeline/threadWin32Impl.I index 77b0048d80..2f4bf6ad13 100644 --- a/panda/src/pipeline/threadWin32Impl.I +++ b/panda/src/pipeline/threadWin32Impl.I @@ -42,7 +42,7 @@ prepare_for_exit() { } //////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::Constructor +// Function: ThreadWin32Impl::get_current_thread // Access: Public, Static // Description: //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 3774ae8376..c7772a89a6 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -50,7 +50,7 @@ bool ThreadWin32Impl:: start(ThreadPriority priority, bool global, bool joinable) { _mutex.lock(); if (thread_cat.is_debug()) { - thread_cat.debug() << "Starting thread " << _parent_obj->get_name() << "\n"; + thread_cat.debug() << "Starting " << *_parent_obj << "\n"; } nassertd(_status == S_new && _thread == 0) { diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index 4cf58502e7..ece9b53533 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -20,6 +20,7 @@ #include "pnmFileTypeRegistry.h" #include "pnmFileType.h" #include "pnmReader.h" +#include "pnmWriter.h" #include "config_pnmimage.h" #include "virtualFileSystem.h" #include "zStream.h" diff --git a/panda/src/pnmimage/pnmimage_base.cxx b/panda/src/pnmimage/pnmimage_base.cxx index 47da0b92dc..3a297b192e 100644 --- a/panda/src/pnmimage/pnmimage_base.cxx +++ b/panda/src/pnmimage/pnmimage_base.cxx @@ -19,6 +19,7 @@ #include "pnmimage_base.h" #include "streamReader.h" #include "streamWriter.h" +#include "config_pnmimage.h" #include #include // for sprintf() diff --git a/panda/src/putil/bamTextureMode.cxx b/panda/src/putil/bamTextureMode.cxx index fef4a3bb67..90ccdb0453 100644 --- a/panda/src/putil/bamTextureMode.cxx +++ b/panda/src/putil/bamTextureMode.cxx @@ -18,6 +18,7 @@ #include "bamTextureMode.h" #include "config_util.h" +#include "string_utils.h" ostream & operator << (ostream &out, BamTextureMode btm) { diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.I b/panda/src/putil/cachedTypedWritableReferenceCount.I index 57f9ea31ee..1c23b8d483 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.I +++ b/panda/src/putil/cachedTypedWritableReferenceCount.I @@ -135,7 +135,7 @@ INLINE CachedTypedWritableReferenceCount:: //////////////////////////////////////////////////////////////////// INLINE int CachedTypedWritableReferenceCount:: get_cache_ref_count() const { -#ifndef NDEBUG +#ifdef _DEBUG test_ref_count_integrity(); #endif return AtomicAdjust::get(_cache_ref_count); @@ -152,15 +152,15 @@ get_cache_ref_count() const { // with the object. An object might be const in other // ways, but we still need to accurately count the // number of references to it. -// -// The return value is the new reference count. //////////////////////////////////////////////////////////////////// -INLINE int CachedTypedWritableReferenceCount:: +INLINE void CachedTypedWritableReferenceCount:: cache_ref() const { - nassertr(test_ref_count_integrity(), 0); +#ifdef _DEBUG + nassertv(test_ref_count_integrity()); +#endif ref(); - return AtomicAdjust::inc(((CachedTypedWritableReferenceCount *)this)->_cache_ref_count); + AtomicAdjust::inc(((CachedTypedWritableReferenceCount *)this)->_cache_ref_count); } //////////////////////////////////////////////////////////////////// @@ -186,11 +186,14 @@ cache_ref() const { // ways, but we still need to accurately count the // number of references to it. // -// The return value is the new reference count. +// The return value is true if the new reference count +// is nonzero, false if it is zero. //////////////////////////////////////////////////////////////////// -INLINE int CachedTypedWritableReferenceCount:: +INLINE bool CachedTypedWritableReferenceCount:: cache_unref() const { +#ifdef _DEBUG nassertr(test_ref_count_integrity(), 0); +#endif // If this assertion fails, you tried to unref an object with a // zero reference count. Are you using ref() and unref() diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.h b/panda/src/putil/cachedTypedWritableReferenceCount.h index 1cfa803eaa..fa59f5f59d 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.h +++ b/panda/src/putil/cachedTypedWritableReferenceCount.h @@ -50,8 +50,8 @@ protected: PUBLISHED: INLINE int get_cache_ref_count() const; - INLINE int cache_ref() const; - INLINE int cache_unref() const; + INLINE void cache_ref() const; + INLINE bool cache_unref() const; INLINE bool test_ref_count_integrity() const; protected: diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index 7aded95a04..70a7962847 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -18,6 +18,7 @@ #include "config_util.h" #include "animInterface.h" +#include "bamReader.h" #include "bamReaderParam.h" #include "bitArray.h" #include "bitMask.h" diff --git a/panda/src/putil/linkedListNode.h b/panda/src/putil/linkedListNode.h index 54cfe66a2d..5af32be17b 100644 --- a/panda/src/putil/linkedListNode.h +++ b/panda/src/putil/linkedListNode.h @@ -20,6 +20,7 @@ #define LINKEDLISTNODE_H #include "pandabase.h" +#include "pnotify.h" //////////////////////////////////////////////////////////////////// // Class : LinkedListNode diff --git a/panda/src/putil/nodeCachedReferenceCount.I b/panda/src/putil/nodeCachedReferenceCount.I index 97e2dfbd3c..c28a6ccda8 100644 --- a/panda/src/putil/nodeCachedReferenceCount.I +++ b/panda/src/putil/nodeCachedReferenceCount.I @@ -135,7 +135,7 @@ INLINE NodeCachedReferenceCount:: //////////////////////////////////////////////////////////////////// INLINE int NodeCachedReferenceCount:: get_node_ref_count() const { -#ifndef NDEBUG +#ifdef _DEBUG test_ref_count_integrity(); #endif return AtomicAdjust::get(_node_ref_count); @@ -152,15 +152,15 @@ get_node_ref_count() const { // with the object. An object might be const in other // ways, but we still need to accurately count the // number of references to it. -// -// The return value is the new reference count. //////////////////////////////////////////////////////////////////// -INLINE int NodeCachedReferenceCount:: +INLINE void NodeCachedReferenceCount:: node_ref() const { - nassertr(test_ref_count_integrity(), 0); +#ifdef _DEBUG + nassertv(test_ref_count_integrity()); +#endif ref(); - return AtomicAdjust::inc(((NodeCachedReferenceCount *)this)->_node_ref_count); + AtomicAdjust::inc(((NodeCachedReferenceCount *)this)->_node_ref_count); } //////////////////////////////////////////////////////////////////// @@ -186,11 +186,14 @@ node_ref() const { // ways, but we still need to accurately count the // number of references to it. // -// The return value is the new reference count. +// The return value is true if the new reference count +// is nonzero, false if it is zero. //////////////////////////////////////////////////////////////////// -INLINE int NodeCachedReferenceCount:: +INLINE bool NodeCachedReferenceCount:: node_unref() const { +#ifdef _DEBUG nassertr(test_ref_count_integrity(), 0); +#endif // If this assertion fails, you tried to unref an object with a // zero reference count. Are you using ref() and unref() diff --git a/panda/src/putil/nodeCachedReferenceCount.h b/panda/src/putil/nodeCachedReferenceCount.h index 9acbd06b5f..9d8f7d8901 100644 --- a/panda/src/putil/nodeCachedReferenceCount.h +++ b/panda/src/putil/nodeCachedReferenceCount.h @@ -57,8 +57,8 @@ protected: PUBLISHED: INLINE int get_node_ref_count() const; - INLINE int node_ref() const; - INLINE int node_unref() const; + INLINE void node_ref() const; + INLINE bool node_unref() const; INLINE bool test_ref_count_integrity() const; enum Referenced { diff --git a/panda/src/putil/uniqueIdAllocator.cxx b/panda/src/putil/uniqueIdAllocator.cxx index 3b210f47c0..5b9f58decd 100644 --- a/panda/src/putil/uniqueIdAllocator.cxx +++ b/panda/src/putil/uniqueIdAllocator.cxx @@ -19,6 +19,7 @@ #include "pandabase.h" #include "pnotify.h" +#include "notifyCategoryProxy.h" #include "uniqueIdAllocator.h" diff --git a/panda/src/recorder/recorderFrame.h b/panda/src/recorder/recorderFrame.h index 2f763f16d9..04a74c5769 100644 --- a/panda/src/recorder/recorderFrame.h +++ b/panda/src/recorder/recorderFrame.h @@ -23,6 +23,7 @@ #include "recorderBase.h" #include "typedWritable.h" #include "recorderTable.h" +#include "datagram.h" class BamWriter; class BamReader; diff --git a/panda/src/recorder/recorderTable.cxx b/panda/src/recorder/recorderTable.cxx index 237c1d896b..2f16f4eafd 100644 --- a/panda/src/recorder/recorderTable.cxx +++ b/panda/src/recorder/recorderTable.cxx @@ -20,6 +20,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "config_recorder.h" +#include "recorderController.h" #include "indent.h" TypeHandle RecorderTable::_type_handle; diff --git a/panda/src/recorder/socketStreamRecorder.h b/panda/src/recorder/socketStreamRecorder.h index 3db85b9346..56c8f3497f 100644 --- a/panda/src/recorder/socketStreamRecorder.h +++ b/panda/src/recorder/socketStreamRecorder.h @@ -21,11 +21,13 @@ #include "pandabase.h" #include "socketStream.h" +#include "recorderBase.h" #include "pdeque.h" class BamReader; class BamWriter; class FactoryParams; +class DatagramIterator; // At the present, this module is not compiled if OpenSSL is not // available, since in that case socketStream.h is not compiled diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index df5062d2bb..fa743a42db 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -364,5 +364,6 @@ main(int argc, char *argv[]) { framework.report_frame_rate(nout); } + framework.close_framework(); return (0); } diff --git a/panda/src/text/geomTextGlyph.h b/panda/src/text/geomTextGlyph.h index fab384203f..2ffcff82ef 100644 --- a/panda/src/text/geomTextGlyph.h +++ b/panda/src/text/geomTextGlyph.h @@ -42,6 +42,7 @@ public: GeomTextGlyph(const GeomTextGlyph ©); void operator = (const GeomTextGlyph ©); virtual ~GeomTextGlyph(); + ALLOC_DELETED_CHAIN(GeomTextGlyph); virtual Geom *make_copy() const; virtual bool copy_primitives_from(const Geom *other); diff --git a/panda/src/tform/mouseSubregion.h b/panda/src/tform/mouseSubregion.h index 506ccbfd33..2ba8d59c3c 100644 --- a/panda/src/tform/mouseSubregion.h +++ b/panda/src/tform/mouseSubregion.h @@ -23,6 +23,8 @@ #include "mouseInterfaceNode.h" #include "luse.h" +#include "linmath_events.h" +#include "buttonEventList.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 04c6c2fe24..9df02df54b 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -471,7 +471,7 @@ has_display_region() const { //////////////////////////////////////////////////////////////////// INLINE void MouseWatcher:: within_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { - region->within(param); + region->within_region(param); throw_event_pattern(_within_pattern, region, ButtonHandle::none()); if (_enter_multiple) { enter_region(region, param); @@ -489,6 +489,6 @@ without_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { if (_enter_multiple) { exit_region(region, param); } - region->without(param); + region->without_region(param); throw_event_pattern(_without_pattern, region, ButtonHandle::none()); } diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index ed270e0c5c..e574671cbb 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -549,7 +549,7 @@ clear_current_regions() { while (old_ri != _current_regions.end()) { // Here's a region we don't have any more. MouseWatcherRegion *old_region = (*old_ri); - old_region->exit(param); + old_region->exit_region(param); throw_event_pattern(_leave_pattern, old_region, ButtonHandle::none()); ++old_ri; } @@ -557,7 +557,7 @@ clear_current_regions() { _current_regions.clear(); if (_preferred_region != (MouseWatcherRegion *)NULL) { - _preferred_region->exit(param); + _preferred_region->exit_region(param); throw_event_pattern(_leave_pattern, _preferred_region, ButtonHandle::none()); _preferred_region = (MouseWatcherRegion *)NULL; } @@ -988,7 +988,7 @@ void MouseWatcher:: enter_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); - region->enter(param); + region->enter_region(param); throw_event_pattern(_enter_pattern, region, ButtonHandle::none()); if (_implicit_click) { MouseWatcherParameter param1(param); @@ -1012,7 +1012,7 @@ exit_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { param1.set_button(MouseButton::one()); region->release(param1); } - region->exit(param); + region->exit_region(param); throw_event_pattern(_leave_pattern, region, ButtonHandle::none()); } diff --git a/panda/src/tform/mouseWatcherRegion.cxx b/panda/src/tform/mouseWatcherRegion.cxx index 1cb945bf2c..90f248a92a 100644 --- a/panda/src/tform/mouseWatcherRegion.cxx +++ b/panda/src/tform/mouseWatcherRegion.cxx @@ -46,7 +46,7 @@ write(ostream &out, int indent_level) const { } //////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::enter +// Function: MouseWatcherRegion::enter_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse enters the region. The mouse is only @@ -55,11 +55,11 @@ write(ostream &out, int indent_level) const { // region before entering the inner one. //////////////////////////////////////////////////////////////////// void MouseWatcherRegion:: -enter(const MouseWatcherParameter &) { +enter_region(const MouseWatcherParameter &) { } //////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::exit +// Function: MouseWatcherRegion::exit_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse exits the region. The mouse is only considered @@ -68,11 +68,11 @@ enter(const MouseWatcherParameter &) { // entering the inner one. //////////////////////////////////////////////////////////////////// void MouseWatcherRegion:: -exit(const MouseWatcherParameter &) { +exit_region(const MouseWatcherParameter &) { } //////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::within +// Function: MouseWatcherRegion::within_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse moves within the boundaries of the region, even @@ -82,18 +82,18 @@ exit(const MouseWatcherParameter &) { // region. //////////////////////////////////////////////////////////////////// void MouseWatcherRegion:: -within(const MouseWatcherParameter &) { +within_region(const MouseWatcherParameter &) { } //////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::without +// Function: MouseWatcherRegion::without_region // Access: Public, Virtual // Description: This is a callback hook function, called whenever the // mouse moves completely outside the boundaries of the -// region. See within(). +// region. See within_region(). //////////////////////////////////////////////////////////////////// void MouseWatcherRegion:: -without(const MouseWatcherParameter &) { +without_region(const MouseWatcherParameter &) { } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tform/mouseWatcherRegion.h b/panda/src/tform/mouseWatcherRegion.h index e0563c59f1..b8a6cc406f 100644 --- a/panda/src/tform/mouseWatcherRegion.h +++ b/panda/src/tform/mouseWatcherRegion.h @@ -70,10 +70,10 @@ PUBLISHED: public: INLINE bool operator < (const MouseWatcherRegion &other) const; - virtual void enter(const MouseWatcherParameter ¶m); - virtual void exit(const MouseWatcherParameter ¶m); - virtual void within(const MouseWatcherParameter ¶m); - virtual void without(const MouseWatcherParameter ¶m); + virtual void enter_region(const MouseWatcherParameter ¶m); + virtual void exit_region(const MouseWatcherParameter ¶m); + virtual void within_region(const MouseWatcherParameter ¶m); + virtual void without_region(const MouseWatcherParameter ¶m); virtual void press(const MouseWatcherParameter ¶m); virtual void release(const MouseWatcherParameter ¶m); virtual void keystroke(const MouseWatcherParameter ¶m); diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index 74ae52756e..2f3fd41fde 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -23,6 +23,8 @@ #include "compose_matrix.h" #include "mouseData.h" #include "modifierButtons.h" +#include "linmath_events.h" +#include "mouseButton.h" TypeHandle Trackball::_type_handle; diff --git a/panda/src/tform/transform2sg.cxx b/panda/src/tform/transform2sg.cxx index 50d995ff43..feef14c073 100644 --- a/panda/src/tform/transform2sg.cxx +++ b/panda/src/tform/transform2sg.cxx @@ -18,6 +18,7 @@ #include "transform2sg.h" #include "transformState.h" +#include "dataNodeTransmit.h" TypeHandle Transform2SG::_type_handle; diff --git a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt index 42f061b1d8..4f3adffb3b 100644 --- a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt @@ -17,7 +17,7 @@ #define yywrap vrmlyywrap #line 20 "lex.yy.c" -/* A lexical scanner generated by flex */ +/* A lexical scanner generated by flex*/ /* Scanner skeleton version: * $Header$ @@ -152,6 +152,15 @@ extern FILE *yyin, *yyout; #define unput(c) yyunput( c, yytext_ptr ) +/* Some routines like yy_flex_realloc() are emitted as static but are + not called by all lexers. This generates warnings in some compilers, + notably GCC. Arrange to suppress these. */ +#ifdef __GNUC__ +#define YY_MAY_BE_UNUSED __attribute__((unused)) +#else +#define YY_MAY_BE_UNUSED +#endif + /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). @@ -258,7 +267,7 @@ YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) YY_MAY_BE_UNUSED; static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer @@ -2594,7 +2603,7 @@ char *yytext; #include "vrmlNode.h" #include "vrmlParser.h" #include "indent.h" -#include "notify.h" +#include "pnotify.h" static int yyinput(void); // declared by flex. extern "C" int vrmlyywrap(); @@ -2785,7 +2794,7 @@ void extract_vec(double vec[], int num_elements) { /* Legal other characters in an identifier */ /*idRestChar ([^\x00-\x20\x22\x23\x27\x2b-\x2e\x5b-\x5d\x7b\x7d])*/ /* Allow hyphen (0x2d) in identifiers. */ -#line 2790 "lex.yy.c" +#line 2799 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -2984,7 +2993,7 @@ YY_DECL /* This is more complicated than they really need to be because */ /* I was ambitious and made the whitespace-matching rule aggressive */ -#line 2989 "lex.yy.c" +#line 2998 "lex.yy.c" if ( yy_init ) { @@ -3531,7 +3540,7 @@ YY_RULE_SETUP #line 570 "vrmlLexer.lxx" ECHO; YY_BREAK -#line 3536 "lex.yy.c" +#line 3545 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(NODE): case YY_STATE_EOF(SFB): @@ -3934,6 +3943,7 @@ register char *yy_bp; #endif /* ifndef YY_NO_UNPUT */ +#ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput() #else @@ -4005,7 +4015,7 @@ static int input() return c; } - +#endif /* YY_NO_INPUT */ #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) diff --git a/pandatool/src/vrml/vrmlParser.cxx.prebuilt b/pandatool/src/vrml/vrmlParser.cxx.prebuilt index 103e49f930..fd68dab5c7 100644 --- a/pandatool/src/vrml/vrmlParser.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlParser.cxx.prebuilt @@ -1,48 +1,137 @@ -/* A Bison parser, made from vrmlParser.yxx - by GNU bison 1.35. */ +/* A Bison parser, made by GNU Bison 2.0. */ -#define YYBISON 1 /* Identify Bison output. */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ #define yyparse vrmlyyparse -#define yylex vrmlyylex +#define yylex vrmlyylex #define yyerror vrmlyyerror -#define yylval vrmlyylval -#define yychar vrmlyychar +#define yylval vrmlyylval +#define yychar vrmlyychar #define yydebug vrmlyydebug #define yynerrs vrmlyynerrs -# define IDENTIFIER 257 -# define DEF 258 -# define USE 259 -# define PROTO 260 -# define EXTERNPROTO 261 -# define TO 262 -# define IS 263 -# define ROUTE 264 -# define SFN_NULL 265 -# define EVENTIN 266 -# define EVENTOUT 267 -# define FIELD 268 -# define EXPOSEDFIELD 269 -# define SFBOOL 270 -# define SFCOLOR 271 -# define SFFLOAT 272 -# define SFIMAGE 273 -# define SFINT32 274 -# define SFNODE 275 -# define SFROTATION 276 -# define SFSTRING 277 -# define SFTIME 278 -# define SFVEC2F 279 -# define SFVEC3F 280 -# define MFCOLOR 281 -# define MFFLOAT 282 -# define MFINT32 283 -# define MFROTATION 284 -# define MFSTRING 285 -# define MFVEC2F 286 -# define MFVEC3F 287 -# define MFNODE 288 + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + IDENTIFIER = 258, + DEF = 259, + USE = 260, + PROTO = 261, + EXTERNPROTO = 262, + TO = 263, + IS = 264, + ROUTE = 265, + SFN_NULL = 266, + EVENTIN = 267, + EVENTOUT = 268, + FIELD = 269, + EXPOSEDFIELD = 270, + SFBOOL = 271, + SFCOLOR = 272, + SFFLOAT = 273, + SFIMAGE = 274, + SFINT32 = 275, + SFNODE = 276, + SFROTATION = 277, + SFSTRING = 278, + SFTIME = 279, + SFVEC2F = 280, + SFVEC3F = 281, + MFCOLOR = 282, + MFFLOAT = 283, + MFINT32 = 284, + MFROTATION = 285, + MFSTRING = 286, + MFVEC2F = 287, + MFVEC3F = 288, + MFNODE = 289 + }; +#endif +#define IDENTIFIER 258 +#define DEF 259 +#define USE 260 +#define PROTO 261 +#define EXTERNPROTO 262 +#define TO 263 +#define IS 264 +#define ROUTE 265 +#define SFN_NULL 266 +#define EVENTIN 267 +#define EVENTOUT 268 +#define FIELD 269 +#define EXPOSEDFIELD 270 +#define SFBOOL 271 +#define SFCOLOR 272 +#define SFFLOAT 273 +#define SFIMAGE 274 +#define SFINT32 275 +#define SFNODE 276 +#define SFROTATION 277 +#define SFSTRING 278 +#define SFTIME 279 +#define SFVEC2F 280 +#define SFVEC3F 281 +#define MFCOLOR 282 +#define MFFLOAT 283 +#define MFINT32 284 +#define MFROTATION 285 +#define MFSTRING 286 +#define MFVEC2F 287 +#define MFVEC3F 288 +#define MFNODE 289 + + + + +/* Copy the first part of user declarations. */ #line 27 "vrmlParser.yxx" @@ -63,7 +152,7 @@ #include "vrmlLexerDefs.h" #include "vrmlNodeType.h" #include "vrmlNode.h" -#include "notify.h" +#include "pnotify.h" #include "plist.h" #include @@ -108,8 +197,8 @@ int addEventIn(const char *type, const char *name, const VrmlFieldValue *dflt = int addEventOut(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); int addExposedField(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); int add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), - const char *typeString, const char *name, - const VrmlFieldValue *dflt); + const char *typeString, const char *name, + const VrmlFieldValue *dflt); int fieldType(const char *type); void enterNode(const char *); VrmlNode *exitNode(); @@ -136,34 +225,165 @@ vrml_cleanup_parser() { } + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) #line 120 "vrmlParser.yxx" -#ifndef YYSTYPE -typedef union { +typedef union YYSTYPE { char *string; VrmlFieldValue fv; VrmlNode *node; MFArray *mfarray; SFNodeRef nodeRef; VrmlScene *scene; -} yystype; -# define YYSTYPE yystype +} YYSTYPE; +/* Line 190 of yacc.c. */ +#line 254 "y.tab.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif -#ifndef YYDEBUG -# define YYDEBUG 0 + + + +/* Copy the second part of user declarations. */ + + +/* Line 213 of yacc.c. */ +#line 266 "y.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + #endif +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 126 -#define YYFINAL 125 -#define YYFLAG -32768 -#define YYNTBASE 40 +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 40 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 26 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 70 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 125 -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 288 ? yytranslate[x] : 65) +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 289 -/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ -static const char yytranslate[] = +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -190,334 +410,239 @@ static const char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34 + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 }; #if YYDEBUG -static const short yyprhs[] = +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = { - 0, 0, 2, 3, 6, 9, 12, 14, 18, 21, - 23, 25, 26, 36, 37, 38, 47, 48, 51, 55, - 59, 60, 66, 67, 73, 74, 77, 81, 85, 89, - 93, 102, 103, 109, 110, 113, 114, 118, 120, 122, - 126, 130, 131, 137, 143, 149, 151, 153, 155, 157, - 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, - 179, 181, 183, 186, 189, 192, 195, 199, 201, 202 -}; -static const short yyrhs[] = -{ - 41, 0, 0, 41, 42, 0, 41, 43, 0, 41, - 55, 0, 56, 0, 4, 3, 56, 0, 5, 3, - 0, 44, 0, 46, 0, 0, 6, 3, 45, 35, - 49, 36, 37, 41, 38, 0, 0, 0, 7, 3, - 47, 35, 53, 36, 48, 62, 0, 0, 49, 50, - 0, 12, 3, 3, 0, 13, 3, 3, 0, 0, - 14, 3, 3, 51, 62, 0, 0, 15, 3, 3, - 52, 62, 0, 0, 53, 54, 0, 12, 3, 3, - 0, 13, 3, 3, 0, 14, 3, 3, 0, 15, - 3, 3, 0, 10, 3, 39, 3, 8, 3, 39, - 3, 0, 0, 3, 57, 37, 58, 38, 0, 0, - 58, 59, 0, 0, 3, 60, 62, 0, 55, 0, - 43, 0, 12, 3, 3, 0, 13, 3, 3, 0, - 0, 14, 3, 3, 61, 62, 0, 12, 3, 3, - 9, 3, 0, 13, 3, 3, 9, 3, 0, 16, - 0, 17, 0, 27, 0, 18, 0, 28, 0, 19, - 0, 20, 0, 29, 0, 22, 0, 30, 0, 23, - 0, 31, 0, 24, 0, 25, 0, 32, 0, 26, - 0, 33, 0, 21, 42, 0, 21, 11, 0, 34, - 63, 0, 9, 3, 0, 35, 64, 36, 0, 42, - 0, 0, 64, 42, 0 + 0, 0, 3, 5, 6, 9, 12, 15, 17, 21, + 24, 26, 28, 29, 39, 40, 41, 50, 51, 54, + 58, 62, 63, 69, 70, 76, 77, 80, 84, 88, + 92, 96, 105, 106, 112, 113, 116, 117, 121, 123, + 125, 129, 133, 134, 140, 146, 152, 154, 156, 158, + 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, + 180, 182, 184, 186, 189, 192, 195, 198, 202, 204, + 205 }; -#endif - -#if YYDEBUG -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const short yyrline[] = +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = { - 0, 151, 157, 162, 169, 170, 173, 180, 186, 194, - 196, 199, 199, 205, 205, 205, 211, 213, 216, 219, - 221, 221, 232, 232, 245, 247, 250, 253, 255, 257, - 261, 266, 266, 271, 273, 276, 276, 284, 285, 288, - 289, 290, 290, 294, 296, 300, 302, 303, 304, 305, - 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, - 316, 317, 319, 320, 326, 327, 330, 335, 344, 349 + 41, 0, -1, 42, -1, -1, 42, 43, -1, 42, + 44, -1, 42, 56, -1, 57, -1, 4, 3, 57, + -1, 5, 3, -1, 45, -1, 47, -1, -1, 6, + 3, 46, 35, 50, 36, 37, 42, 38, -1, -1, + -1, 7, 3, 48, 35, 54, 36, 49, 63, -1, + -1, 50, 51, -1, 12, 3, 3, -1, 13, 3, + 3, -1, -1, 14, 3, 3, 52, 63, -1, -1, + 15, 3, 3, 53, 63, -1, -1, 54, 55, -1, + 12, 3, 3, -1, 13, 3, 3, -1, 14, 3, + 3, -1, 15, 3, 3, -1, 10, 3, 39, 3, + 8, 3, 39, 3, -1, -1, 3, 58, 37, 59, + 38, -1, -1, 59, 60, -1, -1, 3, 61, 63, + -1, 56, -1, 44, -1, 12, 3, 3, -1, 13, + 3, 3, -1, -1, 14, 3, 3, 62, 63, -1, + 12, 3, 3, 9, 3, -1, 13, 3, 3, 9, + 3, -1, 16, -1, 17, -1, 27, -1, 18, -1, + 28, -1, 19, -1, 20, -1, 29, -1, 22, -1, + 30, -1, 23, -1, 31, -1, 24, -1, 25, -1, + 32, -1, 26, -1, 33, -1, 21, 43, -1, 21, + 11, -1, 34, 64, -1, 9, 3, -1, 35, 65, + 36, -1, 43, -1, -1, 65, 43, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short int yyrline[] = +{ + 0, 151, 151, 159, 162, 169, 170, 174, 180, 186, + 195, 196, 200, 200, 206, 208, 206, 211, 213, 217, + 219, 222, 221, 233, 232, 245, 247, 251, 253, 255, + 257, 262, 267, 267, 271, 273, 277, 277, 284, 285, + 288, 289, 290, 290, 294, 296, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 319, 320, 326, 327, 331, 335, 346, + 349 }; #endif - -#if (YYDEBUG) || defined YYERROR_VERBOSE - -/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$", "error", "$undefined.", "IDENTIFIER", "DEF", "USE", "PROTO", - "EXTERNPROTO", "TO", "IS", "ROUTE", "SFN_NULL", "EVENTIN", "EVENTOUT", - "FIELD", "EXPOSEDFIELD", "SFBOOL", "SFCOLOR", "SFFLOAT", "SFIMAGE", - "SFINT32", "SFNODE", "SFROTATION", "SFSTRING", "SFTIME", "SFVEC2F", - "SFVEC3F", "MFCOLOR", "MFFLOAT", "MFINT32", "MFROTATION", "MFSTRING", - "MFVEC2F", "MFVEC3F", "MFNODE", "'['", "']'", "'{'", "'}'", "'.'", - "vrmlscene", "declarations", "nodeDeclaration", "protoDeclaration", - "proto", "@1", "externproto", "@2", "@3", "interfaceDeclarations", - "interfaceDeclaration", "@4", "@5", "externInterfaceDeclarations", - "externInterfaceDeclaration", "routeDeclaration", "node", "@6", - "nodeGuts", "nodeGut", "@7", "@8", "fieldValue", "mfnodeValue", "nodes", 0 + "$end", "error", "$undefined", "IDENTIFIER", "DEF", "USE", "PROTO", + "EXTERNPROTO", "TO", "IS", "ROUTE", "SFN_NULL", "EVENTIN", "EVENTOUT", + "FIELD", "EXPOSEDFIELD", "SFBOOL", "SFCOLOR", "SFFLOAT", "SFIMAGE", + "SFINT32", "SFNODE", "SFROTATION", "SFSTRING", "SFTIME", "SFVEC2F", + "SFVEC3F", "MFCOLOR", "MFFLOAT", "MFINT32", "MFROTATION", "MFSTRING", + "MFVEC2F", "MFVEC3F", "MFNODE", "'['", "']'", "'{'", "'}'", "'.'", + "$accept", "vrmlscene", "declarations", "nodeDeclaration", + "protoDeclaration", "proto", "@1", "externproto", "@2", "@3", + "interfaceDeclarations", "interfaceDeclaration", "@4", "@5", + "externInterfaceDeclarations", "externInterfaceDeclaration", + "routeDeclaration", "node", "@6", "nodeGuts", "nodeGut", "@7", "@8", + "fieldValue", "mfnodeValue", "nodes", 0 }; #endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const short yyr1[] = +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = { - 0, 40, 41, 41, 41, 41, 42, 42, 42, 43, - 43, 45, 44, 47, 48, 46, 49, 49, 50, 50, - 51, 50, 52, 50, 53, 53, 54, 54, 54, 54, - 55, 57, 56, 58, 58, 60, 59, 59, 59, 59, - 59, 61, 59, 59, 59, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 63, 63, 64, 64 + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 91, 93, 123, 125, 46 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 40, 41, 42, 42, 42, 42, 43, 43, 43, + 44, 44, 46, 45, 48, 49, 47, 50, 50, 51, + 51, 52, 51, 53, 51, 54, 54, 55, 55, 55, + 55, 56, 58, 57, 59, 59, 61, 60, 60, 60, + 60, 60, 62, 60, 60, 60, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 64, 64, 65, + 65 }; -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const short yyr2[] = +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = { - 0, 1, 0, 2, 2, 2, 1, 3, 2, 1, - 1, 0, 9, 0, 0, 8, 0, 2, 3, 3, - 0, 5, 0, 5, 0, 2, 3, 3, 3, 3, - 8, 0, 5, 0, 2, 0, 3, 1, 1, 3, - 3, 0, 5, 5, 5, 1, 1, 1, 1, 1, + 0, 2, 1, 0, 2, 2, 2, 1, 3, 2, + 1, 1, 0, 9, 0, 0, 8, 0, 2, 3, + 3, 0, 5, 0, 5, 0, 2, 3, 3, 3, + 3, 8, 0, 5, 0, 2, 0, 3, 1, 1, + 3, 3, 0, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 2, 2, 3, 1, 0, 2 + 1, 1, 1, 2, 2, 2, 2, 3, 1, 0, + 2 }; -/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ -static const short yydefact[] = +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = { - 2, 1, 31, 0, 0, 0, 0, 0, 3, 4, - 9, 10, 5, 6, 0, 0, 8, 11, 13, 0, - 33, 7, 0, 0, 0, 0, 16, 24, 0, 35, - 0, 0, 0, 32, 38, 37, 34, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, - 0, 0, 0, 0, 14, 25, 0, 0, 45, 46, - 48, 50, 51, 0, 53, 55, 57, 58, 60, 47, - 49, 52, 54, 56, 59, 61, 0, 36, 39, 40, - 41, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 65, 63, 62, 68, 67, 64, 0, 0, - 0, 18, 19, 20, 22, 0, 26, 27, 28, 29, - 15, 30, 0, 43, 44, 42, 0, 0, 12, 66, - 69, 21, 23, 0, 0, 0 + 3, 0, 2, 1, 32, 0, 0, 0, 0, 0, + 4, 5, 10, 11, 6, 7, 0, 0, 9, 12, + 14, 0, 34, 8, 0, 0, 0, 0, 17, 25, + 0, 36, 0, 0, 0, 33, 39, 38, 35, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 0, 0, 0, 0, 15, 26, 0, 0, + 46, 47, 49, 51, 52, 0, 54, 56, 58, 59, + 61, 48, 50, 53, 55, 57, 60, 62, 0, 37, + 40, 41, 42, 0, 0, 0, 0, 3, 0, 0, + 0, 0, 0, 0, 66, 64, 63, 69, 68, 65, + 0, 0, 0, 19, 20, 21, 23, 0, 27, 28, + 29, 30, 16, 31, 0, 44, 45, 43, 0, 0, + 13, 67, 70, 22, 24 }; -static const short yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = { - 123, 1, 8, 9, 10, 22, 11, 23, 90, 37, - 49, 116, 117, 38, 55, 12, 13, 14, 25, 36, - 40, 100, 77, 97, 112 + -1, 1, 2, 10, 11, 12, 24, 13, 25, 92, + 39, 51, 118, 119, 40, 57, 14, 15, 16, 27, + 38, 42, 102, 79, 99, 114 }; -static const short yypact[] = +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -73 +static const yysigned_char yypact[] = { - -32768, 79,-32768, -1, 0, 3, 4, 6,-32768,-32768, - -32768,-32768,-32768,-32768, -23, 18,-32768,-32768,-32768, -10, - -32768,-32768, 5, 7, 32, -2,-32768,-32768, 33,-32768, - 40, 41, 45,-32768,-32768,-32768,-32768, 19, 66, 48, - 43, 50, 51, 54, 84, 85, 87, 88, 55,-32768, - 90, 91, 92, 93,-32768,-32768, 58, 95,-32768,-32768, - -32768,-32768,-32768, 34,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768, 23,-32768, 94, 96, - -32768, 97, 98, 101, 103,-32768, 104, 105, 106, 107, - 43, 108,-32768,-32768,-32768,-32768,-32768,-32768, 109, 110, - 43,-32768,-32768,-32768,-32768, 12,-32768,-32768,-32768,-32768, - -32768,-32768, 20,-32768,-32768,-32768, 43, 43,-32768,-32768, - -32768,-32768,-32768, 99, 114,-32768 + -73, 2, 79, -73, -73, 0, 3, 4, 6, 11, + -73, -73, -73, -73, -73, -73, -16, 26, -73, -73, + -73, -4, -73, -73, 5, 7, 38, -2, -73, -73, + 35, -73, 41, 45, 48, -73, -73, -73, -73, 19, + 66, 50, 43, 51, 54, 84, 85, 87, 88, 89, + 56, -73, 91, 92, 93, 94, -73, -73, 59, 96, + -73, -73, -73, -73, -73, 34, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, -73, -73, 23, -73, + 95, 97, -73, 98, 100, 102, 104, -73, 105, 106, + 107, 108, 43, 109, -73, -73, -73, -73, -73, -73, + 110, 111, 43, -73, -73, -73, -73, 12, -73, -73, + -73, -73, -73, -73, 20, -73, -73, -73, 43, 43, + -73, -73, -73, -73, -73 }; -static const short yypgoto[] = +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = { - -32768, 30, -63, 100,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768, 102, 111,-32768,-32768,-32768, - -32768,-32768, -70,-32768,-32768 + -73, -73, 13, -65, 90, -73, -73, -73, -73, -73, + -73, -73, -73, -73, -73, -73, 99, 101, -73, -73, + -73, -73, -73, -72, -73, -73 }; - -#define YYLAST 127 - - -static const short yytable[] = +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = { - 94, 29, 15, 16, 5, 6, 17, 18, 7, 19, - 30, 31, 32, 96, 20, 2, 3, 4, 5, 6, - 110, 2, 7, 2, 3, 4, 2, 3, 4, 24, - 115, 44, 45, 46, 47, 28, 33, 2, 3, 4, - 26, 39, 27, 41, 42, 93, 121, 122, 43, 120, - 118, 56, 57, 78, 79, 48, 119, 80, 95, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 50, 51, - 52, 53, 2, 3, 4, 5, 6, 81, 82, 7, - 83, 84, 85, 86, 87, 88, 89, 91, 92, 124, - 101, 102, 54, 98, 103, 99, 104, 106, 107, 108, - 109, 111, 113, 114, 125, 105, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 34, 21, 35 + 96, 31, 3, 17, 7, 8, 18, 19, 9, 20, + 32, 33, 34, 98, 21, 4, 5, 6, 7, 8, + 112, 22, 9, 4, 5, 6, 4, 5, 6, 4, + 117, 46, 47, 48, 49, 26, 35, 4, 5, 6, + 28, 30, 29, 41, 43, 95, 123, 124, 44, 122, + 120, 45, 59, 58, 80, 50, 121, 81, 97, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 52, 53, + 54, 55, 4, 5, 6, 7, 8, 82, 83, 9, + 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, + 107, 103, 56, 104, 100, 105, 101, 106, 108, 109, + 110, 111, 113, 115, 116, 0, 0, 36, 23, 0, + 0, 0, 0, 0, 0, 0, 37 }; -static const short yycheck[] = +static const yysigned_char yycheck[] = { - 63, 3, 3, 3, 6, 7, 3, 3, 10, 3, - 12, 13, 14, 76, 37, 3, 4, 5, 6, 7, - 90, 3, 10, 3, 4, 5, 3, 4, 5, 39, - 100, 12, 13, 14, 15, 3, 38, 3, 4, 5, - 35, 8, 35, 3, 3, 11, 116, 117, 3, 112, + 65, 3, 0, 3, 6, 7, 3, 3, 10, 3, + 12, 13, 14, 78, 3, 3, 4, 5, 6, 7, + 92, 37, 10, 3, 4, 5, 3, 4, 5, 3, + 102, 12, 13, 14, 15, 39, 38, 3, 4, 5, + 35, 3, 35, 8, 3, 11, 118, 119, 3, 114, 38, 3, 9, 3, 3, 36, 36, 3, 35, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 12, 13, 14, 15, 3, 4, 5, 6, 7, 3, 3, 10, - 3, 3, 37, 3, 3, 3, 3, 39, 3, 0, - 3, 3, 36, 9, 3, 9, 3, 3, 3, 3, - 3, 3, 3, 3, 0, 85, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 25, 15, 25 + 3, 3, 3, 37, 3, 3, 3, 3, 39, 3, + 87, 3, 36, 3, 9, 3, 9, 3, 3, 3, + 3, 3, 3, 3, 3, -1, -1, 27, 17, -1, + -1, -1, -1, -1, -1, -1, 27 }; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison/bison.simple" -/* Skeleton output parser for bison, - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser when - the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = { - short yyss; - YYSTYPE yyvs; -# if YYLSP_NEEDED - YYLTYPE yyls; -# endif + 0, 41, 42, 0, 3, 4, 5, 6, 7, 10, + 43, 44, 45, 47, 56, 57, 58, 3, 3, 3, + 3, 3, 37, 57, 46, 48, 39, 59, 35, 35, + 3, 3, 12, 13, 14, 38, 44, 56, 60, 50, + 54, 8, 61, 3, 3, 3, 12, 13, 14, 15, + 36, 51, 12, 13, 14, 15, 36, 55, 3, 9, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 63, + 3, 3, 3, 3, 3, 3, 3, 37, 3, 3, + 3, 3, 49, 39, 3, 11, 43, 35, 43, 64, + 9, 9, 62, 3, 3, 3, 3, 42, 3, 3, + 3, 3, 63, 3, 65, 3, 3, 63, 52, 53, + 38, 36, 43, 63, 63 }; -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# if YYLSP_NEEDED -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAX) -# else -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAX) -# endif - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - - #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif @@ -536,71 +661,93 @@ union yyalloc #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 +#define YYEMPTY (-2) #define YYEOF 0 + #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ + #define YYFAIL goto yyerrlab + #define YYRECOVERING() (!!yyerrstatus) + #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ - yychar1 = YYTRANSLATE (yychar); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ - yyerror ("syntax error: cannot back up"); \ + yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) + #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). - - When YYLLOC_DEFAULT is run, CURRENT is set the location of the - first token. By default, to implement support for ranges, extend - its range to the last symbol. */ +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ -#if YYPURE -# if YYLSP_NEEDED -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval, &yylloc) -# endif -# else /* !YYLSP_NEEDED */ -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval) -# endif -# endif /* !YYLSP_NEEDED */ -#else /* !YYPURE */ -# define YYLEX yylex () -#endif /* !YYPURE */ - +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -615,13 +762,86 @@ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ + /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 @@ -634,15 +854,13 @@ int yydebug; SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif + -#ifdef YYERROR_VERBOSE + +#if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) @@ -692,86 +910,139 @@ yystpcpy (yydest, yysrc) } # endif # endif -#endif + +#endif /* !YYERROR_VERBOSE */ + -#line 315 "/usr/share/bison/bison.simple" + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -# define YYPARSE_PARAM_DECL +int yyparse (void *YYPARSE_PARAM); # else -# define YYPARSE_PARAM_ARG YYPARSE_PARAM -# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +int yyparse (); # endif -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG -# define YYPARSE_PARAM_DECL -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -int yyparse (void *); -# else +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int yyparse (void); -# endif +#else +int yyparse (); #endif +#endif /* ! YYPARSE_PARAM */ -/* YY_DECL_VARIABLES -- depending whether we use a pure parser, - variables are global, or local to YYPARSE. */ -#define YY_DECL_NON_LSP_VARIABLES \ -/* The lookahead symbol. */ \ -int yychar; \ - \ -/* The semantic value of the lookahead symbol. */ \ -YYSTYPE yylval; \ - \ -/* Number of parse errors so far. */ \ + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ int yynerrs; -#if YYLSP_NEEDED -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES \ - \ -/* Location data for the lookahead symbol. */ \ -YYLTYPE yylloc; -#else -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES -#endif -/* If nonreentrant, generate the variables here. */ - -#if !YYPURE -YY_DECL_VARIABLES -#endif /* !YYPURE */ +/*----------. +| yyparse. | +`----------*/ +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - /* If reentrant, generate the variables here. */ -#if YYPURE - YY_DECL_VARIABLES -#endif /* !YYPURE */ +yyparse (void) +#else +int +yyparse () +#endif +#endif +{ + register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yychar1 = 0; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, @@ -781,41 +1052,29 @@ yyparse (YYPARSE_PARAM_ARG) Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; -#if YYLSP_NEEDED - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#endif -#if YYLSP_NEEDED -# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -# define YYPOPSTACK (yyvsp--, yyssp--) -#endif + +#define YYPOPSTACK (yyvsp--, yyssp--) YYSIZE_T yystacksize = YYINITDEPTH; - /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYLSP_NEEDED - YYLTYPE yyloc; -#endif + /* When reducing, the number of symbols on the RHS of the reduced - rule. */ + rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); @@ -832,9 +1091,10 @@ yyparse (YYPARSE_PARAM_ARG) yyssp = yyss; yyvsp = yyvs; -#if YYLSP_NEEDED - yylsp = yyls; -#endif + + + yyvsp[0] = yylval; + goto yysetstate; /*------------------------------------------------------------. @@ -849,7 +1109,7 @@ yyparse (YYPARSE_PARAM_ARG) yysetstate: *yyssp = yystate; - if (yyssp >= yyss + yystacksize - 1) + if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; @@ -860,26 +1120,19 @@ yyparse (YYPARSE_PARAM_ARG) these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; + short int *yyss1 = yyss; + /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. */ -# if YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), + &yystacksize); - yyls = yyls1; -# else - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); -# endif + yyss = yyss1; yyvs = yyvs1; } @@ -888,24 +1141,22 @@ yyparse (YYPARSE_PARAM_ARG) goto yyoverflowlab; # else /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) + if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) + if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - short *yyss1 = yyss; + short int *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); -# if YYLSP_NEEDED - YYSTACK_RELOCATE (yyls); -# endif -# undef YYSTACK_RELOCATE + +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } @@ -914,14 +1165,12 @@ yyparse (YYPARSE_PARAM_ARG) yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; -#if YYLSP_NEEDED - yylsp = yyls + yysize - 1; -#endif + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); - if (yyssp >= yyss + yystacksize - 1) + if (yyss + yystacksize - 1 <= yyssp) YYABORT; } @@ -929,101 +1178,67 @@ yyparse (YYPARSE_PARAM_ARG) goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ +/* Read a look-ahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yyn == YYFLAG) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ + /* Not known => get a look-ahead token if don't already have one. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ + if (yychar <= YYEOF) { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - + yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { - yychar1 = YYTRANSLATE (yychar); - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables - which are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - YYFPRINTF (stderr, "Next token is %d (%s", - yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise - meaning of a token, for further debugging info. */ -# ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -# endif - YYFPRINTF (stderr, ")\n"); - } -#endif + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) + if (yyn <= 0) { - if (yyn == YYFLAG) + if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } - else if (yyn == 0) - goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", - yychar, yytname[yychar1])); + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif + /* Count tokens shifted since error; after three, turn off error status. */ @@ -1054,290 +1269,296 @@ yyreduce: /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. - Otherwise, the following line sets YYVAL to the semantic value of - the lookahead token. This behavior is undocumented and Bison + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; -#if YYLSP_NEEDED - /* Similarly for the default location. Let the user run additional - commands if for instance locations are ranges. */ - yyloc = yylsp[1-yylen]; - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); -#endif -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables which - are defined only if `YYDEBUG' is set. */ - if (yydebug) + YY_REDUCE_PRINT (yyn); + switch (yyn) { - int yyi; - - YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - switch (yyn) { - -case 1: + case 2: #line 152 "vrmlParser.yxx" -{ - parsed_scene = yyvsp[0].scene; + { + parsed_scene = (yyvsp[0].scene); } break; -case 2: + + case 3: #line 159 "vrmlParser.yxx" -{ - yyval.scene = new VrmlScene; + { + (yyval.scene) = new VrmlScene; } break; -case 3: + + case 4: #line 163 "vrmlParser.yxx" -{ + { Declaration d; - d._node = yyvsp[0].nodeRef; - yyvsp[-1].scene->push_back(d); - yyval.scene = yyvsp[-1].scene; + d._node = (yyvsp[0].nodeRef); + (yyvsp[-1].scene)->push_back(d); + (yyval.scene) = (yyvsp[-1].scene); } break; -case 6: + + case 7: #line 175 "vrmlParser.yxx" -{ - yyval.nodeRef._p = yyvsp[0].node; - yyval.nodeRef._type = SFNodeRef::T_unnamed; - yyval.nodeRef._name = NULL; + { + (yyval.nodeRef)._p = (yyvsp[0].node); + (yyval.nodeRef)._type = SFNodeRef::T_unnamed; + (yyval.nodeRef)._name = NULL; } break; -case 7: + + case 8: #line 181 "vrmlParser.yxx" -{ - yyval.nodeRef._p = yyvsp[0].node; - yyval.nodeRef._type = SFNodeRef::T_def; - yyval.nodeRef._name = yyvsp[-1].string; + { + (yyval.nodeRef)._p = (yyvsp[0].node); + (yyval.nodeRef)._type = SFNodeRef::T_def; + (yyval.nodeRef)._name = (yyvsp[-1].string); } break; -case 8: + + case 9: #line 187 "vrmlParser.yxx" -{ - yyval.nodeRef._p = NULL; - yyval.nodeRef._type = SFNodeRef::T_use; - yyval.nodeRef._name = yyvsp[0].string; + { + (yyval.nodeRef)._p = NULL; + (yyval.nodeRef)._type = SFNodeRef::T_use; + (yyval.nodeRef)._name = (yyvsp[0].string); } break; -case 11: + + case 12: #line 200 "vrmlParser.yxx" -{ beginProto(yyvsp[0].string); } + { beginProto((yyvsp[0].string)); } break; -case 12: + + case 13: #line 202 "vrmlParser.yxx" -{ endProto(); free(yyvsp[-7].string);} + { endProto(); free((yyvsp[-7].string));} break; -case 13: + + case 14: #line 206 "vrmlParser.yxx" -{ beginProto(yyvsp[0].string); } + { beginProto((yyvsp[0].string)); } break; -case 14: + + case 15: #line 208 "vrmlParser.yxx" -{ expect(MFSTRING); } + { expect(MFSTRING); } break; -case 15: + + case 16: #line 209 "vrmlParser.yxx" -{ endProto(); free(yyvsp[-6].string); } + { endProto(); free((yyvsp[-6].string)); } break; -case 18: + + case 19: #line 217 "vrmlParser.yxx" -{ addEventIn(yyvsp[-1].string, yyvsp[0].string); - free(yyvsp[-1].string); free(yyvsp[0].string); } + { addEventIn((yyvsp[-1].string), (yyvsp[0].string)); + free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 19: + + case 20: #line 219 "vrmlParser.yxx" -{ addEventOut(yyvsp[-1].string, yyvsp[0].string); - free(yyvsp[-1].string); free(yyvsp[0].string); } + { addEventOut((yyvsp[-1].string), (yyvsp[0].string)); + free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 20: + + case 21: #line 222 "vrmlParser.yxx" -{ - int type = fieldType(yyvsp[-1].string); + { + int type = fieldType((yyvsp[-1].string)); expect(type); } break; -case 21: + + case 22: #line 227 "vrmlParser.yxx" -{ - addField(yyvsp[-3].string, yyvsp[-2].string, &(yyvsp[0].fv)); - free(yyvsp[-3].string); - free(yyvsp[-2].string); + { + addField((yyvsp[-3].string), (yyvsp[-2].string), &((yyvsp[0].fv))); + free((yyvsp[-3].string)); + free((yyvsp[-2].string)); } break; -case 22: + + case 23: #line 233 "vrmlParser.yxx" -{ - int type = fieldType(yyvsp[-1].string); + { + int type = fieldType((yyvsp[-1].string)); expect(type); } break; -case 23: + + case 24: #line 238 "vrmlParser.yxx" -{ - addExposedField(yyvsp[-3].string, yyvsp[-2].string, &(yyvsp[0].fv)); - free(yyvsp[-3].string); - free(yyvsp[-2].string); + { + addExposedField((yyvsp[-3].string), (yyvsp[-2].string), &((yyvsp[0].fv))); + free((yyvsp[-3].string)); + free((yyvsp[-2].string)); } break; -case 26: + + case 27: #line 251 "vrmlParser.yxx" -{ addEventIn(yyvsp[-1].string, yyvsp[0].string); - free(yyvsp[-1].string); free(yyvsp[0].string); } + { addEventIn((yyvsp[-1].string), (yyvsp[0].string)); + free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 27: + + case 28: #line 253 "vrmlParser.yxx" -{ addEventOut(yyvsp[-1].string, yyvsp[0].string); - free(yyvsp[-1].string); free(yyvsp[0].string); } + { addEventOut((yyvsp[-1].string), (yyvsp[0].string)); + free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 28: + + case 29: #line 255 "vrmlParser.yxx" -{ addField(yyvsp[-1].string, yyvsp[0].string); - free(yyvsp[-1].string); free(yyvsp[0].string); } + { addField((yyvsp[-1].string), (yyvsp[0].string)); + free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 29: + + case 30: #line 257 "vrmlParser.yxx" -{ addExposedField(yyvsp[-1].string, yyvsp[0].string); - free(yyvsp[-1].string); free(yyvsp[0].string); } + { addExposedField((yyvsp[-1].string), (yyvsp[0].string)); + free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 30: + + case 31: #line 263 "vrmlParser.yxx" -{ free(yyvsp[-6].string); free(yyvsp[-4].string); free(yyvsp[-2].string); free(yyvsp[0].string); } + { free((yyvsp[-6].string)); free((yyvsp[-4].string)); free((yyvsp[-2].string)); free((yyvsp[0].string)); } break; -case 31: + + case 32: #line 267 "vrmlParser.yxx" -{ enterNode(yyvsp[0].string); } + { enterNode((yyvsp[0].string)); } break; -case 32: + + case 33: #line 268 "vrmlParser.yxx" -{ yyval.node = exitNode(); free(yyvsp[-4].string);} + { (yyval.node) = exitNode(); free((yyvsp[-4].string));} break; -case 35: + + case 36: #line 277 "vrmlParser.yxx" -{ enterField(yyvsp[0].string); } + { enterField((yyvsp[0].string)); } break; -case 36: + + case 37: #line 279 "vrmlParser.yxx" -{ - storeField(yyvsp[0].fv); + { + storeField((yyvsp[0].fv)); exitField(); - free(yyvsp[-2].string); + free((yyvsp[-2].string)); } break; -case 39: + + case 40: #line 288 "vrmlParser.yxx" -{ inScript(); free(yyvsp[-1].string); free(yyvsp[0].string); } + { inScript(); free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 40: + + case 41: #line 289 "vrmlParser.yxx" -{ inScript(); free(yyvsp[-1].string); free(yyvsp[0].string); } + { inScript(); free((yyvsp[-1].string)); free((yyvsp[0].string)); } break; -case 41: + + case 42: #line 290 "vrmlParser.yxx" -{ inScript(); - int type = fieldType(yyvsp[-1].string); + { inScript(); + int type = fieldType((yyvsp[-1].string)); expect(type); } break; -case 42: + + case 43: #line 293 "vrmlParser.yxx" -{ free(yyvsp[-3].string); free(yyvsp[-2].string); } + { free((yyvsp[-3].string)); free((yyvsp[-2].string)); } break; -case 43: + + case 44: #line 295 "vrmlParser.yxx" -{ inScript(); free(yyvsp[-3].string); free(yyvsp[-2].string); free(yyvsp[0].string); } + { inScript(); free((yyvsp[-3].string)); free((yyvsp[-2].string)); free((yyvsp[0].string)); } break; -case 44: + + case 45: #line 297 "vrmlParser.yxx" -{ inScript(); free(yyvsp[-3].string); free(yyvsp[-2].string); free(yyvsp[0].string); } + { inScript(); free((yyvsp[-3].string)); free((yyvsp[-2].string)); free((yyvsp[0].string)); } break; -case 62: + + case 63: #line 319 "vrmlParser.yxx" -{ yyval.fv._sfnode = yyvsp[0].nodeRef; } + { (yyval.fv)._sfnode = (yyvsp[0].nodeRef); } break; -case 63: + + case 64: #line 321 "vrmlParser.yxx" -{ - yyval.fv._sfnode._p = NULL; - yyval.fv._sfnode._type = SFNodeRef::T_null; - yyval.fv._sfnode._name = NULL; + { + (yyval.fv)._sfnode._p = NULL; + (yyval.fv)._sfnode._type = SFNodeRef::T_null; + (yyval.fv)._sfnode._name = NULL; } break; -case 64: + + case 65: #line 326 "vrmlParser.yxx" -{ yyval.fv._mf = yyvsp[0].mfarray; } + { (yyval.fv)._mf = (yyvsp[0].mfarray); } break; -case 65: + + case 66: #line 327 "vrmlParser.yxx" -{ free(yyvsp[0].string); } + { free((yyvsp[0].string)); } break; -case 66: + + case 67: #line 332 "vrmlParser.yxx" -{ - yyval.mfarray = yyvsp[-1].mfarray; + { + (yyval.mfarray) = (yyvsp[-1].mfarray); } break; -case 67: + + case 68: #line 336 "vrmlParser.yxx" -{ - yyval.mfarray = new MFArray; + { + (yyval.mfarray) = new MFArray; VrmlFieldValue v; - v._sfnode = yyvsp[0].nodeRef; - yyval.mfarray->push_back(v); + v._sfnode = (yyvsp[0].nodeRef); + (yyval.mfarray)->push_back(v); } break; -case 68: + + case 69: #line 346 "vrmlParser.yxx" -{ - yyval.mfarray = new MFArray; + { + (yyval.mfarray) = new MFArray; } break; -case 69: + + case 70: #line 350 "vrmlParser.yxx" -{ + { VrmlFieldValue v; - v._sfnode = yyvsp[0].nodeRef; - yyvsp[-1].mfarray->push_back(v); - yyval.mfarray = yyvsp[-1].mfarray; + v._sfnode = (yyvsp[0].nodeRef); + (yyvsp[-1].mfarray)->push_back(v); + (yyval.mfarray) = (yyvsp[-1].mfarray); } break; -} -#line 705 "/usr/share/bison/bison.simple" + } + +/* Line 1037 of yacc.c. */ +#line 1553 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; -#if YYLSP_NEEDED - yylsp -= yylen; -#endif -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif + + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -#if YYLSP_NEEDED - *++yylsp = yyloc; -#endif + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule @@ -1345,11 +1566,11 @@ case 69: yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -1362,155 +1583,159 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; - -#ifdef YYERROR_VERBOSE +#if YYERROR_VERBOSE yyn = yypact[yystate]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; char *yymsg; - int yyx, yycount; + int yyx; - yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("parse error, unexpected ") + 1; - yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { - char *yyp = yystpcpy (yymsg, "parse error, unexpected "); - yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx) + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); + yyp = yystpcpy (yyp, yyprefix); yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; + yyprefix = " or "; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else - yyerror ("parse error; also virtual memory exhausted"); + yyerror ("syntax error; also virtual memory exhausted"); } else -#endif /* defined (YYERROR_VERBOSE) */ - yyerror ("parse error"); +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + yydestruct ("Error: popping", + yystos[*yyssp], yyvsp); + } + } + else + { + yydestruct ("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ goto yyerrlab1; -/*--------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action | -`--------------------------------------------------*/ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + +yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ yyerrlab1: - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ - /* return failure if at end of input */ - if (yychar == YYEOF) + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) YYABORT; - YYDPRINTF ((stderr, "Discarding token %d (%s).\n", - yychar, yytname[yychar1])); - yychar = YYEMPTY; + + + yydestruct ("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - /* Else will try to reuse lookahead token after shifting the error - token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - - -/*-------------------------------------------------------------------. -| yyerrdefault -- current state does not do anything special for the | -| error token. | -`-------------------------------------------------------------------*/ -yyerrdefault: -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - - /* If its default is to accept any token, ok. Otherwise pop it. */ - yyn = yydefact[yystate]; - if (yyn) - goto yydefault; -#endif - - -/*---------------------------------------------------------------. -| yyerrpop -- pop the current state because it cannot handle the | -| error token | -`---------------------------------------------------------------*/ -yyerrpop: - if (yyssp == yyss) - YYABORT; - yyvsp--; - yystate = *--yyssp; -#if YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "Error: state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - -/*--------------. -| yyerrhandle. | -`--------------*/ -yyerrhandle: - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - if (yyn == YYFINAL) YYACCEPT; - YYDPRINTF ((stderr, "Shifting error token, ")); - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -1527,16 +1752,21 @@ yyacceptlab: | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: + yydestruct ("Error: discarding lookahead", + yytoken, &yylval); + yychar = YYEMPTY; yyresult = 1; goto yyreturn; -/*---------------------------------------------. -| yyoverflowab -- parser overflow comes here. | -`---------------------------------------------*/ +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ +#endif yyreturn: #ifndef yyoverflow @@ -1545,6 +1775,8 @@ yyreturn: #endif return yyresult; } + + #line 358 "vrmlParser.yxx" @@ -1577,26 +1809,26 @@ endProto() int addField(const char *type, const char *name, - const VrmlFieldValue *dflt) + const VrmlFieldValue *dflt) { return add(&VrmlNodeType::addField, type, name, dflt); } int addEventIn(const char *type, const char *name, - const VrmlFieldValue *dflt) + const VrmlFieldValue *dflt) { return add(&VrmlNodeType::addEventIn, type, name, dflt); } int addEventOut(const char *type, const char *name, - const VrmlFieldValue *dflt) + const VrmlFieldValue *dflt) { return add(&VrmlNodeType::addEventOut, type, name, dflt); } int addExposedField(const char *type, const char *name, - const VrmlFieldValue *dflt) + const VrmlFieldValue *dflt) { return add(&VrmlNodeType::addExposedField, type, name, dflt); } @@ -1716,9 +1948,9 @@ enterField(const char *fieldName) return; const VrmlNodeType::NameTypeRec *typeRec = - fr->nodeType->hasField(fieldName); + fr->nodeType->hasField(fieldName); if (typeRec != NULL) { - fr->typeRec = typeRec; + fr->typeRec = typeRec; // Let the lexer know what field type to expect: expect(typeRec->type); } @@ -1761,3 +1993,4 @@ expect(int type) expectToken = type; } + diff --git a/pandatool/src/vrml/vrmlParser.h.prebuilt b/pandatool/src/vrml/vrmlParser.h.prebuilt index ee0e5475a5..5eb392111d 100644 --- a/pandatool/src/vrml/vrmlParser.h.prebuilt +++ b/pandatool/src/vrml/vrmlParser.h.prebuilt @@ -1,52 +1,122 @@ -#ifndef BISON_Y_TAB_H -# define BISON_Y_TAB_H +/* A Bison parser, made by GNU Bison 2.0. */ -#ifndef YYSTYPE -typedef union { +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + IDENTIFIER = 258, + DEF = 259, + USE = 260, + PROTO = 261, + EXTERNPROTO = 262, + TO = 263, + IS = 264, + ROUTE = 265, + SFN_NULL = 266, + EVENTIN = 267, + EVENTOUT = 268, + FIELD = 269, + EXPOSEDFIELD = 270, + SFBOOL = 271, + SFCOLOR = 272, + SFFLOAT = 273, + SFIMAGE = 274, + SFINT32 = 275, + SFNODE = 276, + SFROTATION = 277, + SFSTRING = 278, + SFTIME = 279, + SFVEC2F = 280, + SFVEC3F = 281, + MFCOLOR = 282, + MFFLOAT = 283, + MFINT32 = 284, + MFROTATION = 285, + MFSTRING = 286, + MFVEC2F = 287, + MFVEC3F = 288, + MFNODE = 289 + }; +#endif +#define IDENTIFIER 258 +#define DEF 259 +#define USE 260 +#define PROTO 261 +#define EXTERNPROTO 262 +#define TO 263 +#define IS 264 +#define ROUTE 265 +#define SFN_NULL 266 +#define EVENTIN 267 +#define EVENTOUT 268 +#define FIELD 269 +#define EXPOSEDFIELD 270 +#define SFBOOL 271 +#define SFCOLOR 272 +#define SFFLOAT 273 +#define SFIMAGE 274 +#define SFINT32 275 +#define SFNODE 276 +#define SFROTATION 277 +#define SFSTRING 278 +#define SFTIME 279 +#define SFVEC2F 280 +#define SFVEC3F 281 +#define MFCOLOR 282 +#define MFFLOAT 283 +#define MFINT32 284 +#define MFROTATION 285 +#define MFSTRING 286 +#define MFVEC2F 287 +#define MFVEC3F 288 +#define MFNODE 289 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 120 "vrmlParser.yxx" +typedef union YYSTYPE { char *string; VrmlFieldValue fv; VrmlNode *node; MFArray *mfarray; SFNodeRef nodeRef; VrmlScene *scene; -} yystype; -# define YYSTYPE yystype +} YYSTYPE; +/* Line 1318 of yacc.c. */ +#line 114 "y.tab.h" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif -# define IDENTIFIER 257 -# define DEF 258 -# define USE 259 -# define PROTO 260 -# define EXTERNPROTO 261 -# define TO 262 -# define IS 263 -# define ROUTE 264 -# define SFN_NULL 265 -# define EVENTIN 266 -# define EVENTOUT 267 -# define FIELD 268 -# define EXPOSEDFIELD 269 -# define SFBOOL 270 -# define SFCOLOR 271 -# define SFFLOAT 272 -# define SFIMAGE 273 -# define SFINT32 274 -# define SFNODE 275 -# define SFROTATION 276 -# define SFSTRING 277 -# define SFTIME 278 -# define SFVEC2F 279 -# define SFVEC3F 280 -# define MFCOLOR 281 -# define MFFLOAT 282 -# define MFINT32 283 -# define MFROTATION 284 -# define MFSTRING 285 -# define MFVEC2F 286 -# define MFVEC3F 287 -# define MFNODE 288 - extern YYSTYPE vrmlyylval; -#endif /* not BISON_Y_TAB_H */ + +