Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3277 for code/branches


Ignore:
Timestamp:
Jul 12, 2009, 7:20:39 PM (15 years ago)
Author:
scheusso
Message:

fixed a 64bit issue and inserted some static asserts to prevent further runtime errors with function pointer sizes bigger than expected …

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp6/src/network/NetworkFunction.h

    r3256 r3277  
    3737#include <string>
    3838#include <boost/preprocessor/cat.hpp>
     39#include <boost/static_assert.hpp>
    3940
    4041#include "core/OrxonoxClass.h"
     
    4647{
    4748
    48 #ifdef ORXONOX_COMPILER_GCC
     49#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    4950static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
    50 #else //ORXONOX_COMPILER_GCC
     51#else
    5152static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
    5253#endif //ORXONOX_COMPILER_GCC
     
    5758  bool operator<(const NetworkFunctionPointer& b) const
    5859  {
    59 #ifdef ORXONOX_COMPILER_GCC
     60#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    6061    return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
    6162#else //ORXONOX_COMPILER_GCC
     
    195196template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
    196197{
    197   memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
     198  if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)
     199    memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
    198200  T p2 = ptr;
    199201  memcpy( &destptr, &p2, sizeof(T) );
     
    204206template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    205207{
     208  BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
    206209  NetworkFunctionPointer destptr;
    207210  copyPtr( ptr, destptr );
     
    212215template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    213216{
     217  BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
    214218  NetworkFunctionPointer destptr;
    215219  copyPtr( ptr, destptr );
Note: See TracChangeset for help on using the changeset viewer.