|
37 | 37 | * Integer |
38 | 38 | */ |
39 | 39 |
|
40 | | -#define msgpack_pack_real_uint8(x, d) \ |
41 | | -do { \ |
42 | | - if(d < (1<<7)) { \ |
43 | | - /* fixnum */ \ |
44 | | - msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \ |
45 | | - } else { \ |
46 | | - /* unsigned 8 */ \ |
47 | | - unsigned char buf[2] = {0xcc, TAKE8_8(d)}; \ |
48 | | - msgpack_pack_append_buffer(x, buf, 2); \ |
49 | | - } \ |
50 | | -} while(0) |
51 | | - |
52 | 40 | #define msgpack_pack_real_uint16(x, d) \ |
53 | 41 | do { \ |
54 | 42 | if(d < (1<<7)) { \ |
@@ -123,18 +111,6 @@ do { \ |
123 | 111 | } \ |
124 | 112 | } while(0) |
125 | 113 |
|
126 | | -#define msgpack_pack_real_int8(x, d) \ |
127 | | -do { \ |
128 | | - if(d < -(1<<5)) { \ |
129 | | - /* signed 8 */ \ |
130 | | - unsigned char buf[2] = {0xd0, TAKE8_8(d)}; \ |
131 | | - msgpack_pack_append_buffer(x, buf, 2); \ |
132 | | - } else { \ |
133 | | - /* fixnum */ \ |
134 | | - msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \ |
135 | | - } \ |
136 | | -} while(0) |
137 | | - |
138 | 114 | #define msgpack_pack_real_int16(x, d) \ |
139 | 115 | do { \ |
140 | 116 | if(d < -(1<<5)) { \ |
@@ -264,49 +240,6 @@ do { \ |
264 | 240 | } while(0) |
265 | 241 |
|
266 | 242 |
|
267 | | -static inline int msgpack_pack_uint8(msgpack_packer* x, uint8_t d) |
268 | | -{ |
269 | | - msgpack_pack_real_uint8(x, d); |
270 | | -} |
271 | | - |
272 | | -static inline int msgpack_pack_uint16(msgpack_packer* x, uint16_t d) |
273 | | -{ |
274 | | - msgpack_pack_real_uint16(x, d); |
275 | | -} |
276 | | - |
277 | | -static inline int msgpack_pack_uint32(msgpack_packer* x, uint32_t d) |
278 | | -{ |
279 | | - msgpack_pack_real_uint32(x, d); |
280 | | -} |
281 | | - |
282 | | -static inline int msgpack_pack_uint64(msgpack_packer* x, uint64_t d) |
283 | | -{ |
284 | | - msgpack_pack_real_uint64(x, d); |
285 | | -} |
286 | | - |
287 | | -static inline int msgpack_pack_int8(msgpack_packer* x, int8_t d) |
288 | | -{ |
289 | | - msgpack_pack_real_int8(x, d); |
290 | | -} |
291 | | - |
292 | | -static inline int msgpack_pack_int16(msgpack_packer* x, int16_t d) |
293 | | -{ |
294 | | - msgpack_pack_real_int16(x, d); |
295 | | -} |
296 | | - |
297 | | -static inline int msgpack_pack_int32(msgpack_packer* x, int32_t d) |
298 | | -{ |
299 | | - msgpack_pack_real_int32(x, d); |
300 | | -} |
301 | | - |
302 | | -static inline int msgpack_pack_int64(msgpack_packer* x, int64_t d) |
303 | | -{ |
304 | | - msgpack_pack_real_int64(x, d); |
305 | | -} |
306 | | - |
307 | | - |
308 | | -//#ifdef msgpack_pack_inline_func_cint |
309 | | - |
310 | 243 | static inline int msgpack_pack_short(msgpack_packer* x, short d) |
311 | 244 | { |
312 | 245 | #if defined(SIZEOF_SHORT) |
@@ -372,192 +305,37 @@ if(sizeof(int) == 2) { |
372 | 305 | static inline int msgpack_pack_long(msgpack_packer* x, long d) |
373 | 306 | { |
374 | 307 | #if defined(SIZEOF_LONG) |
375 | | -#if SIZEOF_LONG == 2 |
376 | | - msgpack_pack_real_int16(x, d); |
377 | | -#elif SIZEOF_LONG == 4 |
| 308 | +#if SIZEOF_LONG == 4 |
378 | 309 | msgpack_pack_real_int32(x, d); |
379 | 310 | #else |
380 | 311 | msgpack_pack_real_int64(x, d); |
381 | 312 | #endif |
382 | 313 |
|
383 | 314 | #elif defined(LONG_MAX) |
384 | | -#if LONG_MAX == 0x7fffL |
385 | | - msgpack_pack_real_int16(x, d); |
386 | | -#elif LONG_MAX == 0x7fffffffL |
| 315 | +#if LONG_MAX == 0x7fffffffL |
387 | 316 | msgpack_pack_real_int32(x, d); |
388 | 317 | #else |
389 | 318 | msgpack_pack_real_int64(x, d); |
390 | 319 | #endif |
391 | 320 |
|
392 | 321 | #else |
393 | | -if(sizeof(long) == 2) { |
394 | | - msgpack_pack_real_int16(x, d); |
395 | | -} else if(sizeof(long) == 4) { |
396 | | - msgpack_pack_real_int32(x, d); |
397 | | -} else { |
398 | | - msgpack_pack_real_int64(x, d); |
399 | | -} |
| 322 | + if (sizeof(long) == 4) { |
| 323 | + msgpack_pack_real_int32(x, d); |
| 324 | + } else { |
| 325 | + msgpack_pack_real_int64(x, d); |
| 326 | + } |
400 | 327 | #endif |
401 | 328 | } |
402 | 329 |
|
403 | 330 | static inline int msgpack_pack_long_long(msgpack_packer* x, long long d) |
404 | 331 | { |
405 | | -#if defined(SIZEOF_LONG_LONG) |
406 | | -#if SIZEOF_LONG_LONG == 2 |
407 | | - msgpack_pack_real_int16(x, d); |
408 | | -#elif SIZEOF_LONG_LONG == 4 |
409 | | - msgpack_pack_real_int32(x, d); |
410 | | -#else |
411 | | - msgpack_pack_real_int64(x, d); |
412 | | -#endif |
413 | | - |
414 | | -#elif defined(LLONG_MAX) |
415 | | -#if LLONG_MAX == 0x7fffL |
416 | | - msgpack_pack_real_int16(x, d); |
417 | | -#elif LLONG_MAX == 0x7fffffffL |
418 | | - msgpack_pack_real_int32(x, d); |
419 | | -#else |
420 | | - msgpack_pack_real_int64(x, d); |
421 | | -#endif |
422 | | - |
423 | | -#else |
424 | | -if(sizeof(long long) == 2) { |
425 | | - msgpack_pack_real_int16(x, d); |
426 | | -} else if(sizeof(long long) == 4) { |
427 | | - msgpack_pack_real_int32(x, d); |
428 | | -} else { |
429 | 332 | msgpack_pack_real_int64(x, d); |
430 | 333 | } |
431 | | -#endif |
432 | | -} |
433 | | - |
434 | | -static inline int msgpack_pack_unsigned_short(msgpack_packer* x, unsigned short d) |
435 | | -{ |
436 | | -#if defined(SIZEOF_SHORT) |
437 | | -#if SIZEOF_SHORT == 2 |
438 | | - msgpack_pack_real_uint16(x, d); |
439 | | -#elif SIZEOF_SHORT == 4 |
440 | | - msgpack_pack_real_uint32(x, d); |
441 | | -#else |
442 | | - msgpack_pack_real_uint64(x, d); |
443 | | -#endif |
444 | | - |
445 | | -#elif defined(USHRT_MAX) |
446 | | -#if USHRT_MAX == 0xffffU |
447 | | - msgpack_pack_real_uint16(x, d); |
448 | | -#elif USHRT_MAX == 0xffffffffU |
449 | | - msgpack_pack_real_uint32(x, d); |
450 | | -#else |
451 | | - msgpack_pack_real_uint64(x, d); |
452 | | -#endif |
453 | | - |
454 | | -#else |
455 | | -if(sizeof(unsigned short) == 2) { |
456 | | - msgpack_pack_real_uint16(x, d); |
457 | | -} else if(sizeof(unsigned short) == 4) { |
458 | | - msgpack_pack_real_uint32(x, d); |
459 | | -} else { |
460 | | - msgpack_pack_real_uint64(x, d); |
461 | | -} |
462 | | -#endif |
463 | | -} |
464 | | - |
465 | | -static inline int msgpack_pack_unsigned_int(msgpack_packer* x, unsigned int d) |
466 | | -{ |
467 | | -#if defined(SIZEOF_INT) |
468 | | -#if SIZEOF_INT == 2 |
469 | | - msgpack_pack_real_uint16(x, d); |
470 | | -#elif SIZEOF_INT == 4 |
471 | | - msgpack_pack_real_uint32(x, d); |
472 | | -#else |
473 | | - msgpack_pack_real_uint64(x, d); |
474 | | -#endif |
475 | | - |
476 | | -#elif defined(UINT_MAX) |
477 | | -#if UINT_MAX == 0xffffU |
478 | | - msgpack_pack_real_uint16(x, d); |
479 | | -#elif UINT_MAX == 0xffffffffU |
480 | | - msgpack_pack_real_uint32(x, d); |
481 | | -#else |
482 | | - msgpack_pack_real_uint64(x, d); |
483 | | -#endif |
484 | | - |
485 | | -#else |
486 | | -if(sizeof(unsigned int) == 2) { |
487 | | - msgpack_pack_real_uint16(x, d); |
488 | | -} else if(sizeof(unsigned int) == 4) { |
489 | | - msgpack_pack_real_uint32(x, d); |
490 | | -} else { |
491 | | - msgpack_pack_real_uint64(x, d); |
492 | | -} |
493 | | -#endif |
494 | | -} |
495 | | - |
496 | | -static inline int msgpack_pack_unsigned_long(msgpack_packer* x, unsigned long d) |
497 | | -{ |
498 | | -#if defined(SIZEOF_LONG) |
499 | | -#if SIZEOF_LONG == 2 |
500 | | - msgpack_pack_real_uint16(x, d); |
501 | | -#elif SIZEOF_LONG == 4 |
502 | | - msgpack_pack_real_uint32(x, d); |
503 | | -#else |
504 | | - msgpack_pack_real_uint64(x, d); |
505 | | -#endif |
506 | | - |
507 | | -#elif defined(ULONG_MAX) |
508 | | -#if ULONG_MAX == 0xffffUL |
509 | | - msgpack_pack_real_uint16(x, d); |
510 | | -#elif ULONG_MAX == 0xffffffffUL |
511 | | - msgpack_pack_real_uint32(x, d); |
512 | | -#else |
513 | | - msgpack_pack_real_uint64(x, d); |
514 | | -#endif |
515 | | - |
516 | | -#else |
517 | | -if(sizeof(unsigned long) == 2) { |
518 | | - msgpack_pack_real_uint16(x, d); |
519 | | -} else if(sizeof(unsigned long) == 4) { |
520 | | - msgpack_pack_real_uint32(x, d); |
521 | | -} else { |
522 | | - msgpack_pack_real_uint64(x, d); |
523 | | -} |
524 | | -#endif |
525 | | -} |
526 | 334 |
|
527 | 335 | static inline int msgpack_pack_unsigned_long_long(msgpack_packer* x, unsigned long long d) |
528 | 336 | { |
529 | | -#if defined(SIZEOF_LONG_LONG) |
530 | | -#if SIZEOF_LONG_LONG == 2 |
531 | | - msgpack_pack_real_uint16(x, d); |
532 | | -#elif SIZEOF_LONG_LONG == 4 |
533 | | - msgpack_pack_real_uint32(x, d); |
534 | | -#else |
535 | | - msgpack_pack_real_uint64(x, d); |
536 | | -#endif |
537 | | - |
538 | | -#elif defined(ULLONG_MAX) |
539 | | -#if ULLONG_MAX == 0xffffUL |
540 | | - msgpack_pack_real_uint16(x, d); |
541 | | -#elif ULLONG_MAX == 0xffffffffUL |
542 | | - msgpack_pack_real_uint32(x, d); |
543 | | -#else |
544 | | - msgpack_pack_real_uint64(x, d); |
545 | | -#endif |
546 | | - |
547 | | -#else |
548 | | -if(sizeof(unsigned long long) == 2) { |
549 | | - msgpack_pack_real_uint16(x, d); |
550 | | -} else if(sizeof(unsigned long long) == 4) { |
551 | | - msgpack_pack_real_uint32(x, d); |
552 | | -} else { |
553 | 337 | msgpack_pack_real_uint64(x, d); |
554 | 338 | } |
555 | | -#endif |
556 | | -} |
557 | | - |
558 | | -//#undef msgpack_pack_inline_func_cint |
559 | | -//#endif |
560 | | - |
561 | 339 |
|
562 | 340 |
|
563 | 341 | /* |
@@ -810,11 +588,9 @@ static inline int msgpack_pack_timestamp(msgpack_packer* x, int64_t seconds, uin |
810 | 588 | #undef TAKE8_32 |
811 | 589 | #undef TAKE8_64 |
812 | 590 |
|
813 | | -#undef msgpack_pack_real_uint8 |
814 | 591 | #undef msgpack_pack_real_uint16 |
815 | 592 | #undef msgpack_pack_real_uint32 |
816 | 593 | #undef msgpack_pack_real_uint64 |
817 | | -#undef msgpack_pack_real_int8 |
818 | 594 | #undef msgpack_pack_real_int16 |
819 | 595 | #undef msgpack_pack_real_int32 |
820 | 596 | #undef msgpack_pack_real_int64 |
0 commit comments