extlzham 0.0.1.PROTOTYPE3-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/LICENSE.md +27 -0
 - data/README.md +74 -0
 - data/Rakefile +152 -0
 - data/contrib/lzham/LICENSE +22 -0
 - data/contrib/lzham/README.md +209 -0
 - data/contrib/lzham/include/lzham.h +781 -0
 - data/contrib/lzham/lzhamcomp/lzham_comp.h +38 -0
 - data/contrib/lzham/lzhamcomp/lzham_lzbase.cpp +244 -0
 - data/contrib/lzham/lzhamcomp/lzham_lzbase.h +45 -0
 - data/contrib/lzham/lzhamcomp/lzham_lzcomp.cpp +608 -0
 - data/contrib/lzham/lzhamcomp/lzham_lzcomp_internal.cpp +1966 -0
 - data/contrib/lzham/lzhamcomp/lzham_lzcomp_internal.h +472 -0
 - data/contrib/lzham/lzhamcomp/lzham_lzcomp_state.cpp +1413 -0
 - data/contrib/lzham/lzhamcomp/lzham_match_accel.cpp +562 -0
 - data/contrib/lzham/lzhamcomp/lzham_match_accel.h +146 -0
 - data/contrib/lzham/lzhamcomp/lzham_null_threading.h +97 -0
 - data/contrib/lzham/lzhamcomp/lzham_pthreads_threading.cpp +229 -0
 - data/contrib/lzham/lzhamcomp/lzham_pthreads_threading.h +520 -0
 - data/contrib/lzham/lzhamcomp/lzham_threading.h +12 -0
 - data/contrib/lzham/lzhamcomp/lzham_win32_threading.cpp +220 -0
 - data/contrib/lzham/lzhamcomp/lzham_win32_threading.h +368 -0
 - data/contrib/lzham/lzhamdecomp/lzham_assert.cpp +66 -0
 - data/contrib/lzham/lzhamdecomp/lzham_assert.h +40 -0
 - data/contrib/lzham/lzhamdecomp/lzham_checksum.cpp +73 -0
 - data/contrib/lzham/lzhamdecomp/lzham_checksum.h +13 -0
 - data/contrib/lzham/lzhamdecomp/lzham_config.h +23 -0
 - data/contrib/lzham/lzhamdecomp/lzham_core.h +264 -0
 - data/contrib/lzham/lzhamdecomp/lzham_decomp.h +37 -0
 - data/contrib/lzham/lzhamdecomp/lzham_helpers.h +54 -0
 - data/contrib/lzham/lzhamdecomp/lzham_huffman_codes.cpp +262 -0
 - data/contrib/lzham/lzhamdecomp/lzham_huffman_codes.h +14 -0
 - data/contrib/lzham/lzhamdecomp/lzham_lzdecomp.cpp +1527 -0
 - data/contrib/lzham/lzhamdecomp/lzham_lzdecompbase.cpp +131 -0
 - data/contrib/lzham/lzhamdecomp/lzham_lzdecompbase.h +89 -0
 - data/contrib/lzham/lzhamdecomp/lzham_math.h +142 -0
 - data/contrib/lzham/lzhamdecomp/lzham_mem.cpp +284 -0
 - data/contrib/lzham/lzhamdecomp/lzham_mem.h +112 -0
 - data/contrib/lzham/lzhamdecomp/lzham_platform.cpp +157 -0
 - data/contrib/lzham/lzhamdecomp/lzham_platform.h +284 -0
 - data/contrib/lzham/lzhamdecomp/lzham_prefix_coding.cpp +351 -0
 - data/contrib/lzham/lzhamdecomp/lzham_prefix_coding.h +146 -0
 - data/contrib/lzham/lzhamdecomp/lzham_symbol_codec.cpp +1484 -0
 - data/contrib/lzham/lzhamdecomp/lzham_symbol_codec.h +556 -0
 - data/contrib/lzham/lzhamdecomp/lzham_timer.cpp +147 -0
 - data/contrib/lzham/lzhamdecomp/lzham_timer.h +99 -0
 - data/contrib/lzham/lzhamdecomp/lzham_traits.h +141 -0
 - data/contrib/lzham/lzhamdecomp/lzham_types.h +97 -0
 - data/contrib/lzham/lzhamdecomp/lzham_utils.h +58 -0
 - data/contrib/lzham/lzhamdecomp/lzham_vector.cpp +75 -0
 - data/contrib/lzham/lzhamdecomp/lzham_vector.h +588 -0
 - data/contrib/lzham/lzhamlib/lzham_lib.cpp +179 -0
 - data/examples/basic.rb +48 -0
 - data/ext/constants.c +64 -0
 - data/ext/decoder.c +313 -0
 - data/ext/depend +5 -0
 - data/ext/encoder.c +372 -0
 - data/ext/error.c +80 -0
 - data/ext/extconf.rb +29 -0
 - data/ext/extlzham.c +34 -0
 - data/ext/extlzham.h +62 -0
 - data/gemstub.rb +22 -0
 - data/lib/2.0/extlzham.so +0 -0
 - data/lib/2.1/extlzham.so +0 -0
 - data/lib/2.2/extlzham.so +0 -0
 - data/lib/extlzham.rb +158 -0
 - data/lib/extlzham/version.rb +5 -0
 - data/test/test_extlzham.rb +35 -0
 - metadata +156 -0
 
| 
         @@ -0,0 +1,147 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // File: lzham_timer.cpp
         
     | 
| 
      
 2 
     | 
    
         
            +
            // See Copyright Notice and license at the end of include/lzham.h
         
     | 
| 
      
 3 
     | 
    
         
            +
            #include "lzham_core.h"
         
     | 
| 
      
 4 
     | 
    
         
            +
            #include "lzham_timer.h"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            #ifndef LZHAM_USE_WIN32_API
         
     | 
| 
      
 7 
     | 
    
         
            +
               #include <time.h>
         
     | 
| 
      
 8 
     | 
    
         
            +
            #endif   
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            namespace lzham
         
     | 
| 
      
 11 
     | 
    
         
            +
            {
         
     | 
| 
      
 12 
     | 
    
         
            +
               unsigned long long lzham_timer::g_init_ticks;
         
     | 
| 
      
 13 
     | 
    
         
            +
               unsigned long long lzham_timer::g_freq;
         
     | 
| 
      
 14 
     | 
    
         
            +
               double lzham_timer::g_inv_freq;
         
     | 
| 
      
 15 
     | 
    
         
            +
               
         
     | 
| 
      
 16 
     | 
    
         
            +
               #if LZHAM_USE_WIN32_API
         
     | 
| 
      
 17 
     | 
    
         
            +
                  inline void query_counter(timer_ticks *pTicks)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  {
         
     | 
| 
      
 19 
     | 
    
         
            +
                     QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(pTicks));
         
     | 
| 
      
 20 
     | 
    
         
            +
                  }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  inline void query_counter_frequency(timer_ticks *pTicks)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  {
         
     | 
| 
      
 23 
     | 
    
         
            +
                     QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(pTicks));
         
     | 
| 
      
 24 
     | 
    
         
            +
                  }
         
     | 
| 
      
 25 
     | 
    
         
            +
               #else
         
     | 
| 
      
 26 
     | 
    
         
            +
                  inline void query_counter(timer_ticks *pTicks)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  {
         
     | 
| 
      
 28 
     | 
    
         
            +
                     *pTicks = clock();
         
     | 
| 
      
 29 
     | 
    
         
            +
                  }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  inline void query_counter_frequency(timer_ticks *pTicks)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  {
         
     | 
| 
      
 32 
     | 
    
         
            +
                     *pTicks = CLOCKS_PER_SEC;
         
     | 
| 
      
 33 
     | 
    
         
            +
                  }
         
     | 
| 
      
 34 
     | 
    
         
            +
               #endif
         
     | 
| 
      
 35 
     | 
    
         
            +
               
         
     | 
| 
      
 36 
     | 
    
         
            +
               lzham_timer::lzham_timer() :
         
     | 
| 
      
 37 
     | 
    
         
            +
                  m_start_time(0),
         
     | 
| 
      
 38 
     | 
    
         
            +
                  m_stop_time(0),
         
     | 
| 
      
 39 
     | 
    
         
            +
                  m_started(false),
         
     | 
| 
      
 40 
     | 
    
         
            +
                  m_stopped(false)
         
     | 
| 
      
 41 
     | 
    
         
            +
               {
         
     | 
| 
      
 42 
     | 
    
         
            +
                  if (!g_inv_freq) 
         
     | 
| 
      
 43 
     | 
    
         
            +
                     init();
         
     | 
| 
      
 44 
     | 
    
         
            +
               }
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
               lzham_timer::lzham_timer(timer_ticks start_ticks)
         
     | 
| 
      
 47 
     | 
    
         
            +
               {
         
     | 
| 
      
 48 
     | 
    
         
            +
                  if (!g_inv_freq) 
         
     | 
| 
      
 49 
     | 
    
         
            +
                     init();
         
     | 
| 
      
 50 
     | 
    
         
            +
                  
         
     | 
| 
      
 51 
     | 
    
         
            +
                  m_start_time = start_ticks;
         
     | 
| 
      
 52 
     | 
    
         
            +
                  
         
     | 
| 
      
 53 
     | 
    
         
            +
                  m_started = true;
         
     | 
| 
      
 54 
     | 
    
         
            +
                  m_stopped = false;
         
     | 
| 
      
 55 
     | 
    
         
            +
               }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
               void lzham_timer::start(timer_ticks start_ticks)
         
     | 
| 
      
 58 
     | 
    
         
            +
               {
         
     | 
| 
      
 59 
     | 
    
         
            +
                  m_start_time = start_ticks;
         
     | 
| 
      
 60 
     | 
    
         
            +
                  
         
     | 
| 
      
 61 
     | 
    
         
            +
                  m_started = true;
         
     | 
| 
      
 62 
     | 
    
         
            +
                  m_stopped = false;
         
     | 
| 
      
 63 
     | 
    
         
            +
               }
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
               void lzham_timer::start()
         
     | 
| 
      
 66 
     | 
    
         
            +
               {
         
     | 
| 
      
 67 
     | 
    
         
            +
                  query_counter(&m_start_time);
         
     | 
| 
      
 68 
     | 
    
         
            +
                  
         
     | 
| 
      
 69 
     | 
    
         
            +
                  m_started = true;
         
     | 
| 
      
 70 
     | 
    
         
            +
                  m_stopped = false;
         
     | 
| 
      
 71 
     | 
    
         
            +
               }
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
               void lzham_timer::stop()
         
     | 
| 
      
 74 
     | 
    
         
            +
               {
         
     | 
| 
      
 75 
     | 
    
         
            +
                  LZHAM_ASSERT(m_started);
         
     | 
| 
      
 76 
     | 
    
         
            +
                              
         
     | 
| 
      
 77 
     | 
    
         
            +
                  query_counter(&m_stop_time);
         
     | 
| 
      
 78 
     | 
    
         
            +
                  
         
     | 
| 
      
 79 
     | 
    
         
            +
                  m_stopped = true;
         
     | 
| 
      
 80 
     | 
    
         
            +
               }
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
               double lzham_timer::get_elapsed_secs() const
         
     | 
| 
      
 83 
     | 
    
         
            +
               {
         
     | 
| 
      
 84 
     | 
    
         
            +
                  LZHAM_ASSERT(m_started);
         
     | 
| 
      
 85 
     | 
    
         
            +
                  if (!m_started)
         
     | 
| 
      
 86 
     | 
    
         
            +
                     return 0;
         
     | 
| 
      
 87 
     | 
    
         
            +
                  
         
     | 
| 
      
 88 
     | 
    
         
            +
                  timer_ticks stop_time = m_stop_time;
         
     | 
| 
      
 89 
     | 
    
         
            +
                  if (!m_stopped)
         
     | 
| 
      
 90 
     | 
    
         
            +
                     query_counter(&stop_time);
         
     | 
| 
      
 91 
     | 
    
         
            +
                     
         
     | 
| 
      
 92 
     | 
    
         
            +
                  timer_ticks delta = stop_time - m_start_time;
         
     | 
| 
      
 93 
     | 
    
         
            +
                  return delta * g_inv_freq;
         
     | 
| 
      
 94 
     | 
    
         
            +
               }
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
               timer_ticks lzham_timer::get_elapsed_us() const
         
     | 
| 
      
 97 
     | 
    
         
            +
               {
         
     | 
| 
      
 98 
     | 
    
         
            +
                  LZHAM_ASSERT(m_started);
         
     | 
| 
      
 99 
     | 
    
         
            +
                  if (!m_started)
         
     | 
| 
      
 100 
     | 
    
         
            +
                     return 0;
         
     | 
| 
      
 101 
     | 
    
         
            +
                     
         
     | 
| 
      
 102 
     | 
    
         
            +
                  timer_ticks stop_time = m_stop_time;
         
     | 
| 
      
 103 
     | 
    
         
            +
                  if (!m_stopped)
         
     | 
| 
      
 104 
     | 
    
         
            +
                     query_counter(&stop_time);
         
     | 
| 
      
 105 
     | 
    
         
            +
                  
         
     | 
| 
      
 106 
     | 
    
         
            +
                  timer_ticks delta = stop_time - m_start_time;
         
     | 
| 
      
 107 
     | 
    
         
            +
                  return (delta * 1000000ULL + (g_freq >> 1U)) / g_freq;      
         
     | 
| 
      
 108 
     | 
    
         
            +
               }
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
               void lzham_timer::init()
         
     | 
| 
      
 111 
     | 
    
         
            +
               {
         
     | 
| 
      
 112 
     | 
    
         
            +
                  if (!g_inv_freq)
         
     | 
| 
      
 113 
     | 
    
         
            +
                  {
         
     | 
| 
      
 114 
     | 
    
         
            +
                     query_counter_frequency(&g_freq);
         
     | 
| 
      
 115 
     | 
    
         
            +
                     g_inv_freq = 1.0f / g_freq;
         
     | 
| 
      
 116 
     | 
    
         
            +
                     
         
     | 
| 
      
 117 
     | 
    
         
            +
                     query_counter(&g_init_ticks);
         
     | 
| 
      
 118 
     | 
    
         
            +
                  }
         
     | 
| 
      
 119 
     | 
    
         
            +
               }
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
               timer_ticks lzham_timer::get_init_ticks()
         
     | 
| 
      
 122 
     | 
    
         
            +
               {
         
     | 
| 
      
 123 
     | 
    
         
            +
                  if (!g_inv_freq) 
         
     | 
| 
      
 124 
     | 
    
         
            +
                     init();
         
     | 
| 
      
 125 
     | 
    
         
            +
                  
         
     | 
| 
      
 126 
     | 
    
         
            +
                  return g_init_ticks;
         
     | 
| 
      
 127 
     | 
    
         
            +
               }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
               timer_ticks lzham_timer::get_ticks()
         
     | 
| 
      
 130 
     | 
    
         
            +
               {
         
     | 
| 
      
 131 
     | 
    
         
            +
                  if (!g_inv_freq) 
         
     | 
| 
      
 132 
     | 
    
         
            +
                     init();
         
     | 
| 
      
 133 
     | 
    
         
            +
                  
         
     | 
| 
      
 134 
     | 
    
         
            +
                  timer_ticks ticks;
         
     | 
| 
      
 135 
     | 
    
         
            +
                  query_counter(&ticks);
         
     | 
| 
      
 136 
     | 
    
         
            +
                  return ticks - g_init_ticks;
         
     | 
| 
      
 137 
     | 
    
         
            +
               }
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
               double lzham_timer::ticks_to_secs(timer_ticks ticks)
         
     | 
| 
      
 140 
     | 
    
         
            +
               {
         
     | 
| 
      
 141 
     | 
    
         
            +
                  if (!g_inv_freq) 
         
     | 
| 
      
 142 
     | 
    
         
            +
                     init();
         
     | 
| 
      
 143 
     | 
    
         
            +
                  
         
     | 
| 
      
 144 
     | 
    
         
            +
                  return ticks * g_inv_freq;
         
     | 
| 
      
 145 
     | 
    
         
            +
               }
         
     | 
| 
      
 146 
     | 
    
         
            +
               
         
     | 
| 
      
 147 
     | 
    
         
            +
            } // namespace lzham
         
     | 
| 
         @@ -0,0 +1,99 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // File: lzham_timer.h
         
     | 
| 
      
 2 
     | 
    
         
            +
            // See Copyright Notice and license at the end of include/lzham.h
         
     | 
| 
      
 3 
     | 
    
         
            +
            #pragma once
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            namespace lzham
         
     | 
| 
      
 6 
     | 
    
         
            +
            {
         
     | 
| 
      
 7 
     | 
    
         
            +
               typedef unsigned long long timer_ticks;
         
     | 
| 
      
 8 
     | 
    
         
            +
                  
         
     | 
| 
      
 9 
     | 
    
         
            +
               class lzham_timer
         
     | 
| 
      
 10 
     | 
    
         
            +
               {
         
     | 
| 
      
 11 
     | 
    
         
            +
               public:
         
     | 
| 
      
 12 
     | 
    
         
            +
                  lzham_timer();
         
     | 
| 
      
 13 
     | 
    
         
            +
                  lzham_timer(timer_ticks start_ticks);
         
     | 
| 
      
 14 
     | 
    
         
            +
                  
         
     | 
| 
      
 15 
     | 
    
         
            +
                  void start();
         
     | 
| 
      
 16 
     | 
    
         
            +
                  void start(timer_ticks start_ticks);
         
     | 
| 
      
 17 
     | 
    
         
            +
                  
         
     | 
| 
      
 18 
     | 
    
         
            +
                  void stop();
         
     | 
| 
      
 19 
     | 
    
         
            +
                     
         
     | 
| 
      
 20 
     | 
    
         
            +
                  double get_elapsed_secs() const;
         
     | 
| 
      
 21 
     | 
    
         
            +
                  inline double get_elapsed_ms() const { return get_elapsed_secs() * 1000.0f; }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  timer_ticks get_elapsed_us() const;
         
     | 
| 
      
 23 
     | 
    
         
            +
                  
         
     | 
| 
      
 24 
     | 
    
         
            +
                  static void init();
         
     | 
| 
      
 25 
     | 
    
         
            +
                  static inline timer_ticks get_ticks_per_sec() { return g_freq; }
         
     | 
| 
      
 26 
     | 
    
         
            +
                  static timer_ticks get_init_ticks();
         
     | 
| 
      
 27 
     | 
    
         
            +
                  static timer_ticks get_ticks();
         
     | 
| 
      
 28 
     | 
    
         
            +
                  static double ticks_to_secs(timer_ticks ticks);
         
     | 
| 
      
 29 
     | 
    
         
            +
                  static inline double ticks_to_ms(timer_ticks ticks) { return ticks_to_secs(ticks) * 1000.0f; }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  static inline double get_secs() { return ticks_to_secs(get_ticks()); }
         
     | 
| 
      
 31 
     | 
    
         
            +
                  static inline double get_ms() { return ticks_to_ms(get_ticks()); }
         
     | 
| 
      
 32 
     | 
    
         
            +
                               
         
     | 
| 
      
 33 
     | 
    
         
            +
               private:
         
     | 
| 
      
 34 
     | 
    
         
            +
                  static timer_ticks g_init_ticks;
         
     | 
| 
      
 35 
     | 
    
         
            +
                  static timer_ticks g_freq;
         
     | 
| 
      
 36 
     | 
    
         
            +
                  static double g_inv_freq;
         
     | 
| 
      
 37 
     | 
    
         
            +
                  
         
     | 
| 
      
 38 
     | 
    
         
            +
                  timer_ticks m_start_time;
         
     | 
| 
      
 39 
     | 
    
         
            +
                  timer_ticks m_stop_time;
         
     | 
| 
      
 40 
     | 
    
         
            +
                  
         
     | 
| 
      
 41 
     | 
    
         
            +
                  bool m_started : 1;
         
     | 
| 
      
 42 
     | 
    
         
            +
                  bool m_stopped : 1;
         
     | 
| 
      
 43 
     | 
    
         
            +
               };
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
               enum var_args_t { cVarArgs };
         
     | 
| 
      
 46 
     | 
    
         
            +
               
         
     | 
| 
      
 47 
     | 
    
         
            +
            #if LZHAM_PERF_SECTIONS
         
     | 
| 
      
 48 
     | 
    
         
            +
               class scoped_perf_section
         
     | 
| 
      
 49 
     | 
    
         
            +
               {
         
     | 
| 
      
 50 
     | 
    
         
            +
               public:
         
     | 
| 
      
 51 
     | 
    
         
            +
                  inline scoped_perf_section() :
         
     | 
| 
      
 52 
     | 
    
         
            +
                     m_start_ticks(lzham_timer::get_ticks())
         
     | 
| 
      
 53 
     | 
    
         
            +
                  {
         
     | 
| 
      
 54 
     | 
    
         
            +
                     m_name[0] = '?';
         
     | 
| 
      
 55 
     | 
    
         
            +
                     m_name[1] = '\0';
         
     | 
| 
      
 56 
     | 
    
         
            +
                  }
         
     | 
| 
      
 57 
     | 
    
         
            +
                  
         
     | 
| 
      
 58 
     | 
    
         
            +
                  inline scoped_perf_section(const char *pName) :
         
     | 
| 
      
 59 
     | 
    
         
            +
                     m_start_ticks(lzham_timer::get_ticks())
         
     | 
| 
      
 60 
     | 
    
         
            +
                  {
         
     | 
| 
      
 61 
     | 
    
         
            +
                     strcpy_s(m_name, pName);
         
     | 
| 
      
 62 
     | 
    
         
            +
                     
         
     | 
| 
      
 63 
     | 
    
         
            +
                     lzham_buffered_printf("Thread: 0x%08X, BEGIN Time: %3.3fms, Section: %s\n", GetCurrentThreadId(), lzham_timer::ticks_to_ms(m_start_ticks), m_name);
         
     | 
| 
      
 64 
     | 
    
         
            +
                  }
         
     | 
| 
      
 65 
     | 
    
         
            +
                  
         
     | 
| 
      
 66 
     | 
    
         
            +
                  inline scoped_perf_section(var_args_t, const char *pName, ...) :
         
     | 
| 
      
 67 
     | 
    
         
            +
                     m_start_ticks(lzham_timer::get_ticks())
         
     | 
| 
      
 68 
     | 
    
         
            +
                  {
         
     | 
| 
      
 69 
     | 
    
         
            +
                     va_list args;
         
     | 
| 
      
 70 
     | 
    
         
            +
                     va_start(args, pName);
         
     | 
| 
      
 71 
     | 
    
         
            +
                     vsprintf_s(m_name, sizeof(m_name), pName, args);
         
     | 
| 
      
 72 
     | 
    
         
            +
                     va_end(args);
         
     | 
| 
      
 73 
     | 
    
         
            +
                     
         
     | 
| 
      
 74 
     | 
    
         
            +
                     lzham_buffered_printf("Thread: 0x%08X, BEGIN Time: %3.3fms, Section: %s\n", GetCurrentThreadId(), lzham_timer::ticks_to_ms(m_start_ticks), m_name);
         
     | 
| 
      
 75 
     | 
    
         
            +
                  }
         
     | 
| 
      
 76 
     | 
    
         
            +
               
         
     | 
| 
      
 77 
     | 
    
         
            +
                  inline ~scoped_perf_section()
         
     | 
| 
      
 78 
     | 
    
         
            +
                  {
         
     | 
| 
      
 79 
     | 
    
         
            +
                     double end_ms = lzham_timer::get_ms();
         
     | 
| 
      
 80 
     | 
    
         
            +
                     double start_ms = lzham_timer::ticks_to_ms(m_start_ticks);
         
     | 
| 
      
 81 
     | 
    
         
            +
                     
         
     | 
| 
      
 82 
     | 
    
         
            +
                     lzham_buffered_printf("Thread: 0x%08X, END Time: %3.3fms, Total: %3.3fms, Section: %s\n", GetCurrentThreadId(), end_ms, end_ms - start_ms, m_name);
         
     | 
| 
      
 83 
     | 
    
         
            +
                  }
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
               private:
         
     | 
| 
      
 86 
     | 
    
         
            +
                  char m_name[64];   
         
     | 
| 
      
 87 
     | 
    
         
            +
                  timer_ticks m_start_ticks;
         
     | 
| 
      
 88 
     | 
    
         
            +
               };
         
     | 
| 
      
 89 
     | 
    
         
            +
            #else
         
     | 
| 
      
 90 
     | 
    
         
            +
               class scoped_perf_section
         
     | 
| 
      
 91 
     | 
    
         
            +
               {
         
     | 
| 
      
 92 
     | 
    
         
            +
               public:
         
     | 
| 
      
 93 
     | 
    
         
            +
                  inline scoped_perf_section() { }
         
     | 
| 
      
 94 
     | 
    
         
            +
                  inline scoped_perf_section(const char *pName) { (void)pName; }
         
     | 
| 
      
 95 
     | 
    
         
            +
                  inline scoped_perf_section(var_args_t, const char *pName, ...) { (void)pName; }
         
     | 
| 
      
 96 
     | 
    
         
            +
               };
         
     | 
| 
      
 97 
     | 
    
         
            +
            #endif // LZHAM_PERF_SECTIONS   
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            } // namespace lzham
         
     | 
| 
         @@ -0,0 +1,141 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // File: lzham_traits.h
         
     | 
| 
      
 2 
     | 
    
         
            +
            // See Copyright Notice and license at the end of include/lzham.h
         
     | 
| 
      
 3 
     | 
    
         
            +
            #pragma once
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            namespace lzham
         
     | 
| 
      
 6 
     | 
    
         
            +
            {
         
     | 
| 
      
 7 
     | 
    
         
            +
               template<typename T>
         
     | 
| 
      
 8 
     | 
    
         
            +
               struct scalar_type
         
     | 
| 
      
 9 
     | 
    
         
            +
               {
         
     | 
| 
      
 10 
     | 
    
         
            +
                  enum { cFlag = false };
         
     | 
| 
      
 11 
     | 
    
         
            +
                  static inline void construct(T* p) { helpers::construct(p); }
         
     | 
| 
      
 12 
     | 
    
         
            +
                  static inline void construct(T* p, const T& init) { helpers::construct(p, init); }
         
     | 
| 
      
 13 
     | 
    
         
            +
                  static inline void construct_array(T* p, uint n) { helpers::construct_array(p, n); }
         
     | 
| 
      
 14 
     | 
    
         
            +
                  static inline void destruct(T* p) { helpers::destruct(p); }
         
     | 
| 
      
 15 
     | 
    
         
            +
                  static inline void destruct_array(T* p, uint n) { helpers::destruct_array(p, n); }
         
     | 
| 
      
 16 
     | 
    
         
            +
               };
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
               template<typename T> struct scalar_type<T*>
         
     | 
| 
      
 19 
     | 
    
         
            +
               {
         
     | 
| 
      
 20 
     | 
    
         
            +
                  enum { cFlag = true };
         
     | 
| 
      
 21 
     | 
    
         
            +
                  static inline void construct(T** p) { memset(p, 0, sizeof(T*)); }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  static inline void construct(T** p, T* init) { *p = init; }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  static inline void construct_array(T** p, uint n) { memset(p, 0, sizeof(T*) * n); }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  static inline void destruct(T** p) { LZHAM_NOTE_UNUSED(p); }
         
     | 
| 
      
 25 
     | 
    
         
            +
                  static inline void destruct_array(T** p, uint n) { LZHAM_NOTE_UNUSED(p); LZHAM_NOTE_UNUSED(n); }
         
     | 
| 
      
 26 
     | 
    
         
            +
               };
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            #define LZHAM_DEFINE_BUILT_IN_TYPE(X) \
         
     | 
| 
      
 29 
     | 
    
         
            +
               template<> struct scalar_type<X> { \
         
     | 
| 
      
 30 
     | 
    
         
            +
               enum { cFlag = true }; \
         
     | 
| 
      
 31 
     | 
    
         
            +
               static inline void construct(X* p) { memset(p, 0, sizeof(X)); } \
         
     | 
| 
      
 32 
     | 
    
         
            +
               static inline void construct(X* p, const X& init) { memcpy(p, &init, sizeof(X)); } \
         
     | 
| 
      
 33 
     | 
    
         
            +
               static inline void construct_array(X* p, uint n) { memset(p, 0, sizeof(X) * n); } \
         
     | 
| 
      
 34 
     | 
    
         
            +
               static inline void destruct(X* p) { LZHAM_NOTE_UNUSED(p); } \
         
     | 
| 
      
 35 
     | 
    
         
            +
               static inline void destruct_array(X* p, uint n) { LZHAM_NOTE_UNUSED(p); LZHAM_NOTE_UNUSED(n); } };
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(bool)
         
     | 
| 
      
 38 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(char)
         
     | 
| 
      
 39 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(unsigned char)
         
     | 
| 
      
 40 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(short)
         
     | 
| 
      
 41 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(unsigned short)
         
     | 
| 
      
 42 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(int)
         
     | 
| 
      
 43 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(unsigned int)
         
     | 
| 
      
 44 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(long)
         
     | 
| 
      
 45 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(unsigned long)
         
     | 
| 
      
 46 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(float)
         
     | 
| 
      
 47 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(double)
         
     | 
| 
      
 48 
     | 
    
         
            +
               LZHAM_DEFINE_BUILT_IN_TYPE(long double)
         
     | 
| 
      
 49 
     | 
    
         
            +
               #if defined(WIN32)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  LZHAM_DEFINE_BUILT_IN_TYPE(__int64)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  LZHAM_DEFINE_BUILT_IN_TYPE(unsigned __int64)
         
     | 
| 
      
 52 
     | 
    
         
            +
               #endif
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            #undef LZHAM_DEFINE_BUILT_IN_TYPE
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            // See: http://erdani.org/publications/cuj-2004-06.pdf
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
               template<typename T>
         
     | 
| 
      
 59 
     | 
    
         
            +
               struct bitwise_movable { enum { cFlag = false }; };
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            // Defines type Q as bitwise movable.
         
     | 
| 
      
 62 
     | 
    
         
            +
            #define LZHAM_DEFINE_BITWISE_MOVABLE(Q) template<> struct bitwise_movable<Q> { enum { cFlag = true }; };
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
               template<typename T>
         
     | 
| 
      
 65 
     | 
    
         
            +
               struct bitwise_copyable { enum { cFlag = false }; };
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
               // Defines type Q as bitwise copyable.
         
     | 
| 
      
 68 
     | 
    
         
            +
            #define LZHAM_DEFINE_BITWISE_COPYABLE(Q) template<> struct bitwise_copyable<Q> { enum { cFlag = true }; };
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            #if defined(__APPLE__) || defined(__NetBSD__)
         
     | 
| 
      
 71 
     | 
    
         
            +
               #define LZHAM_IS_POD(T) std::__is_pod<T>::__value
         
     | 
| 
      
 72 
     | 
    
         
            +
            #else
         
     | 
| 
      
 73 
     | 
    
         
            +
               #define LZHAM_IS_POD(T) __is_pod(T)
         
     | 
| 
      
 74 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            #define LZHAM_IS_SCALAR_TYPE(T) (scalar_type<T>::cFlag)
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            #define LZHAM_IS_BITWISE_COPYABLE(T) ((scalar_type<T>::cFlag) || (bitwise_copyable<T>::cFlag) || LZHAM_IS_POD(T))
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            #define LZHAM_IS_BITWISE_MOVABLE(T) (LZHAM_IS_BITWISE_COPYABLE(T) || (bitwise_movable<T>::cFlag))
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            #define LZHAM_HAS_DESTRUCTOR(T) ((!scalar_type<T>::cFlag) && (!LZHAM_IS_POD(T)))
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
               // From yasli_traits.h:
         
     | 
| 
      
 85 
     | 
    
         
            +
               // Credit goes to Boost;
         
     | 
| 
      
 86 
     | 
    
         
            +
               // also found in the C++ Templates book by Vandevoorde and Josuttis
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
               typedef char (&yes_t)[1];
         
     | 
| 
      
 89 
     | 
    
         
            +
               typedef char (&no_t)[2];
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
               template <class U> yes_t class_test(int U::*);
         
     | 
| 
      
 92 
     | 
    
         
            +
               template <class U> no_t class_test(...);
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
               template <class T> struct is_class
         
     | 
| 
      
 95 
     | 
    
         
            +
               {
         
     | 
| 
      
 96 
     | 
    
         
            +
                  enum { value = (sizeof(class_test<T>(0)) == sizeof(yes_t)) };
         
     | 
| 
      
 97 
     | 
    
         
            +
               };
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
               template <typename T> struct is_pointer
         
     | 
| 
      
 100 
     | 
    
         
            +
               {
         
     | 
| 
      
 101 
     | 
    
         
            +
                  enum { value = false };
         
     | 
| 
      
 102 
     | 
    
         
            +
               };
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
               template <typename T> struct is_pointer<T*>
         
     | 
| 
      
 105 
     | 
    
         
            +
               {
         
     | 
| 
      
 106 
     | 
    
         
            +
                  enum { value = true };
         
     | 
| 
      
 107 
     | 
    
         
            +
               };
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
               LZHAM_DEFINE_BITWISE_COPYABLE(empty_type);
         
     | 
| 
      
 110 
     | 
    
         
            +
               LZHAM_DEFINE_BITWISE_MOVABLE(empty_type);
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
               namespace helpers
         
     | 
| 
      
 113 
     | 
    
         
            +
               {
         
     | 
| 
      
 114 
     | 
    
         
            +
                  template <typename T>
         
     | 
| 
      
 115 
     | 
    
         
            +
                  inline void construct_array(T* p, uint n)
         
     | 
| 
      
 116 
     | 
    
         
            +
                  {
         
     | 
| 
      
 117 
     | 
    
         
            +
                     if (LZHAM_IS_SCALAR_TYPE(T))
         
     | 
| 
      
 118 
     | 
    
         
            +
                     {
         
     | 
| 
      
 119 
     | 
    
         
            +
                        memset(p, 0, sizeof(T) * n);
         
     | 
| 
      
 120 
     | 
    
         
            +
                     }
         
     | 
| 
      
 121 
     | 
    
         
            +
                     else
         
     | 
| 
      
 122 
     | 
    
         
            +
                     {
         
     | 
| 
      
 123 
     | 
    
         
            +
                        T* q = p + n;
         
     | 
| 
      
 124 
     | 
    
         
            +
                        for ( ; p != q; ++p)
         
     | 
| 
      
 125 
     | 
    
         
            +
                           new (static_cast<void*>(p)) T;
         
     | 
| 
      
 126 
     | 
    
         
            +
                     }
         
     | 
| 
      
 127 
     | 
    
         
            +
                  }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  template <typename T>
         
     | 
| 
      
 130 
     | 
    
         
            +
                  inline void destruct_array(T* p, uint n)
         
     | 
| 
      
 131 
     | 
    
         
            +
                  {
         
     | 
| 
      
 132 
     | 
    
         
            +
                     if ( LZHAM_HAS_DESTRUCTOR(T) )
         
     | 
| 
      
 133 
     | 
    
         
            +
                     {
         
     | 
| 
      
 134 
     | 
    
         
            +
                        T* q = p + n;
         
     | 
| 
      
 135 
     | 
    
         
            +
                        for ( ; p != q; ++p)
         
     | 
| 
      
 136 
     | 
    
         
            +
                           p->~T();
         
     | 
| 
      
 137 
     | 
    
         
            +
                     }
         
     | 
| 
      
 138 
     | 
    
         
            +
                  }
         
     | 
| 
      
 139 
     | 
    
         
            +
               }
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
            } // namespace lzham
         
     | 
| 
         @@ -0,0 +1,97 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // File: types.h
         
     | 
| 
      
 2 
     | 
    
         
            +
            // See Copyright Notice and license at the end of include/lzham.h
         
     | 
| 
      
 3 
     | 
    
         
            +
            #pragma once
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            // TODO
         
     | 
| 
      
 6 
     | 
    
         
            +
            #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
         
     | 
| 
      
 7 
     | 
    
         
            +
               #undef INT8_MIN
         
     | 
| 
      
 8 
     | 
    
         
            +
               #undef INT8_MAX
         
     | 
| 
      
 9 
     | 
    
         
            +
               #undef UINT8_MIN
         
     | 
| 
      
 10 
     | 
    
         
            +
               #undef UINT8_MAX
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
               #undef INT16_MIN
         
     | 
| 
      
 13 
     | 
    
         
            +
               #undef INT16_MAX
         
     | 
| 
      
 14 
     | 
    
         
            +
               #undef UINT16_MIN
         
     | 
| 
      
 15 
     | 
    
         
            +
               #undef UINT16_MAX
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
               #undef INT32_MIN
         
     | 
| 
      
 18 
     | 
    
         
            +
               #undef INT32_MAX
         
     | 
| 
      
 19 
     | 
    
         
            +
               #undef UINT32_MIN
         
     | 
| 
      
 20 
     | 
    
         
            +
               #undef UINT32_MAX
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
               #undef INT64_MIN
         
     | 
| 
      
 23 
     | 
    
         
            +
               #undef INT64_MAX
         
     | 
| 
      
 24 
     | 
    
         
            +
               #undef UINT64_MIN
         
     | 
| 
      
 25 
     | 
    
         
            +
               #undef UINT64_MAX
         
     | 
| 
      
 26 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            namespace lzham
         
     | 
| 
      
 29 
     | 
    
         
            +
            {
         
     | 
| 
      
 30 
     | 
    
         
            +
               typedef unsigned char      uint8;
         
     | 
| 
      
 31 
     | 
    
         
            +
               typedef signed char        int8;
         
     | 
| 
      
 32 
     | 
    
         
            +
               typedef unsigned char      uint8;
         
     | 
| 
      
 33 
     | 
    
         
            +
               typedef unsigned short     uint16;
         
     | 
| 
      
 34 
     | 
    
         
            +
               typedef signed short       int16;
         
     | 
| 
      
 35 
     | 
    
         
            +
               typedef unsigned int       uint32;
         
     | 
| 
      
 36 
     | 
    
         
            +
               typedef uint32             uint;
         
     | 
| 
      
 37 
     | 
    
         
            +
               typedef signed int         int32;
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
               #ifdef _MSC_VER
         
     | 
| 
      
 40 
     | 
    
         
            +
                  typedef unsigned __int64      uint64;
         
     | 
| 
      
 41 
     | 
    
         
            +
                  typedef signed __int64        int64;
         
     | 
| 
      
 42 
     | 
    
         
            +
               #else
         
     | 
| 
      
 43 
     | 
    
         
            +
                  typedef unsigned long long    uint64;
         
     | 
| 
      
 44 
     | 
    
         
            +
                  typedef long long             int64;
         
     | 
| 
      
 45 
     | 
    
         
            +
               #endif
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
               const uint8  UINT8_MIN  = 0;
         
     | 
| 
      
 48 
     | 
    
         
            +
               const uint8  UINT8_MAX  = 0xFFU;
         
     | 
| 
      
 49 
     | 
    
         
            +
               const uint16 UINT16_MIN = 0;
         
     | 
| 
      
 50 
     | 
    
         
            +
               const uint16 UINT16_MAX = 0xFFFFU;
         
     | 
| 
      
 51 
     | 
    
         
            +
               const uint32 UINT32_MIN = 0;
         
     | 
| 
      
 52 
     | 
    
         
            +
               const uint32 UINT32_MAX = 0xFFFFFFFFU;
         
     | 
| 
      
 53 
     | 
    
         
            +
               const uint64 UINT64_MIN = 0;
         
     | 
| 
      
 54 
     | 
    
         
            +
               const uint64 UINT64_MAX = 0xFFFFFFFFFFFFFFFFULL;    //0xFFFFFFFFFFFFFFFFui64;
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
               const int8  INT8_MIN  = -128;
         
     | 
| 
      
 57 
     | 
    
         
            +
               const int8  INT8_MAX  = 127;
         
     | 
| 
      
 58 
     | 
    
         
            +
               const int16 INT16_MIN = -32768;
         
     | 
| 
      
 59 
     | 
    
         
            +
               const int16 INT16_MAX = 32767;
         
     | 
| 
      
 60 
     | 
    
         
            +
               const int32 INT32_MIN = (-2147483647 - 1);
         
     | 
| 
      
 61 
     | 
    
         
            +
               const int32 INT32_MAX = 2147483647;
         
     | 
| 
      
 62 
     | 
    
         
            +
               const int64 INT64_MIN = (int64)0x8000000000000000ULL; //(-9223372036854775807i64 - 1);
         
     | 
| 
      
 63 
     | 
    
         
            +
               const int64 INT64_MAX = (int64)0x7FFFFFFFFFFFFFFFULL; //9223372036854775807i64;
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            #if LZHAM_64BIT_POINTERS
         
     | 
| 
      
 66 
     | 
    
         
            +
               typedef uint64 uint_ptr;
         
     | 
| 
      
 67 
     | 
    
         
            +
               typedef uint64 uint32_ptr;
         
     | 
| 
      
 68 
     | 
    
         
            +
               typedef int64 signed_size_t;
         
     | 
| 
      
 69 
     | 
    
         
            +
               typedef uint64 ptr_bits_t;
         
     | 
| 
      
 70 
     | 
    
         
            +
               const ptr_bits_t PTR_BITS_XOR = 0xDB0DD4415C87DCF7ULL;
         
     | 
| 
      
 71 
     | 
    
         
            +
            #else
         
     | 
| 
      
 72 
     | 
    
         
            +
               typedef unsigned int uint_ptr;
         
     | 
| 
      
 73 
     | 
    
         
            +
               typedef unsigned int uint32_ptr;
         
     | 
| 
      
 74 
     | 
    
         
            +
               typedef signed int signed_size_t;
         
     | 
| 
      
 75 
     | 
    
         
            +
               typedef uint32 ptr_bits_t;
         
     | 
| 
      
 76 
     | 
    
         
            +
               const ptr_bits_t PTR_BITS_XOR = 0x5C87DCF7UL;
         
     | 
| 
      
 77 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 78 
     | 
    
         
            +
               
         
     | 
| 
      
 79 
     | 
    
         
            +
               enum
         
     | 
| 
      
 80 
     | 
    
         
            +
               {
         
     | 
| 
      
 81 
     | 
    
         
            +
                  cInvalidIndex = -1
         
     | 
| 
      
 82 
     | 
    
         
            +
               };
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
               const uint cIntBits = sizeof(uint) * CHAR_BIT;
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
               template<typename T> struct int_traits { enum { cMin = INT_MIN, cMax = INT_MAX, cSigned = true }; };
         
     | 
| 
      
 87 
     | 
    
         
            +
               template<> struct int_traits<int8> { enum { cMin = INT8_MIN, cMax = INT8_MAX, cSigned = true }; };
         
     | 
| 
      
 88 
     | 
    
         
            +
               template<> struct int_traits<int16> { enum { cMin = INT16_MIN, cMax = INT16_MAX, cSigned = true }; };
         
     | 
| 
      
 89 
     | 
    
         
            +
               template<> struct int_traits<int32> { enum { cMin = INT32_MIN, cMax = INT32_MAX, cSigned = true }; };
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
               template<> struct int_traits<uint> { enum { cMin = 0, cMax = UINT_MAX, cSigned = false }; };
         
     | 
| 
      
 92 
     | 
    
         
            +
               template<> struct int_traits<uint8> { enum { cMin = 0, cMax = UINT8_MAX, cSigned = false }; };
         
     | 
| 
      
 93 
     | 
    
         
            +
               template<> struct int_traits<uint16> { enum { cMin = 0, cMax = UINT16_MAX, cSigned = false }; };
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
               struct empty_type { };
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
            } // namespace lzham
         
     |