Changeset 533 for trunk/src


Ignore:
Timestamp:
01/12/17 13:16:48 (8 years ago)
Author:
epyon
Message:
  • getting rid of size_t
  • datatypes now restricted to uint32 size
  • 64-bit compatibility
  • copyright updates where modified
Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/logger.cc

    r402 r533  
    144144{
    145145        char stamp[16];
    146         size_t ssize = timestamp( stamp );
     146        uint32 ssize = timestamp( stamp );
    147147
    148148#if NV_COMPILER == NV_MSVC
     
    180180{
    181181        char stamp[16];
    182         size_t ssize = timestamp( stamp );
     182        uint32 ssize = timestamp( stamp );
    183183#if 0 // NV_PLATFORM == NV_WINDOWS
    184184        // Turns out WriteFile on Windows is unbuffered and quite slower than fwrite
     
    242242}
    243243
    244 nv::size_t nv::log_sink::timestamp( char* buffer ) const
     244nv::uint32 nv::log_sink::timestamp( char* buffer ) const
    245245{
    246246        uint32 ms = get_system_ms();
  • trunk/src/core/profiler.cc

    r409 r533  
    109109        char buffer[128];
    110110        snprintf( buffer, 128, "%-23s %6s %6s %9s %6s", "TAG", "%PARNT", "CALLS", "TOTAL(ms)", "AVG(ms)" );
    111         NV_LOG_INFO( string_view( buffer, nvstrlen( buffer ) ) );
     111        NV_LOG_INFO( string_view( buffer, static_cast< uint32 >( nvstrlen( buffer ) ) ) );
    112112        log_node_children( 0, m_root );
    113113        NV_LOG_INFO( "-- PROFILER REPORT END ---------------------------------" );
     
    131131                        snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent,
    132132                                c->m_tag.data(), pparent, calls, total_ms, avg_ms );
    133                         NV_LOG_INFO( string_view( buffer, nvstrlen( buffer ) ) );
     133                        NV_LOG_INFO( string_view( buffer, static_cast< uint32 >( nvstrlen( buffer ) ) ) );
    134134                        if ( c->m_children.size() > 0 )
    135135                        {
  • trunk/src/core/random.cc

    r509 r533  
    1616static const uint32 mt_matrix_a   = 0x9908B0DFUL;
    1717
    18 #define NV_MT_MIXBITS(u, v) ( ( (u) & mt_upper_mask) | ( (v) & mt_lower_mask) )
    19 #define NV_MT_TWIST(u, v)  ( (NV_MT_MIXBITS(u, v) >> 1) ^ ( (v) & 1UL ? mt_matrix_a : 0UL) )
     18#define NV_MT_MIXBITS(u, v) ( uint32( (u) & mt_upper_mask) | uint32( (v) & mt_lower_mask) )
     19#define NV_MT_TWIST(u, v)  ( uint32(NV_MT_MIXBITS(u, v) >> uint32(1)) ^ uint32( (v) & uint32(1) ? mt_matrix_a : uint32(0)) )
    2020
    2121nv::random& random::get()
     
    4343{
    4444        uint32 *p = m_state;
    45 
    46         for ( int count = ( mersenne_n - mersenne_m + 1 ); --count; p++ )
     45        constexpr int m = mersenne_m;
     46        constexpr int n = mersenne_n;
     47
     48        for ( int count = ( n - m + 1 ); --count; p++ )
    4749                *p = p[mersenne_m] ^ NV_MT_TWIST( p[0], p[1] );
    4850
    4951        for ( int count = mersenne_m; --count; p++ )
    50                 *p = p[mersenne_m - mersenne_n] ^ NV_MT_TWIST( p[0], p[1] );
    51 
    52         *p = p[mersenne_m - mersenne_n] ^ NV_MT_TWIST( p[0], m_state[0] );
     52        {
     53                *p = p[m - n] ^ NV_MT_TWIST( p[0], p[1] );
     54        }
     55
     56        *p = p[m - n] ^ NV_MT_TWIST( p[0], m_state[0] );
    5357
    5458        m_remaining = mersenne_n;
  • trunk/src/gfx/texture_atlas.cc

    r471 r533  
    1111using namespace nv;
    1212
    13 texture_atlas::texture_atlas( ivec2 size, nv::size_t depth, nv::size_t border /*= 1*/ )
     13texture_atlas::texture_atlas( ivec2 size, uint32 depth, uint32 border /*= 1*/ )
    1414        : image( size, depth ), m_used( 0 ), m_border( border )
    1515{
     
    2626        int best_width  = nv::limits::si_max;
    2727
    28         for( size_t i=0; i < m_nodes.size(); ++i )
     28        for( uint32 i=0; i < m_nodes.size(); ++i )
    2929        {
    3030                int y = fit( i, size );
     
    5151        m_nodes.insert( m_nodes.begin() + best_index, ivec3( r.pos.x, r.pos.y + size.y, size.x ) );
    5252
    53         for( size_t i = static_cast<size_t>( best_index )+1; i < m_nodes.size(); ++i )
     53        for( uint32 i = static_cast<uint32>( best_index )+1; i < m_nodes.size(); ++i )
    5454        {
    5555                ivec3 node = m_nodes[ i ];
     
    8282}
    8383
    84 int texture_atlas::fit( nv::size_t index, ivec2 size )
     84int texture_atlas::fit( uint32 index, ivec2 size )
    8585{
    8686        ivec3 node = m_nodes[ index ];
     
    113113void texture_atlas::merge()
    114114{
    115         for ( size_t i=0; i < m_nodes.size()-1; ++i )
     115        for ( uint32 i=0; i < m_nodes.size()-1; ++i )
    116116    {
    117117                if ( m_nodes[ i ].y == m_nodes[ i+1 ].y )
  • trunk/src/gl/gl_device.cc

    r506 r533  
    452452                glGetActiveUniform( p->glid, i, 128, &uni_nlen, &uni_len, &uni_type, name_buffer );
    453453
    454                 string_view name( name_buffer, size_t( uni_nlen ) );
     454                string_view name( name_buffer, uint32( uni_nlen ) );
    455455
    456456                // skip built-ins
     
    461461
    462462                // check for array
    463                 size_t arrchar = name.find( '[' );
     463                uint32 arrchar = name.find( '[' );
    464464                if ( arrchar != string_view::npos )
    465465                {
  • trunk/src/image/miniz.cc

    r520 r533  
    33
    44using namespace nv;
    5 
    6 #define MINIZ_NO_TIME
    7 #define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
    8 
    9 #define MINIZ_HAS_64BIT_REGISTERS 0
    10 #define TINFL_USE_64BIT_BITBUF 0
    115
    126#if NV_COMPILER == NV_CLANG
     
    1711
    1812#if defined( _M_IX86 ) || defined( _M_X64 ) || defined( __i386__ ) || defined( __i386 ) || defined( __i486__ ) || defined( __i486 ) || defined( i386 ) || defined( __ia64__ ) || defined( __x86_64__ )
    19 // MINIZ_X86_OR_X64_CPU is only used to help set the below macros.
    20 #define MINIZ_X86_OR_X64_CPU 1
    21 #endif
    22 
    23 #if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
    24 // Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian.
    25 #define MINIZ_LITTLE_ENDIAN 1
    26 #endif
    27 
    28 #if MINIZ_X86_OR_X64_CPU
    2913// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses.
    3014#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
    31 #endif
    32 
    33 #if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
    34 // Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions).
    35 #define MINIZ_HAS_64BIT_REGISTERS 1
    3615#endif
    3716
     
    204183        const char *mz_error( int err );
    205184
    206         // Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports.
    207         // Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project.
    208 #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
    209         typedef unsigned char Byte;
    210         typedef unsigned int uInt;
    211         typedef mz_ulong uLong;
    212         typedef Byte Bytef;
    213         typedef uInt uIntf;
    214         typedef char charf;
    215         typedef int intf;
    216         typedef void *voidpf;
    217         typedef uLong uLongf;
    218         typedef void *voidp;
    219         typedef void *const voidpc;
    220 #define Z_NULL                0
    221 #define Z_NO_FLUSH            MZ_NO_FLUSH
    222 #define Z_PARTIAL_FLUSH       MZ_PARTIAL_FLUSH
    223 #define Z_SYNC_FLUSH          MZ_SYNC_FLUSH
    224 #define Z_FULL_FLUSH          MZ_FULL_FLUSH
    225 #define Z_FINISH              MZ_FINISH
    226 #define Z_BLOCK               MZ_BLOCK
    227 #define Z_OK                  MZ_OK
    228 #define Z_STREAM_END          MZ_STREAM_END
    229 #define Z_NEED_DICT           MZ_NEED_DICT
    230 #define Z_ERRNO               MZ_ERRNO
    231 #define Z_STREAM_ERROR        MZ_STREAM_ERROR
    232 #define Z_DATA_ERROR          MZ_DATA_ERROR
    233 #define Z_MEM_ERROR           MZ_MEM_ERROR
    234 #define Z_BUF_ERROR           MZ_BUF_ERROR
    235 #define Z_VERSION_ERROR       MZ_VERSION_ERROR
    236 #define Z_PARAM_ERROR         MZ_PARAM_ERROR
    237 #define Z_NO_COMPRESSION      MZ_NO_COMPRESSION
    238 #define Z_BEST_SPEED          MZ_BEST_SPEED
    239 #define Z_BEST_COMPRESSION    MZ_BEST_COMPRESSION
    240 #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
    241 #define Z_DEFAULT_STRATEGY    MZ_DEFAULT_STRATEGY
    242 #define Z_FILTERED            MZ_FILTERED
    243 #define Z_HUFFMAN_ONLY        MZ_HUFFMAN_ONLY
    244 #define Z_RLE                 MZ_RLE
    245 #define Z_FIXED               MZ_FIXED
    246 #define Z_DEFLATED            MZ_DEFLATED
    247 #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
    248 #define alloc_func            mz_alloc_func
    249 #define free_func             mz_free_func
    250 #define internal_state        mz_internal_state
    251 #define z_stream              mz_stream
    252 #define deflateInit           mz_deflateInit
    253 #define deflateInit2          mz_deflateInit2
    254 #define deflateReset          mz_deflateReset
    255 #define deflate               mz_deflate
    256 #define deflateEnd            mz_deflateEnd
    257 #define deflateBound          mz_deflateBound
    258 #define compress              mz_compress
    259 #define compress2             mz_compress2
    260 #define compressBound         mz_compressBound
    261 #define inflateInit           mz_inflateInit
    262 #define inflateInit2          mz_inflateInit2
    263 #define inflate               mz_inflate
    264 #define inflateEnd            mz_inflateEnd
    265 #define uncompress            mz_uncompress
    266 #define crc32                 mz_crc32
    267 #define adler32               mz_adler32
    268 #define MAX_WBITS             15
    269 #define MAX_MEM_LEVEL         9
    270 #define zError                mz_error
    271 #define ZLIB_VERSION          MZ_VERSION
    272 #define ZLIB_VERNUM           MZ_VERNUM
    273 #define ZLIB_VER_MAJOR        MZ_VER_MAJOR
    274 #define ZLIB_VER_MINOR        MZ_VER_MINOR
    275 #define ZLIB_VER_REVISION     MZ_VER_REVISION
    276 #define ZLIB_VER_SUBREVISION  MZ_VER_SUBREVISION
    277 #define zlibVersion           mz_version
    278 #define zlib_version          mz_version()
    279 #endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
    280185
    281186#endif // MINIZ_NO_ZLIB_APIS
     
    321226                mz_uint16 m_bit_flag;
    322227                mz_uint16 m_method;
    323 #ifndef MINIZ_NO_TIME
    324                 time_t m_time;
    325 #endif
     228//              time_t m_time;
     229
    326230                mz_uint32 m_crc32;
    327231                mz_uint64 m_comp_size;
     
    567471        } tinfl_huff_table;
    568472
    569 #if MINIZ_HAS_64BIT_REGISTERS
    570 #define TINFL_USE_64BIT_BITBUF 1
    571 #endif
    572 
    573 #if TINFL_USE_64BIT_BITBUF
     473#if NV_ARCHITECTURE == NV_64BIT
    574474        typedef mz_uint64 tinfl_bit_buf_t;
    575475#define TINFL_BITBUF_SIZE (64)
     
    766666#define MZ_CLEAR_OBJ(obj) nvmemset(&(obj), 0, sizeof(obj))
    767667
    768 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
     668#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && NV_ENDIANESS == NV_LITTLEENDIAN
    769669#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
    770670#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
     
    13821282                                                {
    13831283                                                        int sym2; mz_uint code_len;
    1384 #if TINFL_USE_64BIT_BITBUF
     1284#if NV_ARCHITECTURE == NV_64BIT
    13851285                                                        if ( num_bits < 30 ) { bit_buf |= ( ( (tinfl_bit_buf_t)MZ_READ_LE32( pIn_buf_cur ) ) << num_bits ); pIn_buf_cur += 4; num_bits += 32; }
    13861286#else
     
    13971297                                                                break;
    13981298
    1399 #if !TINFL_USE_64BIT_BITBUF
     1299#if NV_ARCHITECTURE == NV_32BIT
    14001300                                                        if ( num_bits < 15 ) { bit_buf |= ( ( (tinfl_bit_buf_t)MZ_READ_LE16( pIn_buf_cur ) ) << num_bits ); pIn_buf_cur += 2; num_bits += 16; }
    14011301#endif
     
    18351735        static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
    18361736
    1837 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
     1737#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && NV_ENDIANESS == NV_LITTLEENDIAN && NV_ARCHITECTURE == NV_64BIT
     1738
    18381739        static mz_bool tdefl_compress_lz_codes( tdefl_compressor *d )
    18391740        {
     
    19681869                return ( d->m_pOutput_buf < d->m_pOutput_buf_end );
    19691870        }
    1970 #endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
     1871#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && NV_ENDIANESS == NV_LITTLEENDIAN && NV_ARCHITECTURE == NV_64BIT
     1872
    19711873
    19721874        static mz_bool tdefl_compress_block( tdefl_compressor *d, mz_bool static_block )
     
    21452047#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
    21462048
    2147 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
     2049#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && NV_ENDIANESS == NV_LITTLEENDIAN
    21482050        static mz_bool tdefl_compress_fast( tdefl_compressor *d )
    21492051        {
     
    24802382                        return ( d->m_prev_return_status = tdefl_flush_output_buffer( d ) );
    24812383
    2482 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
     2384#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && NV_ENDIANESS == NV_LITTLEENDIAN
    24832385                if ( ( ( d->m_flags & TDEFL_MAX_PROBES_MASK ) == 1 ) &&
    24842386                        ( ( d->m_flags & TDEFL_GREEDY_PARSING_FLAG ) != 0 ) &&
     
    24892391                }
    24902392                else
    2491 #endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
     2393#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && NV_ENDIANESS == NV_LITTLEENDIAN
    24922394                {
    24932395                        if ( !tdefl_compress_normal( d ) )
  • trunk/src/io/c_file_system.cc

    r438 r533  
    4848        stream* fstream = open( path, "rb" );
    4949        if ( !fstream ) return const_string();
    50         uint32 size = fstream->size();
     50        uint32 size = static_cast< uint32 >( fstream->size() );
    5151        const_string result( nullptr, size );
    5252        fstream->read( const_cast<char*>( result.data() ), size, 1 );
  • trunk/src/lua/lua_state.cc

    r515 r533  
    172172}
    173173
    174 nv::size_t lua::table_guard::get_size()
     174nv::uint32 lua::table_guard::get_size()
    175175{
    176176        return nlua_rawlen( m_state, -1 );
     
    194194        {
    195195                str = lua_tolstring( m_state, -1, &l );
    196                 result = hash_string< uint64 >( str, l );
     196                result = hash_string< uint64 >( str, static_cast< uint32 >( l ) );
    197197                //NV_LOG_DEBUG( str );
    198198        }
     
    210210        {
    211211                str = lua_tolstring( m_state, -1, &l );
    212                 string_view sv( str, l );
     212                string_view sv( str, static_cast< uint32 >( l ) );
    213213                result = table ? table->insert( sv ) : shash64( sv );
    214214        }
     
    226226        {
    227227                str = lua_tolstring( m_state, -1, &l );
    228                 result = hash_string< uint64 >( str, l );
     228                result = hash_string< uint64 >( str, static_cast< uint32 >( l ) );
    229229                //NV_LOG_DEBUG( str );
    230230        }
     
    247247                str = defval.data();
    248248        }
    249         string128 result( str, l );
     249        string128 result( str, static_cast< uint32 >( l ) );
    250250        lua_pop( m_state, 1 );
    251251        return result;
     
    266266                str = defval.data();
    267267        }
    268         const_string result( str, l );
     268        const_string result( str, static_cast< uint32 >( l ) );
    269269        lua_pop( m_state, 1 );
    270270        return result;
     
    280280        {
    281281                str = lua_tolstring( m_state, -1, &l );
    282                 string_view sv( str, l );
     282                string_view sv( str, static_cast< uint32 >( l ) );
    283283                result = table ? table->insert( sv ) : shash64( sv );
    284284        }
     
    301301                str = defval.data();
    302302        }
    303         const_string result( str, l );
     303        const_string result( str, static_cast< uint32 >( l ) );
    304304        lua_pop( m_state, 1 );
    305305        return result;
     
    320320                str = defval.data();
    321321        }
    322         string128 result( str, l );
     322        string128 result( str, static_cast< uint32 >( l ) );
    323323        lua_pop( m_state, 1 );
    324324        return result;
     
    339339                str = defval.data();
    340340        }
    341         string64 result( str, l );
     341        string64 result( str, static_cast< uint32 >( l ) );
    342342        lua_pop( m_state, 1 );
    343343        return result;
     
    359359                str = defval.data();
    360360        }
    361         string32 result( str, l );
     361        string32 result( str, static_cast< uint32 >( l ) );
    362362        lua_pop( m_state, 1 );
    363363        return result;
  • trunk/src/lua/lua_values.cc

    r490 r533  
    105105        size_t length = 0;
    106106        const char* result = lua_tolstring( L, index, &length );
    107         return string_view( result, length );
     107        return string_view( result, static_cast< uint32 >( length ) );
    108108}
    109109
  • trunk/src/stl/string.cc

    r442 r533  
    2727}
    2828
    29 nv::size_t nv::sint32_to_buffer( array_ref< char > buffer, sint32 n )
     29nv::uint32 nv::sint32_to_buffer( array_ref< char > buffer, sint32 n )
    3030{
    3131        if ( buffer.size() < 2 ) return 0;
     
    4646        *s = '\0';
    4747        string_reverse( buffer.begin(), s - 1 );
    48         return static_cast<nv::size_t>( s - buffer.begin() );
    49 }
    50 
    51 nv::size_t nv::sint64_to_buffer( array_ref< char > buffer, sint64 n )
     48        return static_cast<nv::uint32>( s - buffer.begin() );
     49}
     50
     51nv::uint32 nv::sint64_to_buffer( array_ref< char > buffer, sint64 n )
    5252{
    5353        if ( buffer.size() < 2 ) return 0;
     
    6868        *s = '\0';
    6969        string_reverse( buffer.begin(), s - 1 );
    70         return static_cast<nv::size_t>( s - buffer.begin() );
    71 }
    72 
    73 nv::size_t nv::uint32_to_buffer( array_ref< char > buffer, uint32 n )
     70        return static_cast<nv::uint32>( s - buffer.begin() );
     71}
     72
     73nv::uint32 nv::uint32_to_buffer( array_ref< char > buffer, uint32 n )
    7474{
    7575        if ( buffer.size() < 2 ) return 0;
     
    8484        *s = '\0';
    8585        string_reverse( buffer.begin(), s - 1 );
    86         return static_cast<nv::size_t>( s - buffer.begin() );
    87 }
    88 
    89 nv::size_t nv::uint64_to_buffer( array_ref< char > buffer, uint64 n )
     86        return static_cast<nv::uint32>( s - buffer.begin() );
     87}
     88
     89nv::uint32 nv::uint64_to_buffer( array_ref< char > buffer, uint64 n )
    9090{
    9191        if ( buffer.size() < 2 ) return 0;
     
    100100        *s = '\0';
    101101        string_reverse( buffer.begin(), s - 1 );
    102         return static_cast<nv::size_t>( s - buffer.begin() );
    103 }
    104 
    105 nv::size_t nv::f32_to_buffer( array_ref< char > buffer, f32 n )
     102        return static_cast<nv::uint32>( s - buffer.begin() );
     103}
     104
     105nv::uint32 nv::f32_to_buffer( array_ref< char > buffer, f32 n )
    106106{
    107107#if NV_COMPILER == NV_MSVC
     
    110110        int result = snprintf( buffer.data(), buffer.size(), "%.*g", 6, n );
    111111#endif
    112         return static_cast<nv::size_t>( result > 0 ? result : 0 );
    113 }
    114 
    115 nv::size_t nv::f64_to_buffer( array_ref< char > buffer, f64 n )
     112        return static_cast<nv::uint32>( result > 0 ? result : 0 );
     113}
     114
     115nv::uint32 nv::f64_to_buffer( array_ref< char > buffer, f64 n )
    116116{
    117117#if NV_COMPILER == NV_MSVC
     
    120120        int result = snprintf( buffer.data(), buffer.size(), "%.*g", 6, n );
    121121#endif
    122         return static_cast<nv::size_t>( result > 0 ? result : 0 );
     122        return static_cast<nv::uint32>( result > 0 ? result : 0 );
    123123}
    124124
Note: See TracChangeset for help on using the changeset viewer.