msgpack 0.5.1-x86-mingw32 → 0.5.2-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.
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 2012-02-07 version 0.5.2:
3
+
4
+ * Fixed invalid pack/unpack on 32bit architecture such as Win32
5
+ * Disable rmem on Rubinius because rmem is not thread safe
6
+
7
+
2
8
  2012-12-23 version 0.5.1:
3
9
 
4
10
  * Fixed compile error with Rubinius 2.0.0-dev
@@ -611,13 +611,13 @@ size_t msgpack_buffer_flush_to_io(msgpack_buffer_t* b, VALUE io, ID write_method
611
611
  size_t _msgpack_buffer_feed_from_io(msgpack_buffer_t* b)
612
612
  {
613
613
  if(b->io_buffer == Qnil) {
614
- b->io_buffer = rb_funcall(b->io, b->io_partial_read_method, 1, LONG2FIX(b->io_buffer_size));
614
+ b->io_buffer = rb_funcall(b->io, b->io_partial_read_method, 1, LONG2NUM(b->io_buffer_size));
615
615
  if(b->io_buffer == Qnil) {
616
616
  rb_raise(rb_eEOFError, "IO reached end of file");
617
617
  }
618
618
  StringValue(b->io_buffer);
619
619
  } else {
620
- VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2FIX(b->io_buffer_size), b->io_buffer);
620
+ VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2NUM(b->io_buffer_size), b->io_buffer);
621
621
  if(ret == Qnil) {
622
622
  rb_raise(rb_eEOFError, "IO reached end of file");
623
623
  }
@@ -638,7 +638,7 @@ size_t _msgpack_buffer_read_from_io_to_string(msgpack_buffer_t* b, VALUE string,
638
638
  {
639
639
  if(RSTRING_LEN(string) == 0) {
640
640
  /* direct read */
641
- VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2FIX(length), string);
641
+ VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2NUM(length), string);
642
642
  if(ret == Qnil) {
643
643
  return 0;
644
644
  }
@@ -650,7 +650,7 @@ size_t _msgpack_buffer_read_from_io_to_string(msgpack_buffer_t* b, VALUE string,
650
650
  b->io_buffer = rb_str_buf_new(0);
651
651
  }
652
652
 
653
- VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2FIX(length), b->io_buffer);
653
+ VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2NUM(length), b->io_buffer);
654
654
  if(ret == Qnil) {
655
655
  return 0;
656
656
  }
@@ -666,7 +666,7 @@ size_t _msgpack_buffer_skip_from_io(msgpack_buffer_t* b, size_t length)
666
666
  b->io_buffer = rb_str_buf_new(0);
667
667
  }
668
668
 
669
- VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2FIX(length), b->io_buffer);
669
+ VALUE ret = rb_funcall(b->io, b->io_partial_read_method, 2, LONG2NUM(length), b->io_buffer);
670
670
  if(ret == Qnil) {
671
671
  return 0;
672
672
  }
@@ -92,9 +92,11 @@ struct msgpack_buffer_t {
92
92
  msgpack_buffer_chunk_t* head;
93
93
  msgpack_buffer_chunk_t* free_list;
94
94
 
95
+ #ifndef DISABLE_RMEM
95
96
  char* rmem_last;
96
97
  char* rmem_end;
97
98
  void** rmem_owner;
99
+ #endif
98
100
 
99
101
  union msgpack_buffer_cast_block_t cast_block;
100
102
 
@@ -10,6 +10,13 @@ $CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
10
10
  #$CFLAGS << %[ -DDISABLE_BUFFER_READ_REFERENCE_OPTIMIZE]
11
11
  #$CFLAGS << %[ -DDISABLE_BUFFER_READ_TO_S_OPTIMIZE]
12
12
 
13
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
+ # msgpack-ruby doesn't modify data came from RSTRING_PTR(str)
15
+ $CFLAGS << %[ -DRSTRING_NOT_MODIFIED]
16
+ # Rubinius C extensions don't grab GVL while rmem is not thread safe
17
+ $CFLAGS << %[ -DDISABLE_RMEM]
18
+ end
19
+
13
20
  if warnflags = CONFIG['warnflags']
14
21
  warnflags.slice!(/ -Wdeclaration-after-statement/)
15
22
  end
@@ -73,9 +73,9 @@ void msgpack_packer_reset(msgpack_packer_t* pk)
73
73
 
74
74
  void msgpack_packer_write_array_value(msgpack_packer_t* pk, VALUE v)
75
75
  {
76
- size_t len = RARRAY_LEN(v);
76
+ /* actual return type of RARRAY_LEN is long */
77
+ unsigned long len = RARRAY_LEN(v);
77
78
  if(len > 0xffffffffUL) {
78
- // TODO rb_eArgError?
79
79
  rb_raise(rb_eArgError, "size of array is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
80
80
  }
81
81
  unsigned int len32 = (unsigned int)len;
@@ -101,10 +101,11 @@ static int write_hash_foreach(VALUE key, VALUE value, VALUE pk_value)
101
101
 
102
102
  void msgpack_packer_write_hash_value(msgpack_packer_t* pk, VALUE v)
103
103
  {
104
- size_t len = RHASH_SIZE(v);
104
+ /* actual return type of RHASH_SIZE is long (if SIZEOF_LONG == SIZEOF_VOIDP
105
+ * or long long (if SIZEOF_LONG_LONG == SIZEOF_VOIDP. See st.h. */
106
+ unsigned long len = RHASH_SIZE(v);
105
107
  if(len > 0xffffffffUL) {
106
- // TODO rb_eArgError?
107
- rb_raise(rb_eArgError, "size of array is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
108
+ rb_raise(rb_eArgError, "size of array is too long to pack: %ld bytes should be <= %lu", len, 0xffffffffUL);
108
109
  }
109
110
  unsigned int len32 = (unsigned int)len;
110
111
  msgpack_packer_write_map_header(pk, len32);
@@ -145,33 +145,56 @@ static inline void _msgpack_packer_write_int64(msgpack_packer_t* pk, int64_t v)
145
145
  msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xd3, (const void*)&be, 8);
146
146
  }
147
147
 
148
- static inline void msgpack_packer_write_long(msgpack_packer_t* pk, long v)
148
+ static inline void _msgpack_packer_write_long32(msgpack_packer_t* pk, long v)
149
149
  {
150
150
  if(v < -0x20L) {
151
151
  if(v < -0x8000L) {
152
- if(v < -0x80000000L) {
152
+ _msgpack_packer_write_int32(pk, (int32_t) v);
153
+ } else if(v < -0x80L) {
154
+ _msgpack_packer_write_int16(pk, (int16_t) v);
155
+ } else {
156
+ _msgpack_packer_write_int8(pk, (int8_t) v);
157
+ }
158
+ } else if(v <= 0x7fL) {
159
+ _msgpack_packer_write_fixint(pk, (int8_t) v);
160
+ } else {
161
+ if(v <= 0xffL) {
162
+ _msgpack_packer_write_uint8(pk, (uint8_t) v);
163
+ } else if(v <= 0xffffL) {
164
+ _msgpack_packer_write_uint16(pk, (uint16_t) v);
165
+ } else {
166
+ _msgpack_packer_write_uint32(pk, (uint32_t) v);
167
+ }
168
+ }
169
+ }
170
+
171
+ static inline void _msgpack_packer_write_long_long64(msgpack_packer_t* pk, long long v)
172
+ {
173
+ if(v < -0x20LL) {
174
+ if(v < -0x8000LL) {
175
+ if(v < -0x80000000LL) {
153
176
  _msgpack_packer_write_int64(pk, (int64_t) v);
154
177
  } else {
155
178
  _msgpack_packer_write_int32(pk, (int32_t) v);
156
179
  }
157
180
  } else {
158
- if(v < -0x80L) {
181
+ if(v < -0x80LL) {
159
182
  _msgpack_packer_write_int16(pk, (int16_t) v);
160
183
  } else {
161
184
  _msgpack_packer_write_int8(pk, (int8_t) v);
162
185
  }
163
186
  }
164
- } else if(v <= 0x7fL) {
187
+ } else if(v <= 0x7fLL) {
165
188
  _msgpack_packer_write_fixint(pk, (int8_t) v);
166
189
  } else {
167
- if(v <= 0xffffL) {
168
- if(v <= 0xffL) {
190
+ if(v <= 0xffffLL) {
191
+ if(v <= 0xffLL) {
169
192
  _msgpack_packer_write_uint8(pk, (uint8_t) v);
170
193
  } else {
171
194
  _msgpack_packer_write_uint16(pk, (uint16_t) v);
172
195
  }
173
196
  } else {
174
- if(v <= 0xffffffffL) {
197
+ if(v <= 0xffffffffLL) {
175
198
  _msgpack_packer_write_uint32(pk, (uint32_t) v);
176
199
  } else {
177
200
  _msgpack_packer_write_uint64(pk, (uint64_t) v);
@@ -180,6 +203,37 @@ static inline void msgpack_packer_write_long(msgpack_packer_t* pk, long v)
180
203
  }
181
204
  }
182
205
 
206
+ static inline void msgpack_packer_write_long(msgpack_packer_t* pk, long v)
207
+ {
208
+ #if defined(SIZEOF_LONG)
209
+ # if SIZEOF_LONG <= 4
210
+ _msgpack_packer_write_long32(pk, v);
211
+ # else
212
+ _msgpack_packer_write_long_long64(pk, v);
213
+ # endif
214
+
215
+ #elif defined(LONG_MAX)
216
+ # if LONG_MAX <= 0x7fffffffL
217
+ _msgpack_packer_write_long32(pk, v);
218
+ # else
219
+ _msgpack_packer_write_long_long64(pk, v);
220
+ # endif
221
+
222
+ #else
223
+ if(sizeof(long) <= 4) {
224
+ _msgpack_packer_write_long32(pk, v);
225
+ } else {
226
+ _msgpack_packer_write_long_long64(pk, v);
227
+ }
228
+ #endif
229
+ }
230
+
231
+ static inline void msgpack_packer_write_long_long(msgpack_packer_t* pk, long long v)
232
+ {
233
+ /* assuming sizeof(long long) == 8 */
234
+ _msgpack_packer_write_long_long64(pk, v);
235
+ }
236
+
183
237
  static inline void msgpack_packer_write_u64(msgpack_packer_t* pk, uint64_t v)
184
238
  {
185
239
  if(v <= 0xffULL) {
@@ -268,7 +322,8 @@ void _msgpack_packer_write_string_to_io(msgpack_packer_t* pk, VALUE string);
268
322
  static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE v)
269
323
  {
270
324
  /* TODO encoding conversion? */
271
- size_t len = RSTRING_LEN(v);
325
+ /* actual return type of RSTRING_LEN is long */
326
+ unsigned long len = RSTRING_LEN(v);
272
327
  if(len > 0xffffffffUL) {
273
328
  // TODO rb_eArgError?
274
329
  rb_raise(rb_eArgError, "size of string is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
@@ -280,7 +335,8 @@ static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE
280
335
  static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE v)
281
336
  {
282
337
  const char* name = rb_id2name(SYM2ID(v));
283
- size_t len = strlen(name);
338
+ /* actual return type of strlen is size_t */
339
+ unsigned long len = strlen(name);
284
340
  if(len > 0xffffffffUL) {
285
341
  // TODO rb_eArgError?
286
342
  rb_raise(rb_eArgError, "size of symbol is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
@@ -303,7 +359,7 @@ static inline void msgpack_packer_write_bignum_value(msgpack_packer_t* pk, VALUE
303
359
  if(RBIGNUM_POSITIVE_P(v)) {
304
360
  msgpack_packer_write_u64(pk, rb_big2ull(v));
305
361
  } else {
306
- msgpack_packer_write_long(pk, rb_big2ll(v)); /* TODO long long? */
362
+ msgpack_packer_write_long_long(pk, rb_big2ll(v));
307
363
  }
308
364
  }
309
365
 
@@ -251,10 +251,10 @@ static int read_primitive(msgpack_unpacker_t* uk)
251
251
 
252
252
  SWITCH_RANGE_BEGIN(b)
253
253
  SWITCH_RANGE(b, 0x00, 0x7f) // Positive Fixnum
254
- return object_complete(uk, INT2FIX(b));
254
+ return object_complete(uk, INT2NUM(b));
255
255
 
256
256
  SWITCH_RANGE(b, 0xe0, 0xff) // Negative Fixnum
257
- return object_complete(uk, INT2FIX((int8_t)b));
257
+ return object_complete(uk, INT2NUM((int8_t)b));
258
258
 
259
259
  SWITCH_RANGE(b, 0xa0, 0xbf) // FixRaw
260
260
  int count = b & 0x1f;
@@ -317,14 +317,14 @@ static int read_primitive(msgpack_unpacker_t* uk)
317
317
  {
318
318
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 1);
319
319
  uint8_t u8 = cb->u8;
320
- return object_complete(uk, INT2FIX((int)u8));
320
+ return object_complete(uk, INT2NUM((int)u8));
321
321
  }
322
322
 
323
323
  case 0xcd: // unsigned int 16
324
324
  {
325
325
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 2);
326
326
  uint16_t u16 = _msgpack_be16(cb->u16);
327
- return object_complete(uk, INT2FIX((int)u16));
327
+ return object_complete(uk, INT2NUM((int)u16));
328
328
  }
329
329
 
330
330
  case 0xce: // unsigned int 32
@@ -345,21 +345,21 @@ static int read_primitive(msgpack_unpacker_t* uk)
345
345
  {
346
346
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 1);
347
347
  int8_t i8 = cb->i8;
348
- return object_complete(uk, INT2FIX((int)i8));
348
+ return object_complete(uk, INT2NUM((int)i8));
349
349
  }
350
350
 
351
351
  case 0xd1: // signed int 16
352
352
  {
353
353
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 2);
354
354
  int16_t i16 = _msgpack_be16(cb->i16);
355
- return object_complete(uk, INT2FIX((int)i16));
355
+ return object_complete(uk, INT2NUM((int)i16));
356
356
  }
357
357
 
358
358
  case 0xd2: // signed int 32
359
359
  {
360
360
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 4);
361
361
  int32_t i32 = _msgpack_be32(cb->i32);
362
- return object_complete(uk, LONG2FIX((long)i32));
362
+ return object_complete(uk, LONG2NUM((long)i32));
363
363
  }
364
364
 
365
365
  case 0xd3: // signed int 64
@@ -1,3 +1,3 @@
1
1
  module MessagePack
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - FURUHASHI Sadayuki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-24 00:00:00 +09:00
18
+ date: 2013-02-07 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency