Changeset 376


Ignore:
Timestamp:
05/28/15 10:21:10 (10 years ago)
Author:
epyon
Message:
  • stl/assert.hh, stl/capi.hh, size_t independent
  • GCC 4.8 compatibility
  • using template usage
  • various minor changes
Location:
trunk
Files:
4 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/common.hh

    r374 r376  
    44// This file is part of NV Libraries.
    55// For conditions of distribution and use, see copyright notice in nv.hh
    6 
    76#ifndef NV_CORE_COMMON_HH
    87#define NV_CORE_COMMON_HH
     
    6867
    6968// Platform specific settings.
    70 #if NV_PLATFORM == NV_WINDOWS
     69#if NV_COMPILER == NV_MSVC
    7170#ifdef _DEBUG
    7271#define NV_DEBUG 1
     
    7473#define NV_DEBUG 0
    7574#endif
    76 #endif
    77 
    78 #if NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    79 #ifdef DEBUG
     75#else
     76#ifdef NDEBUG
     77#define NV_DEBUG 0
     78#else
    8079#define NV_DEBUG 1
    81 #else
    82 #define NV_DEBUG 0
    8380#endif
    8481#endif
     
    105102#endif
    106103
    107 #if NV_COMPILER == NV_GNUC && NV_COMP_VER < 460
    108 #error "GCC 4.6+ required!"
     104#if NV_COMPILER == NV_GNUC && NV_COMP_VER < 480
     105#error "GCC 4.8+ required!"
    109106#endif
    110107
     
    125122#endif
    126123
    127 #include <cassert>
    128 
    129124#define NV_STRINGIZE_DETAIL(x) #x
    130125#define NV_STRINGIZE(x) NV_STRINGIZE_DETAIL(x)
     126
     127#if NV_COMPILER == NV_MSVC
     128#define NV_WIDE_DETAIL(x) L ## x
     129#define NV_WIDE(x) NV_WIDE_DETAIL(x)
     130#endif
    131131
    132132#if NV_COMPILER == NV_MSVC
     
    134134#define NV_ALIGN(value) __declspec(align(value))
    135135#define NV_ALIGNED_STRUCT(value) __declspec(align(value)) struct
     136#define NV_NOALIAS __declspec(noalias)
    136137#define NV_RESTRICT __declspec(restrict)
    137138#define NV_RESTRICT_VAR __restrict
    138139#define NV_NOEXCEPT throw()
    139140#define NV_ALIGN_OF(type) __alignof(type)
     141#if NV_ARCHITECTURE == NV_64BIT
     142#define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) )
     143#else // NV_32BIT
     144#define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m))
     145#endif 
    140146//#define NV_CONSTEXPR
    141147#elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
     
    147153#define NV_NOEXCEPT noexcept
    148154#define NV_ALIGN_OF(type) alignof(type)
     155#define NV_OFFSET_OF(obj, m) __builtin_offsetof(obj, m)
    149156//#define NV_CONSTEXPR constexpr
    150157#else
    151 #define NV_DEPRECATED(func) func
    152 #define NV_ALIGN(value)
    153 #define NV_ALIGNED_STRUCT(value) struct
    154 #define NV_RESTRICT
    155 #define NV_RESTRICT_VAR
    156 #define NV_NOEXCEPT
    157 #define NV_ALIGN_OF
    158 //#define NV_CONSTEXPR
     158#error "Unknown compiler, cannot proceed!"
    159159#endif
    160160
    161161#define NV_UNUSED(x) (void)(x)
    162 #define NV_ASSERT(cond, msg) assert( (cond) && msg )
    163162#define NV_THROW(eobj, ...) { \
    164163        NV_LOG_ERROR( __FILE__ " line " NV_STRINGIZE(__LINE__) " - exception thrown - " #eobj ); \
     
    184183        }
    185184
    186         using ::size_t; // typedef decltype( sizeof( int ) ) size_t;
    187         using ::ptrdiff_t;
     185        using size_t    = decltype( sizeof(0) );
     186        using ptrdiff_t = decltype((int*)0 - (int*)0);
     187
     188        using nullptr_t = decltype( nullptr );
    188189
    189190        // Typedefs for fixed size types.
     
    196197        typedef unsigned int       uint32;
    197198
    198 #if NV_COMPILER == NV_MSVC
    199         typedef signed   __int64   sint64;
    200         typedef unsigned __int64   uint64;
    201 #else
    202199        typedef signed   long long sint64;
    203200        typedef unsigned long long uint64;
    204 #endif
     201
    205202        typedef unsigned char      uchar8;
    206203        typedef unsigned short     uchar16;
     
    242239                typedef T value_type;
    243240                typedef integral_constant<T, VALUE> type;
    244                 NV_CONSTEXPR operator value_type() const { return ( value ); }
    245         };
    246 
    247         typedef integral_constant<bool, true> true_type;
    248         typedef integral_constant<bool, false> false_type;
     241                NV_CONSTEXPR operator value_type() const NV_NOEXCEPT { return ( value ); }
     242                NV_CONSTEXPR value_type operator()() const NV_NOEXCEPT { return value; }
     243        };
     244
     245        // TODO: Propagate
     246        template< bool B >
     247        using bool_constant = integral_constant < bool, B > ;
     248
     249        typedef bool_constant<true> true_type;
     250        typedef bool_constant<false> false_type;
    249251
    250252        template< bool TEST, typename T = void>
     
    313315static_assert( sizeof( nv::f64 ) == 8, "float64 size isn't 8 bytes" );
    314316
     317#include <nv/stl/assert.hh>
    315318
    316319#endif // NV_CORE_COMMON_HH
     320
  • trunk/nv/interface/animation_key.hh

    r368 r376  
    120120                        typedef decltype( KEY::time ) value_type;
    121121                        static const datatype etype  = type_to_enum< decltype( KEY::time ) >::type;
    122                         static const int      offset = offsetof( KEY, time );
     122                        static const int      offset = NV_OFFSET_OF( KEY, time );
    123123                };
    124124
     
    128128                        typedef decltype( KEY::position ) value_type;
    129129                        static const datatype etype  = type_to_enum< decltype( KEY::position ) >::type;
    130                         static const int      offset = offsetof( KEY, position );
     130                        static const int      offset = NV_OFFSET_OF( KEY, position );
    131131                        static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor )
    132132                        {
     
    140140                        typedef decltype( KEY::rotation ) value_type;
    141141                        static const datatype etype  = type_to_enum< decltype( KEY::rotation ) >::type;
    142                         static const int      offset = offsetof( KEY, rotation );
     142                        static const int      offset = NV_OFFSET_OF( KEY, rotation );
    143143                        static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor )
    144144                        {
     
    152152                        typedef decltype( KEY::scale ) value_type;
    153153                        static const datatype etype  = type_to_enum< decltype( KEY::scale ) >::type;
    154                         static const int      offset = offsetof( KEY, scale );
     154                        static const int      offset = NV_OFFSET_OF( KEY, scale );
    155155                        static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor )
    156156                        {
     
    164164                        typedef decltype( KEY::tform ) value_type;
    165165                        static const datatype etype  = type_to_enum< decltype( KEY::tform ) >::type;
    166                         static const int      offset = offsetof( KEY, tform );
     166                        static const int      offset = NV_OFFSET_OF( KEY, tform );
    167167                        static void interpolate( KEY& key, const KEY& k1, const KEY& k2, float factor )
    168168                        {
     
    173173
    174174        template < typename KEY, animation_slot SLOT >
    175         struct key_has_slot : public detail::key_has_slot_impl< KEY, SLOT >
     175        struct key_has_slot : bool_constant< detail::key_has_slot_impl< KEY, SLOT >::value >
    176176        {
    177177        };
  • trunk/nv/interface/interpolation_template.hh

    r374 r376  
    3232        void interpolate_key( KEY& key, const KEY& k1, const KEY& k2, float factor )
    3333        {
    34                 interpolate_slot< KEY, animation_slot::POSITION >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::POSITION >::value >() );
    35                 interpolate_slot< KEY, animation_slot::ROTATION >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::ROTATION >::value >() );
    36                 interpolate_slot< KEY, animation_slot::SCALE >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::SCALE >::value >() );
    37                 interpolate_slot< KEY, animation_slot::TFORM >( key, k1, k2, factor, integral_constant< bool, key_has_slot< KEY, animation_slot::TFORM >::value >() );
     34                interpolate_slot< KEY, animation_slot::POSITION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::POSITION >() );
     35                interpolate_slot< KEY, animation_slot::ROTATION >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::ROTATION >() );
     36                interpolate_slot< KEY, animation_slot::SCALE >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::SCALE >() );
     37                interpolate_slot< KEY, animation_slot::TFORM >( key, k1, k2, factor, key_has_slot< KEY, animation_slot::TFORM >() );
    3838        }
    3939
     
    135135                        static_assert( key_has_slot< KEY, animation_slot::TFORM >::value == false, "key!");
    136136                        return extract_matrix_prs( k,
    137                                 integral_constant< bool, key_has_slot< KEY, animation_slot::POSITION >::value >(),
    138                                 integral_constant< bool, key_has_slot< KEY, animation_slot::ROTATION >::value >(),
    139                                 integral_constant< bool, key_has_slot< KEY, animation_slot::SCALE >::value >()
     137                                key_has_slot< KEY, animation_slot::POSITION >(),
     138                                key_has_slot< KEY, animation_slot::ROTATION >(),
     139                                key_has_slot< KEY, animation_slot::SCALE >()
    140140                                );
    141141                }
     
    156156                        static_assert( key_has_slot< KEY, animation_slot::SCALE >::value == false, "key!");
    157157                        return extract_transform_pr_impl( k,
    158                                 integral_constant< bool, key_has_slot< KEY, animation_slot::POSITION >::value >(),
    159                                 integral_constant< bool, key_has_slot< KEY, animation_slot::ROTATION >::value >()
     158                                key_has_slot< KEY, animation_slot::POSITION >::value >(),
     159                                key_has_slot< KEY, animation_slot::ROTATION >::value >()
    160160                                );
    161161                }
     
    165165        mat4 extract_matrix( const KEY& k )
    166166        {
    167                 return detail::extract_matrix_impl( k, integral_constant< bool, key_has_slot< KEY, animation_slot::TFORM >::value >() );
     167                return detail::extract_matrix_impl( k, key_has_slot< KEY, animation_slot::TFORM >() );
    168168        }
    169169
     
    171171        transform extract_transform( const KEY& k )
    172172        {
    173                 return detail::extract_transform_impl( k, integral_constant< bool, key_has_slot< KEY, animation_slot::TFORM >::value >() );
     173                return detail::extract_transform_impl( k, key_has_slot< KEY, animation_slot::TFORM >() );
    174174        }
    175175
  • trunk/nv/interface/vertex.hh

    r368 r376  
    164164                        typedef decltype( VT::position ) value_type;
    165165                        static const datatype etype  = type_to_enum< decltype( VT::position ) >::type;
    166                         static const int      offset = offsetof( VT, position );
     166                        static const int      offset = NV_OFFSET_OF( VT, position );
    167167                };
    168168
     
    172172                        typedef decltype( VT::texcoord ) value_type;
    173173                        static const datatype etype  = type_to_enum< decltype( VT::texcoord ) >::type;
    174                         static const int      offset = offsetof( VT, texcoord );
     174                        static const int      offset = NV_OFFSET_OF( VT, texcoord );
    175175                };
    176176
     
    180180                        typedef decltype( VT::normal ) value_type;
    181181                        static const datatype etype  = type_to_enum< decltype( VT::normal ) >::type;
    182                         static const int      offset = offsetof( VT, normal );
     182                        static const int      offset = NV_OFFSET_OF( VT, normal );
    183183                };
    184184
     
    188188                        typedef decltype( VT::tangent ) value_type;
    189189                        static const datatype etype  = type_to_enum< decltype( VT::tangent ) >::type;
    190                         static const int      offset = offsetof( VT, tangent );
     190                        static const int      offset = NV_OFFSET_OF( VT, tangent );
    191191                };
    192192
     
    196196                        typedef decltype( VT::boneindex ) value_type;
    197197                        static const datatype etype  = type_to_enum< decltype( VT::boneindex ) >::type;
    198                         static const int      offset = offsetof( VT, boneindex );
     198                        static const int      offset = NV_OFFSET_OF( VT, boneindex );
    199199                };
    200200
     
    204204                        typedef decltype( VT::boneweight ) value_type;
    205205                        static const datatype etype  = type_to_enum< decltype( VT::boneweight ) >::type;
    206                         static const int      offset = offsetof( VT, boneweight );
     206                        static const int      offset = NV_OFFSET_OF( VT, boneweight );
    207207                };
    208208
     
    212212                        typedef decltype( VT::color ) value_type;
    213213                        static const datatype etype  = type_to_enum< decltype( VT::color ) >::type;
    214                         static const int      offset = offsetof( VT, color );
     214                        static const int      offset = NV_OFFSET_OF( VT, color );
    215215                };
    216216
  • trunk/nv/lib/curses.hh

    r374 r376  
    2929#endif
    3030
     31// for va_list
     32#include <stdarg.h>
    3133#ifdef CURSES_PDC_WIDE
    3234#include <wchar.h>
  • trunk/nv/lib/detail/wgl_functions.inc

    r245 r376  
    1212NV_GL_FUN_REN( BOOL,  wglRealizeLayerPalette,   dynwglRealizeLayerPalette,(HDC, int, BOOL) );
    1313NV_GL_FUN_REN( BOOL,  wglSwapLayerBuffers,      dynwglSwapLayerBuffers, (HDC, UINT) );
    14 NV_GL_FUN_REN( DWORD, wglSwapMultipleBuffers,   dynwglSwapMultipleBuffers, (UINT, CONST WGLSWAP *) );
     14// GCC 4.8 doesnt like WGLSWAP
     15//NV_GL_FUN_REN( DWORD, wglSwapMultipleBuffers,   dynwglSwapMultipleBuffers, (UINT, CONST WGLSWAP *) );
    1516
    1617// Global
  • trunk/nv/stl/algorithm.hh

    r374 r376  
    219219        {
    220220                detail::fill_impl( first, last, value,
    221                         integral_constant< bool, sizeof( T ) == 1 && has_trivial_assign<T>::value >() );
     221                        bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() );
    222222        }
    223223
     
    226226        {
    227227                return detail::fill_n_impl( first, count, value,
    228                         integral_constant< bool, sizeof( T ) == 1 && has_trivial_assign<T>::value >() );
     228                        bool_constant< sizeof( T ) == 1 && has_trivial_assign<T>::value >() );
    229229        }
    230230
     
    235235                typedef typename iterator_traits< ForwardIterator >::value_type value_type;
    236236                detail::fill_impl( first, last, value_type(),
    237                         integral_constant< bool, sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );
     237                        bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );
    238238        }
    239239
     
    244244                typedef typename iterator_traits< ForwardIterator >::value_type value_type;
    245245                return detail::fill_n_impl( first, count, value_type(),
    246                         integral_constant< bool, sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );
     246                        bool_constant< sizeof( value_type ) == 1 && has_trivial_assign<value_type>::value >() );
    247247        }
    248248
  • trunk/nv/stl/array.hh

    r375 r376  
    8484        };
    8585
    86         // TODO: using array =
    8786        template< typename T, size_t N >
    88         class array : public array_base< T,
    89                 fixed_container_storage< static_storage< T, N > >
    90         >
    91         {
    92 
    93         };
     87        using array = array_base < T, fixed_container_storage < static_storage< T, N > > >;
     88       
    9489
    9590#if 0
  • trunk/nv/stl/handle.hh

    r368 r376  
    9393                {
    9494                        value_type index = h.index();
    95                         typedef handle_operator<HANDLE> hop;
    9695                        NV_ASSERT( m_entries[index].next_free == USED, "Unused handle freed!" );
    97                         NV_ASSERT( m_entries[index].counter == hop::get_counter( h ), "Handle corruption!" );
     96                        NV_ASSERT( m_entries[index].counter == handle_operator<HANDLE>::get_counter( h ), "Handle corruption!" );
    9897                        m_entries[index].next_free = NONE;
    9998                        if ( m_last_free == NONE )
  • trunk/nv/stl/limits.hh

    r374 r376  
    4747                static const signed long sl_max = 2147483647;
    4848                static const signed long sl_bit = sizeof( signed long ) * 8;
    49                 static const uint64 ull_min = 0;
    50                 static const uint64 ull_max = 18446744073709551615;
    51                 static const uint64 ull_bit = sizeof( uint64 ) * 8;
    52                 static const sint64 sll_min = -9223372036854775808;
    53                 static const sint64 sll_max = 9223372036854775807;
    54                 static const sint64 sll_bit = sizeof( sint64 ) * 8;
     49                static const unsigned long long ull_min = 0;
     50                static const unsigned long long ull_max = 18446744073709551615;
     51                static const unsigned long long ull_bit = sizeof( unsigned long long ) * 8;
     52                static const signed long long sll_min = -9223372036854775808;
     53                static const signed long long sll_max = 9223372036854775807;
     54                static const signed long long sll_bit = sizeof( signed long long ) * 8;
    5555
    5656                static const int f_dig        = 6;
     
    311311
    312312        template<>
    313         struct numeric_limits < uint64 > : detail::numeric_limits_int_base
    314         {
    315                 static NV_CONSTEXPR uint64 min()           NV_NOEXCEPT { return limits::ull_min; }
    316                 static NV_CONSTEXPR uint64 max()           NV_NOEXCEPT { return limits::ull_max; }
    317                 static NV_CONSTEXPR uint64 lowest()        NV_NOEXCEPT { return limits::ull_min; }
    318                 static NV_CONSTEXPR uint64 epsilon()       NV_NOEXCEPT { return 0; }
    319                 static NV_CONSTEXPR uint64 round_error()   NV_NOEXCEPT { return 0; }
     313        struct numeric_limits < unsigned long long > : detail::numeric_limits_int_base
     314        {
     315                static NV_CONSTEXPR unsigned long long min()           NV_NOEXCEPT { return limits::ull_min; }
     316                static NV_CONSTEXPR unsigned long long max()           NV_NOEXCEPT{ return limits::ull_max; }
     317                static NV_CONSTEXPR unsigned long long lowest()        NV_NOEXCEPT{ return limits::ull_min; }
     318                static NV_CONSTEXPR unsigned long long epsilon()       NV_NOEXCEPT{ return 0; }
     319                static NV_CONSTEXPR unsigned long long round_error()   NV_NOEXCEPT{ return 0; }
    320320
    321321                static const bool is_signed = false;
     
    325325
    326326        template<>
    327         struct numeric_limits < sint64 > : detail::numeric_limits_int_base
    328         {
    329                 static NV_CONSTEXPR sint64 min()           NV_NOEXCEPT { return limits::sll_min; }
    330                 static NV_CONSTEXPR sint64 max()           NV_NOEXCEPT { return limits::sll_max; }
    331                 static NV_CONSTEXPR sint64 lowest()        NV_NOEXCEPT { return limits::sll_min; }
    332                 static NV_CONSTEXPR sint64 epsilon()       NV_NOEXCEPT { return 0; }
    333                 static NV_CONSTEXPR sint64 round_error()   NV_NOEXCEPT { return 0; }
     327        struct numeric_limits < signed long long > : detail::numeric_limits_int_base
     328        {
     329                static NV_CONSTEXPR signed long long min()           NV_NOEXCEPT{ return limits::sll_min; }
     330                static NV_CONSTEXPR signed long long max()           NV_NOEXCEPT{ return limits::sll_max; }
     331                static NV_CONSTEXPR signed long long lowest()        NV_NOEXCEPT{ return limits::sll_min; }
     332                static NV_CONSTEXPR signed long long epsilon()       NV_NOEXCEPT{ return 0; }
     333                static NV_CONSTEXPR signed long long round_error()   NV_NOEXCEPT{ return 0; }
    334334
    335335                static const bool is_signed = true;
  • trunk/nv/stl/memory.hh

    r375 r376  
    2020#include <nv/stl/utility.hh>
    2121#include <nv/stl/iterator.hh>
    22 
    23 #include <type_traits>
     22#include <nv/stl/capi.hh>
    2423
    2524namespace nv
    2625{
     26
    2727        template< typename T >
    2828        class storage_view
     
    111111                fixed_dynamic_storage()
    112112                {
    113                         m_data = malloc( N * sizeof( value_type ) );
     113                        m_data = nvmalloc( N * sizeof( value_type ) );
    114114                }
    115115                ~fixed_dynamic_storage()
    116116                {
    117                         free( m_data );
     117                        nvfree( m_data );
    118118                }
    119119                static NV_CONSTEXPR size_t capacity() { return N; }
  • trunk/nv/stl/string.hh

    r375 r376  
    283283        }
    284284
    285 #if NV_COMPILER == NV_GNUC
    286         template< typename T >
    287         struct string_length : public detail::string_length_impl <
    288                 typename remove_cv < typename remove_reference< T >::type >::type >
    289         {
    290         };
    291 #else
    292285        template< typename T >
    293286        using string_length = detail::string_length_impl <
    294287                typename remove_cv < typename remove_reference< T >::type >::type >;
    295 #endif
    296288
    297289        // These could be done much better
    298290        template <typename T>
    299291        struct is_cstring
    300                 : public integral_constant < bool,
     292                : bool_constant <
    301293                is_same<       char *, typename decay< T >::type >::value ||
    302294                is_same< const char *, typename decay< T >::type >::value >
     
    306298        template <typename T>
    307299        struct is_stdstring
    308                 : public integral_constant < bool,
    309                 is_same< std::string, typename remove_cvr< T >::type >::value
    310                 >
    311         {
    312         };
    313 
    314         template < typename T > struct is_string : public integral_constant < bool, is_stdstring<T>::value || is_cstring<T>::value > {};
     300                : bool_constant < is_same< std::string, typename remove_cvr< T >::type >::value >
     301        {
     302        };
     303
     304        template < typename T > struct is_string : bool_constant < is_stdstring<T>::value || is_cstring<T>::value > {};
    315305
    316306        template<typename T>
  • trunk/nv/stl/type_traits.hh

    r374 r376  
    1212// TODO: remove typeinfo?
    1313
     14
    1415#ifndef NV_STL_TYPE_TRAITS_HH
    1516#define NV_STL_TYPE_TRAITS_HH
     
    1718#include <nv/core/common.hh>
    1819
    19 #include <type_traits>
    2020namespace nv
    2121{
     
    244244                template<> struct is_integral_impl< signed long > : true_type {};
    245245                template<> struct is_integral_impl< unsigned long > : true_type {};
    246                 template<> struct is_integral_impl< sint64 > : true_type {};
    247                 template<> struct is_integral_impl< uint64 > : true_type {};
     246                template<> struct is_integral_impl< signed long long > : true_type{};
     247                template<> struct is_integral_impl< unsigned long long > : true_type{};
    248248
    249249                template< typename T > struct is_floating_point_impl : false_type {};
     
    264264                template<> struct signed_type < unsigned int > { typedef signed int type; };
    265265                template<> struct signed_type < unsigned long > { typedef signed long type; };
    266                 template<> struct signed_type < uint64 > { typedef sint64 type; };
     266                template<> struct signed_type < unsigned long long > { typedef signed long long type; };
    267267
    268268                template < typename T >
     
    277277                template<> struct unsigned_type < signed int > { typedef unsigned int type; };
    278278                template<> struct unsigned_type < signed long > { typedef unsigned long type; };
    279                 template<> struct unsigned_type < sint64 > { typedef uint64 type; };
     279                template<> struct unsigned_type < signed long long > { typedef unsigned long long type; };
    280280
    281281                template < typename T, bool IS_ENUM = is_enum< T >::value >
     
    340340        template <> struct is_signed<signed long> : true_type {};
    341341        template <> struct is_signed<const signed long> : true_type {};
    342         template <> struct is_signed<sint64> : true_type {};
    343         template <> struct is_signed<const sint64> : true_type{};
     342        template <> struct is_signed<signed long long> : true_type{};
     343        template <> struct is_signed<const signed long long> : true_type{};
    344344
    345345        template <typename T> struct is_unsigned : false_type {};
     
    353353        template <> struct is_unsigned<unsigned long> : true_type{};
    354354        template <> struct is_unsigned<const unsigned long> : true_type{};
    355         template <> struct is_unsigned<uint64> : true_type{};
    356         template <> struct is_unsigned<const uint64> : true_type{};
     355        template <> struct is_unsigned<unsigned long long> : true_type{};
     356        template <> struct is_unsigned<const unsigned long long> : true_type{};
    357357
    358358        template <> struct is_signed<char> : integral_constant<bool, ( char( 0 ) > char( -1 ) ) >{};
     
    618618                long double             dummy1;
    619619                void*                   dummy2;
    620                 sint64                  dummy3;
     620                long long               dummy3;
    621621                detail::aligned_fptr    dummy4;
    622622                detail::aligned_memptr  dummy5;
  • trunk/src/core/logger.cc

    r368 r376  
    88#include "nv/core/time.hh"
    99#include <cstdio>
    10 #if NV_PLATFORM == NV_WINDOWS
     10#if NV_COMPILER == NV_MSVC
    1111#define WIN32_LEAN_AND_MEAN
    1212#include <Windows.h>
     
    5151#define NV_LOG_LEVEL_NAME_PAD(level) (log_level_names_pad[ (level) / 10 ])
    5252
    53 #if NV_PLATFORM == NV_WINDOWS
     53#if NV_COMPILER == NV_MSVC
    5454static unsigned short log_color[] =
    5555{
     
    145145        size_t ssize = timestamp( stamp );
    146146
    147 #if NV_PLATFORM == NV_WINDOWS
     147#if NV_COMPILER == NV_MSVC
    148148        if ( m_color ) SetConsoleTextAttribute( m_handle, FOREGROUND_INTENSITY );
    149149        WriteConsole( m_handle, stamp, ssize, nullptr, nullptr );
     
    170170        else
    171171                fwrite( "] ", 2, 1, stdout );
    172         fwrite( stamp.data(), stamp.size(), 1, stdout );
     172        fwrite( message.data(), message.size(), 1, stdout );
    173173        fwrite( "\n", 1, 1, stdout );
    174174#endif
     
    233233        : m_color( coloring )
    234234{
    235 #if NV_PLATFORM == NV_WINDOWS
     235#if NV_COMPILER == NV_MSVC
    236236        m_handle = GetStdHandle( STD_OUTPUT_HANDLE );
    237237#else
     
    240240}
    241241
    242 size_t nv::log_sink::timestamp( char* buffer ) const
     242nv::size_t nv::log_sink::timestamp( char* buffer ) const
    243243{
    244244        uint32 ms = get_system_ms();
     
    248248        unsigned int m    = (unsigned int)(secs / 60) % 60;
    249249        unsigned int s    = secs % 60;
    250 #if NV_PLATFORM == NV_WINDOWS
     250#if NV_COMPILER == NV_MSVC
    251251        sprintf_s( buffer, 16, "%02d:%02d:%02d.%02d", h, m, s, mm );
    252252#else
  • trunk/src/core/profiler.cc

    r371 r376  
    1212using namespace nv;
    1313
    14 #ifdef NV_MSVC
     14#if NV_COMPILER == NV_MSVC
    1515#define snprintf sprintf_s
    1616#endif
  • trunk/src/core/time.cc

    r319 r376  
    77#include "nv/core/logging.hh"
    88
     9#include <ctime>
     10
    911#if NV_COMPILER == NV_MSVC
    1012#define WIN32_LEAN_AND_MEAN
     
    1315#pragma intrinsic(__rdtsc)
    1416#else
    15 #include <unistd.h>
     17#if NV_COMPILER == NV_GNUC && NV_PLATFORM == NV_WINDOWS
     18// mingw doesn't have usleep nor nanosleep...
     19#include <windows.h>
     20#endif
     21// #include <unistd.h>
     22// #include <time.h>
     23// #include <sys/time.h>
     24// #include <sys/types.h>
     25#include <stdio.h>
     26#include <time.h>
    1627#include <sys/time.h>
    1728#endif
    1829
    19 #include <ctime>
     30
    2031
    2132struct timer_impl
     
    5869        Sleep( ms );
    5970#else
    60         usleep( ms * 1000 );
     71#if NV_COMPILER == NV_GNUC && NV_PLATFORM == NV_WINDOWS
     72        Sleep( ms );
     73#else
     74        struct timespec ts;
     75        ts.tv_sec = 0;
     76        ts.tv_nsec = ms * 1000000;
     77        nanosleep(&ts, NULL);
     78//      usleep( ms * 1000 );
     79#endif
    6180#endif
    6281}
  • trunk/src/formats/assimp_loader.cc

    r367 r376  
    479479}
    480480
    481 size_t nv::assimp_loader::get_nodes_data_count() const
     481nv::size_t nv::assimp_loader::get_nodes_data_count() const
    482482{
    483483        if ( m_scene == nullptr ) return 0;
  • trunk/src/formats/md2_loader.cc

    r374 r376  
    167167       
    168168        source.seek( md2->header.offset_skins, origin::SET );
    169         source.read( md2->skins, sizeof(md2_skin_t), static_cast<size_t>( md2->header.num_skins ) );
     169        source.read( md2->skins, sizeof( md2_skin_t ), static_cast<nv::size_t>( md2->header.num_skins ) );
    170170
    171171        source.seek( md2->header.offset_st, origin::SET );
    172         source.read( md2->texcoords, sizeof(md2_texcoord_t), static_cast<size_t>( md2->header.num_st ) );
     172        source.read( md2->texcoords, sizeof( md2_texcoord_t ), static_cast<nv::size_t>( md2->header.num_st ) );
    173173
    174174        source.seek( md2->header.offset_tris, origin::SET );
    175         source.read( md2->triangles, sizeof(md2_triangle_t), static_cast<size_t>( md2->header.num_tris ) );
     175        source.read( md2->triangles, sizeof( md2_triangle_t ), static_cast<nv::size_t>( md2->header.num_tris ) );
    176176
    177177        source.seek( md2->header.offset_glcmds, origin::SET);
    178         source.read( md2->glcmds, sizeof(int), static_cast<size_t>( md2->header.num_glcmds ) );
     178        source.read( md2->glcmds, sizeof( int ), static_cast<nv::size_t>( md2->header.num_glcmds ) );
    179179
    180180        md2->frames    = new md2_frame_t   [ md2->header.num_frames ];
  • trunk/src/formats/md3_loader.cc

    r374 r376  
    161161
    162162        source.seek( pos + surface->header.ofs_shaders, origin::SET );
    163         source.read( surface->shaders, sizeof( md3_shader_t ), static_cast<size_t>( surface->header.num_shaders ) );
     163        source.read( surface->shaders, sizeof( md3_shader_t ), static_cast<nv::size_t>( surface->header.num_shaders ) );
    164164
    165165        source.seek( pos + surface->header.ofs_triangles, origin::SET );
    166         source.read( surface->triangles, sizeof( md3_triangle_t ), static_cast<size_t>( surface->header.num_triangles ) );
     166        source.read( surface->triangles, sizeof( md3_triangle_t ), static_cast<nv::size_t>( surface->header.num_triangles ) );
    167167
    168168        source.seek( pos + surface->header.ofs_st, origin::SET );
    169         source.read( surface->st, sizeof( md3_texcoord_t ), static_cast<size_t>( surface->header.num_verts ) );
     169        source.read( surface->st, sizeof( md3_texcoord_t ), static_cast<nv::size_t>( surface->header.num_verts ) );
    170170
    171171        source.seek( pos + surface->header.ofs_xyznormal, origin::SET );
    172         source.read( surface->vertices, sizeof( md3_vertex_t ), static_cast<size_t>( surface->header.num_verts * surface->header.num_frames ) );
    173 
    174         if ( source.tell() != static_cast<size_t>( pos + surface->header.ofs_end ) ) return false;
     172        source.read( surface->vertices, sizeof( md3_vertex_t ), static_cast<nv::size_t>( surface->header.num_verts * surface->header.num_frames ) );
     173
     174        if ( source.tell() != static_cast<nv::size_t>( pos + surface->header.ofs_end ) ) return false;
    175175
    176176        return true;
     
    198198        md3->tags     = new md3_tag_t    [ md3->header.num_tags * md3->header.num_frames ];
    199199        md3->surfaces = new md3_surface_t[ md3->header.num_surfaces ];
    200         std::memset( md3->surfaces, 0, static_cast< size_t >( md3->header.num_surfaces ) * sizeof(md3_surface_t) );
     200        std::memset( md3->surfaces, 0, static_cast< nv::size_t >( md3->header.num_surfaces ) * sizeof( md3_surface_t ) );
    201201
    202202        source.seek( md3->header.ofs_frames, origin::SET );
    203         source.read( md3->frames, sizeof( md3_frame_t ), static_cast<size_t>( md3->header.num_frames ) );
     203        source.read( md3->frames, sizeof( md3_frame_t ), static_cast<nv::size_t>( md3->header.num_frames ) );
    204204
    205205        if ( md3->header.num_tags > 0 )
    206206        {
    207207                source.seek( md3->header.ofs_tags, origin::SET );
    208                 source.read( md3->tags, sizeof( md3_tag_t ), static_cast<size_t>( md3->header.num_tags * md3->header.num_frames ) );
     208                source.read( md3->tags, sizeof( md3_tag_t ), static_cast<nv::size_t>( md3->header.num_tags * md3->header.num_frames ) );
    209209        }
    210210
     
    321321};
    322322
    323 mesh_data* nv::md3_loader::release_mesh_data( size_t index )
     323mesh_data* nv::md3_loader::release_mesh_data( nv::size_t index )
    324324{
    325325        mesh_data* data = new mesh_data;
     
    417417}
    418418
    419 mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( size_t )
     419mesh_nodes_data* nv::md3_loader::release_mesh_nodes_data( nv::size_t )
    420420{
    421421        md3_t* md3 = (md3_t*)m_md3;
     
    464464}
    465465
    466 size_t md3_loader::get_max_frames() const
     466nv::size_t md3_loader::get_max_frames() const
    467467{
    468468        return static_cast< size_t >( ((md3_t*)m_md3)->header.num_frames );
  • trunk/src/formats/md5_loader.cc

    r374 r376  
    2424static void remove_quotes( std::string& str )
    2525{
    26         size_t n;
     26        nv::size_t n;
    2727        while ( ( n = str.find('\"') ) != std::string::npos ) str.erase(n,1);
    2828}
  • trunk/src/formats/obj_loader.cc

    r374 r376  
    5353        std::string next_name;
    5454
    55         size_t size;
     55        nv::size_t size;
    5656        bool   eof;
    5757
    5858        obj_reader();
    5959        bool read_stream( std::istream& stream );
    60         virtual size_t add_face( uint32* vi, uint32* ti, uint32* ni, size_t count ) = 0;
    61         virtual size_t raw_size() const = 0;
     60        virtual nv::size_t add_face( uint32* vi, uint32* ti, uint32* ni, nv::size_t count ) = 0;
     61        virtual nv::size_t raw_size() const = 0;
    6262        virtual void reset() = 0;
    6363        virtual const uint8* raw_pointer() const = 0;
     
    172172{
    173173        mesh_data_reader( bool normals ) : m_normals( normals ) {}
    174         virtual size_t add_face( uint32* vi, uint32* ti, uint32* ni, size_t count )
     174        virtual nv::size_t add_face( uint32* vi, uint32* ti, uint32* ni, nv::size_t count )
    175175        {
    176176                if ( count < 3 ) return 0; // TODO : report error?
     
    178178                // TODO : support if normals not present;
    179179                vec3 nullvec;
    180                 size_t result = 0;
     180                nv::size_t result = 0;
    181181                // Simple triangulation - obj's shouldn't have more than quads anyway
    182182
    183183                if ( m_normals )
    184184                {
    185                         for ( size_t i = 2; i < count; ++i )
     185                        for ( nv::size_t i = 2; i < count; ++i )
    186186                        {
    187187                                result++;
     
    193193                else
    194194                {
    195                         for ( size_t i = 2; i < count; ++i )
     195                        for ( nv::size_t i = 2; i < count; ++i )
    196196                        {
    197197                                result++;
     
    206206        std::vector< VTX > m_data;
    207207        virtual void reset() { m_data.clear(); }
    208         virtual size_t raw_size() const { return m_data.size() * sizeof( VTX ); }
     208        virtual nv::size_t raw_size() const { return m_data.size() * sizeof( VTX ); }
    209209        virtual const uint8* raw_pointer() const { return (const uint8*)m_data.data(); }
    210210};
     
    233233                //              std::vector< vec3 >& tg = m_mesh->get_tangents();
    234234
    235                 size_t count = m_data.size();
    236                 size_t tcount = count / 3;
     235                nv::size_t count = m_data.size();
     236                nv::size_t tcount = count / 3;
    237237
    238238                std::vector< vec3 > tan1( count );
    239239                std::vector< vec3 > tan2( count );
    240240
    241                 for (size_t a = 0; a < tcount; ++a )
    242                 {
    243                         size_t i1 = a * 3;
    244                         size_t i2 = a * 3 + 1;
    245                         size_t i3 = a * 3 + 2;
     241                for ( nv::size_t a = 0; a < tcount; ++a )
     242                {
     243                        nv::size_t i1 = a * 3;
     244                        nv::size_t i2 = a * 3 + 1;
     245                        nv::size_t i3 = a * 3 + 2;
    246246                        obj_vertex_vtnt& vtx1 = m_data[ i1 ];
    247247                        obj_vertex_vtnt& vtx2 = m_data[ i2 ];
     
    278278                }
    279279
    280                 for (size_t a = 0; a < count; ++a )
     280                for ( nv::size_t a = 0; a < count; ++a )
    281281                {
    282282                        const vec3& n = m_data[a].normal;
  • trunk/src/gfx/image.cc

    r374 r376  
    77using namespace nv;
    88
    9 image::image( glm::ivec2 size, size_t depth )
     9image::image( glm::ivec2 size, nv::size_t depth )
    1010        : m_size( size ), m_depth( depth ), m_data( nullptr )
    1111{
     
    2020
    2121
    22 image::image( glm::ivec2 size, size_t depth, const uint8 * data, bool reversed )
     22image::image( glm::ivec2 size, nv::size_t depth, const uint8 * data, bool reversed )
    2323        : m_size( size ), m_depth( depth ), m_data( nullptr )
    2424{
  • trunk/src/gfx/keyframed_mesh.cc

    r367 r376  
    3636}
    3737
    38 size_t keyframed_mesh::get_max_frames() const
     38nv::size_t keyframed_mesh::get_max_frames() const
    3939{
    4040        return m_frame_count;
  • trunk/src/gfx/texture_atlas.cc

    r367 r376  
    1111using namespace nv;
    1212
    13 texture_atlas::texture_atlas( glm::ivec2 size, size_t depth, size_t border /*= 1*/ )
     13texture_atlas::texture_atlas( glm::ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ )
    1414        : image( size, depth ), m_used( 0 ), m_border( border )
    1515{
     
    8282}
    8383
    84 int texture_atlas::fit( size_t index, glm::ivec2 size )
     84int texture_atlas::fit( nv::size_t index, glm::ivec2 size )
    8585{
    8686        glm::ivec3 node = m_nodes[ index ];
  • trunk/src/gl/gl_context.cc

    r365 r376  
    329329}
    330330
    331 void gl_context::update( buffer b, const void* data, size_t offset, size_t size )
     331void gl_context::update( buffer b, const void* data, nv::size_t offset, nv::size_t size )
    332332{
    333333        const gl_buffer_info* info = static_cast< const gl_buffer_info* >( m_device->get_buffer_info( b ) );
     
    748748}
    749749
    750 void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count )
     750void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, nv::size_t count )
    751751{
    752752        apply_render_state( rs );
  • trunk/src/gui/gui_gfx_renderer.cc

    r367 r376  
    107107{
    108108public:
    109         screen_render_data( context* actx, size_t initial_size )
     109        screen_render_data( context* actx, nv::size_t initial_size )
    110110                : buffer( actx, VERTEX_BUFFER, DYNAMIC_DRAW, initial_size ), ctx( actx ), varray(), shader()
    111111        {
     
    175175}
    176176
    177 texture_font* gfx_renderer::get_font( size_t name ) const
     177texture_font* gfx_renderer::get_font( nv::size_t name ) const
    178178{
    179179        if ( name >= m_fonts.size() ) return nullptr;
     
    181181}
    182182
    183 const image_info* gfx_renderer::get_image( size_t name ) const
     183const image_info* gfx_renderer::get_image( nv::size_t name ) const
    184184{
    185185        if ( name >= m_images.size() ) return nullptr;
     
    187187}
    188188
    189 size_t gfx_renderer::load_font( const std::string& filename, size_t size )
     189nv::size_t gfx_renderer::load_font( const std::string& filename, nv::size_t size )
    190190{
    191191        std::string id_name( filename );
     
    205205}
    206206
    207 size_t gfx_renderer::load_image( const std::string& filename )
     207nv::size_t gfx_renderer::load_image( const std::string& filename )
    208208{
    209209        auto i = m_image_names.find( filename );
  • trunk/src/io/c_stream.cc

    r374 r376  
    33// For conditions of distribution and use, see copyright notice in nv.hh
    44
     5#include "nv/io/c_stream.hh"
    56#include <cstdio>
    67#include <sys/stat.h>
    7 #include "nv/io/c_stream.hh"
    88
    99using namespace nv;
     
    3333}
    3434
    35 size_t c_stream::read( void* buffer, size_t size, size_t count )
     35nv::size_t c_stream::read( void* buffer, nv::size_t size, nv::size_t count )
    3636{
    3737        NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to read!" );
     
    3939}
    4040
    41 size_t c_stream::write( const void* buffer, size_t size, size_t count )
     41nv::size_t c_stream::write( const void* buffer, nv::size_t size, nv::size_t count )
    4242{
    4343        NV_ASSERT( buffer != nullptr && size != 0 && count != 0, "Bad parameter passed to write!" );
     
    5050}
    5151
    52 size_t c_stream::tell()
     52nv::size_t c_stream::tell()
    5353{
    54         return m_file != nullptr ? static_cast< size_t >( ::ftell( (FILE*)m_file ) ) : 0;
     54        return m_file != nullptr ? static_cast< nv::size_t >( ::ftell( (FILE*)m_file ) ) : 0;
    5555}
    5656
    57 size_t c_stream::size()
     57nv::size_t c_stream::size()
    5858{
    5959        if ( m_file == nullptr || m_file_name == nullptr )
  • trunk/src/lua/lua_path.cc

    r360 r376  
    3232}
    3333
    34 void lua::path::push( size_t value )
     34void lua::path::push( nv::size_t value )
    3535{
    3636        m_elements[ m_count ].value  = value;
  • trunk/src/lua/lua_state.cc

    r368 r376  
    166166}
    167167
    168 size_t lua::table_guard::get_size()
     168nv::size_t lua::table_guard::get_size()
    169169{
    170170        return lua_rawlen( m_state, -1 );
Note: See TracChangeset for help on using the changeset viewer.