diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I index aa86d2c83e..d7b405ae15 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I @@ -18,7 +18,7 @@ // Access: Public, Static // Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// -INLINE void AtomicAdjustDummyImpl:: +ALWAYS_INLINE void AtomicAdjustDummyImpl:: inc(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { ++var; } @@ -30,7 +30,7 @@ inc(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { // returns true if the new value is nonzero, false if it // is zero. //////////////////////////////////////////////////////////////////// -INLINE bool AtomicAdjustDummyImpl:: +ALWAYS_INLINE bool AtomicAdjustDummyImpl:: dec(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { return (--var) != 0; } @@ -41,7 +41,7 @@ dec(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { // Description: Atomically computes var += delta. It is legal for // delta to be negative. //////////////////////////////////////////////////////////////////// -INLINE void AtomicAdjustDummyImpl:: +ALWAYS_INLINE void AtomicAdjustDummyImpl:: add(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer delta) { var += delta; } @@ -52,7 +52,7 @@ add(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Intege // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: +ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: set(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer new_value) { Integer orig_value = var; var = new_value; @@ -68,7 +68,7 @@ set(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Intege // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: +ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: get(const TVOLATILE AtomicAdjustDummyImpl::Integer &var) { return var; } @@ -79,8 +79,8 @@ get(const TVOLATILE AtomicAdjustDummyImpl::Integer &var) { // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: -set_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &var, +ALWAYS_INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: +set_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &var, AtomicAdjustDummyImpl::Pointer new_value) { Pointer orig_value = var; var = new_value; @@ -96,7 +96,7 @@ set_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &var, // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: +ALWAYS_INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: get_ptr(const TVOLATILE AtomicAdjustDummyImpl::Pointer &var) { return var; } @@ -104,15 +104,15 @@ get_ptr(const TVOLATILE AtomicAdjustDummyImpl::Pointer &var) { //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustDummyImpl::compare_and_exchange // Access: Public, Static -// Description: Atomic compare and exchange. +// 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 AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: -compare_and_exchange(TVOLATILE AtomicAdjustDummyImpl::Integer &mem, +ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: +compare_and_exchange(TVOLATILE AtomicAdjustDummyImpl::Integer &mem, AtomicAdjustDummyImpl::Integer old_value, AtomicAdjustDummyImpl::Integer new_value) { Integer orig_value = mem; @@ -125,12 +125,12 @@ compare_and_exchange(TVOLATILE AtomicAdjustDummyImpl::Integer &mem, //////////////////////////////////////////////////////////////////// // Function: AtomicAdjustDummyImpl::compare_and_exchange_ptr // Access: Public, Static -// Description: Atomic compare and exchange. +// Description: Atomic compare and exchange. // // As above, but works on pointers instead of integers. //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: -compare_and_exchange_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &mem, +ALWAYS_INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: +compare_and_exchange_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &mem, AtomicAdjustDummyImpl::Pointer old_value, AtomicAdjustDummyImpl::Pointer new_value) { Pointer orig_value = mem; diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h index 17e03c04e6..c77f527dc1 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h @@ -31,22 +31,22 @@ public: typedef long Integer; typedef void *Pointer; - INLINE static void inc(TVOLATILE Integer &var); - INLINE static bool dec(TVOLATILE Integer &var); - INLINE static void add(TVOLATILE Integer &var, Integer delta); - INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); - INLINE static Integer get(const TVOLATILE Integer &var); + ALWAYS_INLINE static void inc(TVOLATILE Integer &var); + ALWAYS_INLINE static bool dec(TVOLATILE Integer &var); + ALWAYS_INLINE static void add(TVOLATILE Integer &var, Integer delta); + ALWAYS_INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); + ALWAYS_INLINE static Integer get(const TVOLATILE Integer &var); - INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value); - INLINE static Pointer get_ptr(const TVOLATILE Pointer &var); + ALWAYS_INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value); + ALWAYS_INLINE static Pointer get_ptr(const TVOLATILE Pointer &var); - INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, - Integer old_value, - Integer new_value); + ALWAYS_INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + Integer old_value, + Integer new_value); - INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, - Pointer old_value, - Pointer new_value); + ALWAYS_INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, + Pointer old_value, + Pointer new_value); }; #include "atomicAdjustDummyImpl.I" diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I index d96fe98bc1..f04dfbe8fa 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I @@ -18,7 +18,7 @@ // Access: Public, Static // Description: Atomically increments the indicated variable. //////////////////////////////////////////////////////////////////// -INLINE void AtomicAdjustWin32Impl:: +ALWAYS_INLINE void AtomicAdjustWin32Impl:: inc(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); #ifdef _WIN64 @@ -35,7 +35,7 @@ inc(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { // returns true if the new value is nonzero, false if it // is zero. //////////////////////////////////////////////////////////////////// -INLINE bool AtomicAdjustWin32Impl:: +ALWAYS_INLINE bool AtomicAdjustWin32Impl:: dec(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); #ifdef _WIN64 @@ -70,7 +70,7 @@ add(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Intege // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: +ALWAYS_INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: set(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer new_value) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -90,7 +90,7 @@ set(TVOLATILE AtomicAdjustWin32Impl::Integer &var, // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: +ALWAYS_INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: get(const TVOLATILE AtomicAdjustWin32Impl::Integer &var) { // On Intel platforms, word-aligned loads are atomic (if performed // in a single instruction). We can't guarantee the compiler will @@ -107,7 +107,7 @@ get(const TVOLATILE AtomicAdjustWin32Impl::Integer &var) { // Description: Atomically changes the indicated variable and // returns the original value. //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: +ALWAYS_INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: set_ptr(TVOLATILE AtomicAdjustWin32Impl::Pointer &var, AtomicAdjustWin32Impl::Pointer new_value) { assert((((size_t)&var) & (sizeof(Pointer) - 1)) == 0); @@ -123,7 +123,7 @@ set_ptr(TVOLATILE AtomicAdjustWin32Impl::Pointer &var, // asynchronously setting, incrementing, or decrementing // (via other AtomicAjust methods). //////////////////////////////////////////////////////////////////// -INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: +ALWAYS_INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: get_ptr(const TVOLATILE AtomicAdjustWin32Impl::Pointer &var) { // As in get(), make sure the address is word-aligned. assert((((size_t)&var) & (sizeof(Pointer) - 1)) == 0); diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h index 2ead06d0fe..2018560577 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -45,20 +45,20 @@ public: typedef ALIGN_4BYTE UnalignedPointer Pointer; #endif // _WIN64 - INLINE static void inc(TVOLATILE Integer &var); - INLINE static bool dec(TVOLATILE Integer &var); + ALWAYS_INLINE static void inc(TVOLATILE Integer &var); + ALWAYS_INLINE static bool dec(TVOLATILE Integer &var); INLINE static void add(TVOLATILE Integer &var, Integer delta); - INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); - INLINE static Integer get(const TVOLATILE Integer &var); + ALWAYS_INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); + ALWAYS_INLINE static Integer get(const TVOLATILE Integer &var); - INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value); - INLINE static Pointer get_ptr(const TVOLATILE Pointer &var); + ALWAYS_INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value); + ALWAYS_INLINE static Pointer get_ptr(const TVOLATILE Pointer &var); - INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, Integer old_value, Integer new_value); - - INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, + + INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, Pointer old_value, Pointer new_value); }; diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index efefd36e9e..60ea4bd37f 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -32,6 +32,7 @@ using namespace std; #define INLINE inline +#define ALWAYS_INLINE inline #define TYPENAME typename #define CONSTEXPR #define NOEXCEPT noexcept @@ -115,11 +116,19 @@ typedef ios::iostate ios_iostate; typedef ios::seekdir ios_seekdir; #endif -#if defined(WIN32_VC) && defined(FORCE_INLINING) +#ifdef _MSC_VER +#define ALWAYS_INLINE __forceinline +#elif defined(__GNUC__) +#define ALWAYS_INLINE __attribute__((always_inline)) inline +#else +#define ALWAYS_INLINE inline +#endif + +#ifdef FORCE_INLINING // If FORCE_INLINING is defined, we use the keyword __forceinline, // which tells MS VC++ to override its internal benefit heuristic // and inline the fn if it is technically possible to do so. -#define INLINE __forceinline +#define INLINE ALWAYS_INLINE #else #define INLINE inline #endif diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index e489fd4099..867bdb4cea 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -263,24 +263,3 @@ INLINE TypeHandle:: operator bool () const { return (_index != 0); } - -//////////////////////////////////////////////////////////////////// -// Function: get_best_parent_from_Set -// Access: Published -// Description: Return the Index of the BEst fit Classs from a set -//////////////////////////////////////////////////////////////////// -INLINE int TypeHandle::get_best_parent_from_Set(const std::set< int > &legal_vals) const -{ - if(legal_vals.find(_index) != legal_vals.end()) - return _index; - - for(int pi = 0; pi < get_num_parent_classes() ; pi++) - { - TypeHandle ph = get_parent_class(pi); - int val = ph.get_best_parent_from_Set(legal_vals); - if(val > 0) - return val; - - } - return -1; -} diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index cca55062c1..d807a298b6 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -84,6 +84,27 @@ dec_memory_usage(MemoryClass memory_class, size_t size) { } #endif // DO_MEMORY_USAGE +//////////////////////////////////////////////////////////////////// +// Function: get_best_parent_from_Set +// Access: Published +// Description: Return the Index of the BEst fit Classs from a set +//////////////////////////////////////////////////////////////////// +int TypeHandle:: +get_best_parent_from_Set(const std::set< int > &legal_vals) const { + if (legal_vals.find(_index) != legal_vals.end()) { + return _index; + } + + for (int pi = 0; pi < get_num_parent_classes(); ++pi) { + TypeHandle ph = get_parent_class(pi); + int val = ph.get_best_parent_from_Set(legal_vals); + if (val > 0) { + return val; + } + } + return -1; +} + ostream & operator << (ostream &out, TypeHandle::MemoryClass mem_class) { switch (mem_class) { diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index c669fa8084..f94e983447 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -123,7 +123,7 @@ PUBLISHED: INLINE TypeHandle get_parent_towards(TypeHandle ancestor, TypedObject *object = (TypedObject *)NULL) const; - INLINE int get_best_parent_from_Set(const std::set< int > &legal_vals) const; + int get_best_parent_from_Set(const std::set< int > &legal_vals) const; #ifdef DO_MEMORY_USAGE int get_memory_usage(MemoryClass memory_class) const; diff --git a/dtool/src/prc/configFlags.I b/dtool/src/prc/configFlags.I index f0bb39bf51..d13cdd2699 100644 --- a/dtool/src/prc/configFlags.I +++ b/dtool/src/prc/configFlags.I @@ -20,7 +20,7 @@ // valid (based on a comparison of the supplied // local_modified value with the global_modified value). //////////////////////////////////////////////////////////////////// -INLINE bool ConfigFlags:: +ALWAYS_INLINE bool ConfigFlags:: is_cache_valid(AtomicAdjust::Integer local_modified) { return local_modified == _global_modified; } @@ -32,7 +32,7 @@ is_cache_valid(AtomicAdjust::Integer local_modified) { // the cache will appear to be valid, until someone next // calls invalidate_cache(). //////////////////////////////////////////////////////////////////// -INLINE void ConfigFlags:: +ALWAYS_INLINE void ConfigFlags:: mark_cache_valid(AtomicAdjust::Integer &local_modified) { local_modified = _global_modified; } diff --git a/dtool/src/prc/configFlags.h b/dtool/src/prc/configFlags.h index a90bdc1f33..b7a3205468 100644 --- a/dtool/src/prc/configFlags.h +++ b/dtool/src/prc/configFlags.h @@ -62,8 +62,8 @@ PUBLISHED: }; protected: - INLINE static bool is_cache_valid(AtomicAdjust::Integer local_modified); - INLINE static void mark_cache_valid(AtomicAdjust::Integer &local_modified); + ALWAYS_INLINE static bool is_cache_valid(AtomicAdjust::Integer local_modified); + ALWAYS_INLINE static void mark_cache_valid(AtomicAdjust::Integer &local_modified); INLINE static AtomicAdjust::Integer initial_invalid_cache(); INLINE static void invalidate_cache(); diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index ce0228174a..4c19e3fdc2 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -517,23 +517,6 @@ reverse_ls() const { reverse_ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::reverse_ls -// Access: Published -// Description: Lists the hierarchy at and above the referenced node. -//////////////////////////////////////////////////////////////////// -INLINE int NodePath:: -reverse_ls(ostream &out, int indent_level) const { - if (is_empty()) { - out << "(empty)\n"; - return 0; - } else if (has_parent()) { - indent_level = get_parent().reverse_ls(out, indent_level); - } - node()->write(out, indent_level); - return indent_level + 2; -} - //////////////////////////////////////////////////////////////////// // Function: NodePath::set_state // Access: Published diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 20a2f90ab4..5fe2c1ab3b 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -810,6 +810,23 @@ detach_node(Thread *current_thread) { } } +//////////////////////////////////////////////////////////////////// +// Function: NodePath::reverse_ls +// Access: Published +// Description: Lists the hierarchy at and above the referenced node. +//////////////////////////////////////////////////////////////////// +int NodePath:: +reverse_ls(ostream &out, int indent_level) const { + if (is_empty()) { + out << "(empty)\n"; + return 0; + } else if (has_parent()) { + indent_level = get_parent().reverse_ls(out, indent_level); + } + node()->write(out, indent_level); + return indent_level + 2; +} + //////////////////////////////////////////////////////////////////// // Function: NodePath::output // Access: Published diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 4e7a098601..0762600b2e 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -278,8 +278,7 @@ PUBLISHED: INLINE void ls() const; INLINE void ls(ostream &out, int indent_level = 0) const; INLINE void reverse_ls() const; - INLINE int reverse_ls(ostream &out, int indent_level = 0) const; - + int reverse_ls(ostream &out, int indent_level = 0) const; // Aggregate transform and state information. const RenderState *get_state(Thread *current_thread = Thread::get_current_thread()) const;