mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
Changes to inlining so we can use FORCE_INLINING in gcc as well
This commit is contained in:
parent
4206e349c9
commit
75019784f4
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user