Changeset 533 for trunk/src/image


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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ) )
Note: See TracChangeset for help on using the changeset viewer.