digest-xxhash 0.1.0 → 0.2.2

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.
@@ -1,2 +1,22 @@
1
1
  require 'mkmf'
2
+
3
+ $defs.push('-Wall') if enable_config('all-warnings')
4
+ $defs.push('-ggdb3') if enable_config('gdb-info')
5
+ $CFLAGS << ' -O0' if enable_config('no-opt')
6
+
2
7
  create_makefile('digest/xxhash')
8
+
9
+ if enable_config('verbose-mode')
10
+ # This also needs Gem.configuration.really_verbose enabled to work
11
+ # with `gem install`. The value of Gem.configuration.verbose should
12
+ # be set to anything other than true, false, or nil to enable it.
13
+ # See source code of Gem::ConfigFile class for location of gemrc
14
+ # files and other details.
15
+ #
16
+ # Following is an example configuration in /etc/gemrc.
17
+ # Key needs to be in symbol form.
18
+ #
19
+ # :verbose: "really_verbose"
20
+ #
21
+ File.write('Makefile', "\nV = 1\n", mode: 'a')
22
+ end
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include <string.h>
12
12
 
13
+ #if 0
13
14
  /*
14
15
  * Checks if system uses little endian.
15
16
  *
@@ -21,7 +22,9 @@ static int is_little_endian()
21
22
  const unsigned num = 0xABCD;
22
23
  return *((unsigned char *) &num) == 0xCD;
23
24
  }
25
+ #endif
24
26
 
27
+ #if 0
25
28
  /*
26
29
  * Swaps bytes to transform numbers from little endian mode to big endian mode
27
30
  * or vice versa.
@@ -40,7 +43,9 @@ static uint64_t swap_uint64(uint64_t val)
40
43
  val = ((val << 16) & 0xFFFF0000FFFF0000ULL ) | ((val >> 16) & 0x0000FFFF0000FFFFULL );
41
44
  return (val << 32) | (val >> 32);
42
45
  }
46
+ #endif
43
47
 
48
+ #if 0
44
49
  /*
45
50
  * Reads primitive numerical data from an address which can be aligned or not.
46
51
  *
@@ -59,6 +64,7 @@ static uint64_t read64(const void *ptr)
59
64
  memcpy(&value, ptr, sizeof(uint64_t));
60
65
  return value;
61
66
  }
67
+ #endif
62
68
 
63
69
  /*
64
70
  * A simplified hex encoder based on Yannuth's answer in StackOverflow
@@ -69,9 +75,10 @@ static uint64_t read64(const void *ptr)
69
75
  static void hex_encode_str_implied(const unsigned char *src, size_t len, unsigned char *dest)
70
76
  {
71
77
  static const unsigned char table[] = "0123456789abcdef";
78
+ unsigned char c;
72
79
 
73
80
  for (; len > 0; --len) {
74
- unsigned char c = *src++;
81
+ c = *src++;
75
82
  *dest++ = table[c >> 4];
76
83
  *dest++ = table[c & 0x0f];
77
84
  }
@@ -86,8 +93,10 @@ static void hex_encode_str_implied(const unsigned char *src, size_t len, unsigne
86
93
  */
87
94
  static int hex_decode_str_implied(const unsigned char *src, size_t len, unsigned char *dest)
88
95
  {
96
+ unsigned char low, high;
97
+
89
98
  if (len % 2) {
90
- unsigned char low = *src++;
99
+ low = *src++;
91
100
 
92
101
  if (low >= '0' && low <= '9') {
93
102
  low -= '0';
@@ -104,7 +113,7 @@ static int hex_decode_str_implied(const unsigned char *src, size_t len, unsigned
104
113
  }
105
114
 
106
115
  for (; len > 0; len -= 2) {
107
- unsigned char high = *src++;
116
+ high = *src++;
108
117
 
109
118
  if (high >= '0' && high <= '9') {
110
119
  high -= '0';
@@ -116,7 +125,7 @@ static int hex_decode_str_implied(const unsigned char *src, size_t len, unsigned
116
125
  return 0;
117
126
  }
118
127
 
119
- unsigned char low = *src++;
128
+ low = *src++;
120
129
 
121
130
  if (low >= '0' && low <= '9') {
122
131
  low -= '0';
@@ -134,6 +143,7 @@ static int hex_decode_str_implied(const unsigned char *src, size_t len, unsigned
134
143
  return -1;
135
144
  }
136
145
 
146
+ #if 0
137
147
  /*
138
148
  * Calculates length of string that would store decoded hex.
139
149
  */
@@ -147,5 +157,6 @@ static size_t calc_hex_decoded_str_length(size_t hex_encoded_length)
147
157
 
148
158
  return hex_encoded_length / 2;
149
159
  }
160
+ #endif
150
161
 
151
162
  #endif