sq_detailed_metrics 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/extconf.rb +26 -0
  3. data/include/half.hpp +4575 -0
  4. data/include/msgpack.h +24 -0
  5. data/include/msgpack/fbuffer.h +42 -0
  6. data/include/msgpack/gcc_atomic.h +25 -0
  7. data/include/msgpack/object.h +118 -0
  8. data/include/msgpack/pack.h +174 -0
  9. data/include/msgpack/pack_define.h +18 -0
  10. data/include/msgpack/pack_template.h +952 -0
  11. data/include/msgpack/sbuffer.h +115 -0
  12. data/include/msgpack/sysdep.h +221 -0
  13. data/include/msgpack/timestamp.h +58 -0
  14. data/include/msgpack/unpack.h +281 -0
  15. data/include/msgpack/unpack_define.h +89 -0
  16. data/include/msgpack/unpack_template.h +471 -0
  17. data/include/msgpack/util.h +15 -0
  18. data/include/msgpack/version.h +38 -0
  19. data/include/msgpack/version_master.h +3 -0
  20. data/include/msgpack/vrefbuffer.h +144 -0
  21. data/include/msgpack/zbuffer.h +205 -0
  22. data/include/msgpack/zone.h +163 -0
  23. data/include/rapidjson/allocators.h +271 -0
  24. data/include/rapidjson/document.h +2575 -0
  25. data/include/rapidjson/encodedstream.h +299 -0
  26. data/include/rapidjson/encodings.h +716 -0
  27. data/include/rapidjson/error/en.h +74 -0
  28. data/include/rapidjson/error/error.h +155 -0
  29. data/include/rapidjson/filereadstream.h +99 -0
  30. data/include/rapidjson/filewritestream.h +104 -0
  31. data/include/rapidjson/fwd.h +151 -0
  32. data/include/rapidjson/internal/biginteger.h +290 -0
  33. data/include/rapidjson/internal/diyfp.h +258 -0
  34. data/include/rapidjson/internal/dtoa.h +245 -0
  35. data/include/rapidjson/internal/ieee754.h +78 -0
  36. data/include/rapidjson/internal/itoa.h +304 -0
  37. data/include/rapidjson/internal/meta.h +181 -0
  38. data/include/rapidjson/internal/pow10.h +55 -0
  39. data/include/rapidjson/internal/regex.h +701 -0
  40. data/include/rapidjson/internal/stack.h +230 -0
  41. data/include/rapidjson/internal/strfunc.h +55 -0
  42. data/include/rapidjson/internal/strtod.h +269 -0
  43. data/include/rapidjson/internal/swap.h +46 -0
  44. data/include/rapidjson/istreamwrapper.h +115 -0
  45. data/include/rapidjson/memorybuffer.h +70 -0
  46. data/include/rapidjson/memorystream.h +71 -0
  47. data/include/rapidjson/msinttypes/inttypes.h +316 -0
  48. data/include/rapidjson/msinttypes/stdint.h +300 -0
  49. data/include/rapidjson/ostreamwrapper.h +81 -0
  50. data/include/rapidjson/pointer.h +1358 -0
  51. data/include/rapidjson/prettywriter.h +255 -0
  52. data/include/rapidjson/rapidjson.h +615 -0
  53. data/include/rapidjson/reader.h +1879 -0
  54. data/include/rapidjson/schema.h +2006 -0
  55. data/include/rapidjson/stream.h +179 -0
  56. data/include/rapidjson/stringbuffer.h +117 -0
  57. data/include/rapidjson/writer.h +610 -0
  58. data/include/xxhash.h +328 -0
  59. data/json_conv.cpp +284 -0
  60. data/json_conv.hpp +17 -0
  61. data/metrics.cpp +239 -0
  62. data/metrics.hpp +84 -0
  63. data/msgpack/objectc.c +482 -0
  64. data/msgpack/unpack.c +703 -0
  65. data/msgpack/version.c +22 -0
  66. data/msgpack/vrefbuffer.c +250 -0
  67. data/msgpack/zone.c +222 -0
  68. data/sq_detailed_metrics.cpp +248 -0
  69. metadata +199 -0
@@ -0,0 +1,24 @@
1
+ /*
2
+ * MessagePack for C
3
+ *
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * http://www.boost.org/LICENSE_1_0.txt)
9
+ */
10
+ /**
11
+ * @defgroup msgpack MessagePack C
12
+ * @{
13
+ * @}
14
+ */
15
+
16
+ #include "msgpack/util.h"
17
+ #include "msgpack/object.h"
18
+ #include "msgpack/zone.h"
19
+ #include "msgpack/pack.h"
20
+ #include "msgpack/unpack.h"
21
+ #include "msgpack/sbuffer.h"
22
+ #include "msgpack/vrefbuffer.h"
23
+ #include "msgpack/version.h"
24
+
@@ -0,0 +1,42 @@
1
+ /*
2
+ * MessagePack for C FILE* buffer adaptor
3
+ *
4
+ * Copyright (C) 2013 Vladimir Volodko
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * http://www.boost.org/LICENSE_1_0.txt)
9
+ */
10
+ #ifndef MSGPACK_FBUFFER_H
11
+ #define MSGPACK_FBUFFER_H
12
+
13
+ #include <stdio.h>
14
+ #include <assert.h>
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+
21
+ /**
22
+ * @defgroup msgpack_fbuffer FILE* buffer
23
+ * @ingroup msgpack_buffer
24
+ * @{
25
+ */
26
+
27
+ static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
28
+ {
29
+ assert(buf || len == 0);
30
+ if(!buf) return 0;
31
+
32
+ return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
33
+ }
34
+
35
+ /** @} */
36
+
37
+
38
+ #ifdef __cplusplus
39
+ }
40
+ #endif
41
+
42
+ #endif /* msgpack/fbuffer.h */
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Distributed under the Boost Software License, Version 1.0.
3
+ * (See accompanying file LICENSE_1_0.txt or copy at
4
+ * http://www.boost.org/LICENSE_1_0.txt)
5
+ */
6
+
7
+ #ifndef MSGPACK_GCC_ATOMIC_H
8
+ #define MSGPACK_GCC_ATOMIC_H
9
+
10
+ #if defined(__cplusplus)
11
+ extern "C" {
12
+ #endif
13
+
14
+ typedef int _msgpack_atomic_counter_t;
15
+
16
+ int _msgpack_sync_decr_and_fetch(volatile _msgpack_atomic_counter_t* ptr);
17
+ int _msgpack_sync_incr_and_fetch(volatile _msgpack_atomic_counter_t* ptr);
18
+
19
+
20
+ #if defined(__cplusplus)
21
+ }
22
+ #endif
23
+
24
+
25
+ #endif // MSGPACK_GCC_ATOMIC_H
@@ -0,0 +1,118 @@
1
+ /*
2
+ * MessagePack for C dynamic typing routine
3
+ *
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * http://www.boost.org/LICENSE_1_0.txt)
9
+ */
10
+ #ifndef MSGPACK_OBJECT_H
11
+ #define MSGPACK_OBJECT_H
12
+
13
+ #include "zone.h"
14
+ #include <stdio.h>
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+
21
+ /**
22
+ * @defgroup msgpack_object Dynamically typed object
23
+ * @ingroup msgpack
24
+ * @{
25
+ */
26
+
27
+ typedef enum {
28
+ MSGPACK_OBJECT_NIL = 0x00,
29
+ MSGPACK_OBJECT_BOOLEAN = 0x01,
30
+ MSGPACK_OBJECT_POSITIVE_INTEGER = 0x02,
31
+ MSGPACK_OBJECT_NEGATIVE_INTEGER = 0x03,
32
+ MSGPACK_OBJECT_FLOAT32 = 0x0a,
33
+ MSGPACK_OBJECT_FLOAT64 = 0x04,
34
+ MSGPACK_OBJECT_FLOAT = 0x04,
35
+ #if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
36
+ MSGPACK_OBJECT_DOUBLE = MSGPACK_OBJECT_FLOAT, /* obsolete */
37
+ #endif /* MSGPACK_USE_LEGACY_NAME_AS_FLOAT */
38
+ MSGPACK_OBJECT_STR = 0x05,
39
+ MSGPACK_OBJECT_ARRAY = 0x06,
40
+ MSGPACK_OBJECT_MAP = 0x07,
41
+ MSGPACK_OBJECT_BIN = 0x08,
42
+ MSGPACK_OBJECT_EXT = 0x09
43
+ } msgpack_object_type;
44
+
45
+
46
+ struct msgpack_object;
47
+ struct msgpack_object_kv;
48
+
49
+ typedef struct {
50
+ uint32_t size;
51
+ struct msgpack_object* ptr;
52
+ } msgpack_object_array;
53
+
54
+ typedef struct {
55
+ uint32_t size;
56
+ struct msgpack_object_kv* ptr;
57
+ } msgpack_object_map;
58
+
59
+ typedef struct {
60
+ uint32_t size;
61
+ const char* ptr;
62
+ } msgpack_object_str;
63
+
64
+ typedef struct {
65
+ uint32_t size;
66
+ const char* ptr;
67
+ } msgpack_object_bin;
68
+
69
+ typedef struct {
70
+ int8_t type;
71
+ uint32_t size;
72
+ const char* ptr;
73
+ } msgpack_object_ext;
74
+
75
+ typedef union {
76
+ bool boolean;
77
+ uint64_t u64;
78
+ int64_t i64;
79
+ #if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
80
+ double dec; /* obsolete*/
81
+ #endif /* MSGPACK_USE_LEGACY_NAME_AS_FLOAT */
82
+ double f64;
83
+ msgpack_object_array array;
84
+ msgpack_object_map map;
85
+ msgpack_object_str str;
86
+ msgpack_object_bin bin;
87
+ msgpack_object_ext ext;
88
+ } msgpack_object_union;
89
+
90
+ typedef struct msgpack_object {
91
+ msgpack_object_type type;
92
+ msgpack_object_union via;
93
+ } msgpack_object;
94
+
95
+ typedef struct msgpack_object_kv {
96
+ msgpack_object key;
97
+ msgpack_object val;
98
+ } msgpack_object_kv;
99
+
100
+ #if !defined(_KERNEL_MODE)
101
+ MSGPACK_DLLEXPORT
102
+ void msgpack_object_print(FILE* out, msgpack_object o);
103
+ #endif
104
+
105
+ MSGPACK_DLLEXPORT
106
+ int msgpack_object_print_buffer(char *buffer, size_t buffer_size, msgpack_object o);
107
+
108
+ MSGPACK_DLLEXPORT
109
+ bool msgpack_object_equal(const msgpack_object x, const msgpack_object y);
110
+
111
+ /** @} */
112
+
113
+
114
+ #ifdef __cplusplus
115
+ }
116
+ #endif
117
+
118
+ #endif /* msgpack/object.h */
@@ -0,0 +1,174 @@
1
+ /*
2
+ * MessagePack for C packing routine
3
+ *
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * http://www.boost.org/LICENSE_1_0.txt)
9
+ */
10
+ #ifndef MSGPACK_PACK_H
11
+ #define MSGPACK_PACK_H
12
+
13
+ #include "pack_define.h"
14
+ #include "object.h"
15
+ #include "timestamp.h"
16
+ #include <stdlib.h>
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+
23
+ /**
24
+ * @defgroup msgpack_buffer Buffers
25
+ * @ingroup msgpack
26
+ * @{
27
+ * @}
28
+ */
29
+
30
+ /**
31
+ * @defgroup msgpack_pack Serializer
32
+ * @ingroup msgpack
33
+ * @{
34
+ */
35
+
36
+ typedef int (*msgpack_packer_write)(void* data, const char* buf, size_t len);
37
+
38
+ typedef struct msgpack_packer {
39
+ void* data;
40
+ msgpack_packer_write callback;
41
+ } msgpack_packer;
42
+
43
+ static void msgpack_packer_init(msgpack_packer* pk, void* data, msgpack_packer_write callback);
44
+
45
+ static msgpack_packer* msgpack_packer_new(void* data, msgpack_packer_write callback);
46
+ static void msgpack_packer_free(msgpack_packer* pk);
47
+
48
+ static int msgpack_pack_char(msgpack_packer* pk, char d);
49
+
50
+ static int msgpack_pack_signed_char(msgpack_packer* pk, signed char d);
51
+ static int msgpack_pack_short(msgpack_packer* pk, short d);
52
+ static int msgpack_pack_int(msgpack_packer* pk, int d);
53
+ static int msgpack_pack_long(msgpack_packer* pk, long d);
54
+ static int msgpack_pack_long_long(msgpack_packer* pk, long long d);
55
+ static int msgpack_pack_unsigned_char(msgpack_packer* pk, unsigned char d);
56
+ static int msgpack_pack_unsigned_short(msgpack_packer* pk, unsigned short d);
57
+ static int msgpack_pack_unsigned_int(msgpack_packer* pk, unsigned int d);
58
+ static int msgpack_pack_unsigned_long(msgpack_packer* pk, unsigned long d);
59
+ static int msgpack_pack_unsigned_long_long(msgpack_packer* pk, unsigned long long d);
60
+
61
+ static int msgpack_pack_uint8(msgpack_packer* pk, uint8_t d);
62
+ static int msgpack_pack_uint16(msgpack_packer* pk, uint16_t d);
63
+ static int msgpack_pack_uint32(msgpack_packer* pk, uint32_t d);
64
+ static int msgpack_pack_uint64(msgpack_packer* pk, uint64_t d);
65
+ static int msgpack_pack_int8(msgpack_packer* pk, int8_t d);
66
+ static int msgpack_pack_int16(msgpack_packer* pk, int16_t d);
67
+ static int msgpack_pack_int32(msgpack_packer* pk, int32_t d);
68
+ static int msgpack_pack_int64(msgpack_packer* pk, int64_t d);
69
+
70
+ static int msgpack_pack_fix_uint8(msgpack_packer* pk, uint8_t d);
71
+ static int msgpack_pack_fix_uint16(msgpack_packer* pk, uint16_t d);
72
+ static int msgpack_pack_fix_uint32(msgpack_packer* pk, uint32_t d);
73
+ static int msgpack_pack_fix_uint64(msgpack_packer* pk, uint64_t d);
74
+ static int msgpack_pack_fix_int8(msgpack_packer* pk, int8_t d);
75
+ static int msgpack_pack_fix_int16(msgpack_packer* pk, int16_t d);
76
+ static int msgpack_pack_fix_int32(msgpack_packer* pk, int32_t d);
77
+ static int msgpack_pack_fix_int64(msgpack_packer* pk, int64_t d);
78
+
79
+ static int msgpack_pack_float(msgpack_packer* pk, float d);
80
+ static int msgpack_pack_double(msgpack_packer* pk, double d);
81
+
82
+ static int msgpack_pack_nil(msgpack_packer* pk);
83
+ static int msgpack_pack_true(msgpack_packer* pk);
84
+ static int msgpack_pack_false(msgpack_packer* pk);
85
+
86
+ static int msgpack_pack_array(msgpack_packer* pk, size_t n);
87
+
88
+ static int msgpack_pack_map(msgpack_packer* pk, size_t n);
89
+
90
+ static int msgpack_pack_str(msgpack_packer* pk, size_t l);
91
+ static int msgpack_pack_str_body(msgpack_packer* pk, const void* b, size_t l);
92
+ static int msgpack_pack_str_with_body(msgpack_packer* pk, const void* b, size_t l);
93
+
94
+ static int msgpack_pack_v4raw(msgpack_packer* pk, size_t l);
95
+ static int msgpack_pack_v4raw_body(msgpack_packer* pk, const void* b, size_t l);
96
+
97
+ static int msgpack_pack_bin(msgpack_packer* pk, size_t l);
98
+ static int msgpack_pack_bin_body(msgpack_packer* pk, const void* b, size_t l);
99
+ static int msgpack_pack_bin_with_body(msgpack_packer* pk, const void* b, size_t l);
100
+
101
+ static int msgpack_pack_ext(msgpack_packer* pk, size_t l, int8_t type);
102
+ static int msgpack_pack_ext_body(msgpack_packer* pk, const void* b, size_t l);
103
+ static int msgpack_pack_ext_with_body(msgpack_packer* pk, const void* b, size_t l, int8_t type);
104
+
105
+ static int msgpack_pack_timestamp(msgpack_packer* pk, const msgpack_timestamp* d);
106
+
107
+ MSGPACK_DLLEXPORT
108
+ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d);
109
+
110
+
111
+ /** @} */
112
+
113
+
114
+ #define msgpack_pack_inline_func(name) \
115
+ inline int msgpack_pack ## name
116
+
117
+ #define msgpack_pack_inline_func_cint(name) \
118
+ inline int msgpack_pack ## name
119
+
120
+ #define msgpack_pack_inline_func_fixint(name) \
121
+ inline int msgpack_pack_fix ## name
122
+
123
+ #define msgpack_pack_user msgpack_packer*
124
+
125
+ #define msgpack_pack_append_buffer(user, buf, len) \
126
+ return (*(user)->callback)((user)->data, (const char*)buf, len)
127
+
128
+ #include "pack_template.h"
129
+
130
+ inline void msgpack_packer_init(msgpack_packer* pk, void* data, msgpack_packer_write callback)
131
+ {
132
+ pk->data = data;
133
+ pk->callback = callback;
134
+ }
135
+
136
+ inline msgpack_packer* msgpack_packer_new(void* data, msgpack_packer_write callback)
137
+ {
138
+ msgpack_packer* pk = (msgpack_packer*)calloc(1, sizeof(msgpack_packer));
139
+ if(!pk) { return NULL; }
140
+ msgpack_packer_init(pk, data, callback);
141
+ return pk;
142
+ }
143
+
144
+ inline void msgpack_packer_free(msgpack_packer* pk)
145
+ {
146
+ free(pk);
147
+ }
148
+
149
+ inline int msgpack_pack_str_with_body(msgpack_packer* pk, const void* b, size_t l)
150
+ {
151
+ int ret = msgpack_pack_str(pk, l);
152
+ if (ret != 0) { return ret; }
153
+ return msgpack_pack_str_body(pk, b, l);
154
+ }
155
+
156
+ inline int msgpack_pack_bin_with_body(msgpack_packer* pk, const void* b, size_t l)
157
+ {
158
+ int ret = msgpack_pack_bin(pk, l);
159
+ if (ret != 0) { return ret; }
160
+ return msgpack_pack_bin_body(pk, b, l);
161
+ }
162
+
163
+ inline int msgpack_pack_ext_with_body(msgpack_packer* pk, const void* b, size_t l, int8_t type)
164
+ {
165
+ int ret = msgpack_pack_ext(pk, l, type);
166
+ if (ret != 0) { return ret; }
167
+ return msgpack_pack_ext_body(pk, b, l);
168
+ }
169
+
170
+ #ifdef __cplusplus
171
+ }
172
+ #endif
173
+
174
+ #endif /* msgpack/pack.h */
@@ -0,0 +1,18 @@
1
+ /*
2
+ * MessagePack unpacking routine template
3
+ *
4
+ * Copyright (C) 2008-2010 FURUHASHI Sadayuki
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * http://www.boost.org/LICENSE_1_0.txt)
9
+ */
10
+ #ifndef MSGPACK_PACK_DEFINE_H
11
+ #define MSGPACK_PACK_DEFINE_H
12
+
13
+ #include "msgpack/sysdep.h"
14
+ #include <limits.h>
15
+ #include <string.h>
16
+
17
+ #endif /* msgpack/pack_define.h */
18
+
@@ -0,0 +1,952 @@
1
+ /*
2
+ * MessagePack packing routine template
3
+ *
4
+ * Copyright (C) 2008-2010 FURUHASHI Sadayuki
5
+ *
6
+ * Distributed under the Boost Software License, Version 1.0.
7
+ * (See accompanying file LICENSE_1_0.txt or copy at
8
+ * http://www.boost.org/LICENSE_1_0.txt)
9
+ */
10
+
11
+ #ifndef MSGPACK_ENDIAN_BIG_BYTE
12
+ #define MSGPACK_ENDIAN_BIG_BYTE 0
13
+ #endif
14
+ #ifndef MSGPACK_ENDIAN_LITTLE_BYTE
15
+ #define MSGPACK_ENDIAN_LITTLE_BYTE 1
16
+ #endif
17
+
18
+ #if MSGPACK_ENDIAN_LITTLE_BYTE
19
+ #define TAKE8_8(d) ((uint8_t*)&d)[0]
20
+ #define TAKE8_16(d) ((uint8_t*)&d)[0]
21
+ #define TAKE8_32(d) ((uint8_t*)&d)[0]
22
+ #define TAKE8_64(d) ((uint8_t*)&d)[0]
23
+ #elif MSGPACK_ENDIAN_BIG_BYTE
24
+ #define TAKE8_8(d) ((uint8_t*)&d)[0]
25
+ #define TAKE8_16(d) ((uint8_t*)&d)[1]
26
+ #define TAKE8_32(d) ((uint8_t*)&d)[3]
27
+ #define TAKE8_64(d) ((uint8_t*)&d)[7]
28
+ #else
29
+ #error msgpack-c supports only big endian and little endian
30
+ #endif
31
+
32
+ #ifndef msgpack_pack_inline_func
33
+ #error msgpack_pack_inline_func template is not defined
34
+ #endif
35
+
36
+ #ifndef msgpack_pack_user
37
+ #error msgpack_pack_user type is not defined
38
+ #endif
39
+
40
+ #ifndef msgpack_pack_append_buffer
41
+ #error msgpack_pack_append_buffer callback is not defined
42
+ #endif
43
+
44
+ #if defined(_MSC_VER)
45
+ # pragma warning(push)
46
+ # pragma warning(disable : 4204) /* nonstandard extension used: non-constant aggregate initializer */
47
+ #endif
48
+
49
+ /*
50
+ * Integer
51
+ */
52
+
53
+ #define msgpack_pack_real_uint8(x, d) \
54
+ do { \
55
+ if(d < (1<<7)) { \
56
+ /* fixnum */ \
57
+ msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \
58
+ } else { \
59
+ /* unsigned 8 */ \
60
+ unsigned char buf[2] = {0xcc, TAKE8_8(d)}; \
61
+ msgpack_pack_append_buffer(x, buf, 2); \
62
+ } \
63
+ } while(0)
64
+
65
+ #define msgpack_pack_real_uint16(x, d) \
66
+ do { \
67
+ if(d < (1<<7)) { \
68
+ /* fixnum */ \
69
+ msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \
70
+ } else if(d < (1<<8)) { \
71
+ /* unsigned 8 */ \
72
+ unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \
73
+ msgpack_pack_append_buffer(x, buf, 2); \
74
+ } else { \
75
+ /* unsigned 16 */ \
76
+ unsigned char buf[3]; \
77
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
78
+ msgpack_pack_append_buffer(x, buf, 3); \
79
+ } \
80
+ } while(0)
81
+
82
+ #define msgpack_pack_real_uint32(x, d) \
83
+ do { \
84
+ if(d < (1<<8)) { \
85
+ if(d < (1<<7)) { \
86
+ /* fixnum */ \
87
+ msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \
88
+ } else { \
89
+ /* unsigned 8 */ \
90
+ unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \
91
+ msgpack_pack_append_buffer(x, buf, 2); \
92
+ } \
93
+ } else { \
94
+ if(d < (1<<16)) { \
95
+ /* unsigned 16 */ \
96
+ unsigned char buf[3]; \
97
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
98
+ msgpack_pack_append_buffer(x, buf, 3); \
99
+ } else { \
100
+ /* unsigned 32 */ \
101
+ unsigned char buf[5]; \
102
+ buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
103
+ msgpack_pack_append_buffer(x, buf, 5); \
104
+ } \
105
+ } \
106
+ } while(0)
107
+
108
+ #define msgpack_pack_real_uint64(x, d) \
109
+ do { \
110
+ if(d < (1ULL<<8)) { \
111
+ if(d < (1ULL<<7)) { \
112
+ /* fixnum */ \
113
+ msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
114
+ } else { \
115
+ /* unsigned 8 */ \
116
+ unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
117
+ msgpack_pack_append_buffer(x, buf, 2); \
118
+ } \
119
+ } else { \
120
+ if(d < (1ULL<<16)) { \
121
+ /* unsigned 16 */ \
122
+ unsigned char buf[3]; \
123
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
124
+ msgpack_pack_append_buffer(x, buf, 3); \
125
+ } else if(d < (1ULL<<32)) { \
126
+ /* unsigned 32 */ \
127
+ unsigned char buf[5]; \
128
+ buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
129
+ msgpack_pack_append_buffer(x, buf, 5); \
130
+ } else { \
131
+ /* unsigned 64 */ \
132
+ unsigned char buf[9]; \
133
+ buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
134
+ msgpack_pack_append_buffer(x, buf, 9); \
135
+ } \
136
+ } \
137
+ } while(0)
138
+
139
+ #define msgpack_pack_real_int8(x, d) \
140
+ do { \
141
+ if(d < -(1<<5)) { \
142
+ /* signed 8 */ \
143
+ unsigned char buf[2] = {0xd0, TAKE8_8(d)}; \
144
+ msgpack_pack_append_buffer(x, buf, 2); \
145
+ } else { \
146
+ /* fixnum */ \
147
+ msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \
148
+ } \
149
+ } while(0)
150
+
151
+ #define msgpack_pack_real_int16(x, d) \
152
+ do { \
153
+ if(d < -(1<<5)) { \
154
+ if(d < -(1<<7)) { \
155
+ /* signed 16 */ \
156
+ unsigned char buf[3]; \
157
+ buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
158
+ msgpack_pack_append_buffer(x, buf, 3); \
159
+ } else { \
160
+ /* signed 8 */ \
161
+ unsigned char buf[2] = {0xd0, TAKE8_16(d)}; \
162
+ msgpack_pack_append_buffer(x, buf, 2); \
163
+ } \
164
+ } else if(d < (1<<7)) { \
165
+ /* fixnum */ \
166
+ msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \
167
+ } else { \
168
+ if(d < (1<<8)) { \
169
+ /* unsigned 8 */ \
170
+ unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \
171
+ msgpack_pack_append_buffer(x, buf, 2); \
172
+ } else { \
173
+ /* unsigned 16 */ \
174
+ unsigned char buf[3]; \
175
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
176
+ msgpack_pack_append_buffer(x, buf, 3); \
177
+ } \
178
+ } \
179
+ } while(0)
180
+
181
+ #define msgpack_pack_real_int32(x, d) \
182
+ do { \
183
+ if(d < -(1<<5)) { \
184
+ if(d < -(1<<15)) { \
185
+ /* signed 32 */ \
186
+ unsigned char buf[5]; \
187
+ buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
188
+ msgpack_pack_append_buffer(x, buf, 5); \
189
+ } else if(d < -(1<<7)) { \
190
+ /* signed 16 */ \
191
+ unsigned char buf[3]; \
192
+ buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
193
+ msgpack_pack_append_buffer(x, buf, 3); \
194
+ } else { \
195
+ /* signed 8 */ \
196
+ unsigned char buf[2] = {0xd0, TAKE8_32(d)}; \
197
+ msgpack_pack_append_buffer(x, buf, 2); \
198
+ } \
199
+ } else if(d < (1<<7)) { \
200
+ /* fixnum */ \
201
+ msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \
202
+ } else { \
203
+ if(d < (1<<8)) { \
204
+ /* unsigned 8 */ \
205
+ unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \
206
+ msgpack_pack_append_buffer(x, buf, 2); \
207
+ } else if(d < (1<<16)) { \
208
+ /* unsigned 16 */ \
209
+ unsigned char buf[3]; \
210
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
211
+ msgpack_pack_append_buffer(x, buf, 3); \
212
+ } else { \
213
+ /* unsigned 32 */ \
214
+ unsigned char buf[5]; \
215
+ buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
216
+ msgpack_pack_append_buffer(x, buf, 5); \
217
+ } \
218
+ } \
219
+ } while(0)
220
+
221
+ #define msgpack_pack_real_int64(x, d) \
222
+ do { \
223
+ if(d < -(1LL<<5)) { \
224
+ if(d < -(1LL<<15)) { \
225
+ if(d < -(1LL<<31)) { \
226
+ /* signed 64 */ \
227
+ unsigned char buf[9]; \
228
+ buf[0] = 0xd3; _msgpack_store64(&buf[1], d); \
229
+ msgpack_pack_append_buffer(x, buf, 9); \
230
+ } else { \
231
+ /* signed 32 */ \
232
+ unsigned char buf[5]; \
233
+ buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
234
+ msgpack_pack_append_buffer(x, buf, 5); \
235
+ } \
236
+ } else { \
237
+ if(d < -(1<<7)) { \
238
+ /* signed 16 */ \
239
+ unsigned char buf[3]; \
240
+ buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
241
+ msgpack_pack_append_buffer(x, buf, 3); \
242
+ } else { \
243
+ /* signed 8 */ \
244
+ unsigned char buf[2] = {0xd0, TAKE8_64(d)}; \
245
+ msgpack_pack_append_buffer(x, buf, 2); \
246
+ } \
247
+ } \
248
+ } else if(d < (1<<7)) { \
249
+ /* fixnum */ \
250
+ msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
251
+ } else { \
252
+ if(d < (1LL<<16)) { \
253
+ if(d < (1<<8)) { \
254
+ /* unsigned 8 */ \
255
+ unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
256
+ msgpack_pack_append_buffer(x, buf, 2); \
257
+ } else { \
258
+ /* unsigned 16 */ \
259
+ unsigned char buf[3]; \
260
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
261
+ msgpack_pack_append_buffer(x, buf, 3); \
262
+ } \
263
+ } else { \
264
+ if(d < (1LL<<32)) { \
265
+ /* unsigned 32 */ \
266
+ unsigned char buf[5]; \
267
+ buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
268
+ msgpack_pack_append_buffer(x, buf, 5); \
269
+ } else { \
270
+ /* unsigned 64 */ \
271
+ unsigned char buf[9]; \
272
+ buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
273
+ msgpack_pack_append_buffer(x, buf, 9); \
274
+ } \
275
+ } \
276
+ } \
277
+ } while(0)
278
+
279
+
280
+ #ifdef msgpack_pack_inline_func_fixint
281
+
282
+ msgpack_pack_inline_func_fixint(_uint8)(msgpack_pack_user x, uint8_t d)
283
+ {
284
+ unsigned char buf[2] = {0xcc, TAKE8_8(d)};
285
+ msgpack_pack_append_buffer(x, buf, 2);
286
+ }
287
+
288
+ msgpack_pack_inline_func_fixint(_uint16)(msgpack_pack_user x, uint16_t d)
289
+ {
290
+ unsigned char buf[3];
291
+ buf[0] = 0xcd; _msgpack_store16(&buf[1], d);
292
+ msgpack_pack_append_buffer(x, buf, 3);
293
+ }
294
+
295
+ msgpack_pack_inline_func_fixint(_uint32)(msgpack_pack_user x, uint32_t d)
296
+ {
297
+ unsigned char buf[5];
298
+ buf[0] = 0xce; _msgpack_store32(&buf[1], d);
299
+ msgpack_pack_append_buffer(x, buf, 5);
300
+ }
301
+
302
+ msgpack_pack_inline_func_fixint(_uint64)(msgpack_pack_user x, uint64_t d)
303
+ {
304
+ unsigned char buf[9];
305
+ buf[0] = 0xcf; _msgpack_store64(&buf[1], d);
306
+ msgpack_pack_append_buffer(x, buf, 9);
307
+ }
308
+
309
+ msgpack_pack_inline_func_fixint(_int8)(msgpack_pack_user x, int8_t d)
310
+ {
311
+ unsigned char buf[2] = {0xd0, TAKE8_8(d)};
312
+ msgpack_pack_append_buffer(x, buf, 2);
313
+ }
314
+
315
+ msgpack_pack_inline_func_fixint(_int16)(msgpack_pack_user x, int16_t d)
316
+ {
317
+ unsigned char buf[3];
318
+ buf[0] = 0xd1; _msgpack_store16(&buf[1], d);
319
+ msgpack_pack_append_buffer(x, buf, 3);
320
+ }
321
+
322
+ msgpack_pack_inline_func_fixint(_int32)(msgpack_pack_user x, int32_t d)
323
+ {
324
+ unsigned char buf[5];
325
+ buf[0] = 0xd2; _msgpack_store32(&buf[1], d);
326
+ msgpack_pack_append_buffer(x, buf, 5);
327
+ }
328
+
329
+ msgpack_pack_inline_func_fixint(_int64)(msgpack_pack_user x, int64_t d)
330
+ {
331
+ unsigned char buf[9];
332
+ buf[0] = 0xd3; _msgpack_store64(&buf[1], d);
333
+ msgpack_pack_append_buffer(x, buf, 9);
334
+ }
335
+
336
+ #undef msgpack_pack_inline_func_fixint
337
+ #endif
338
+
339
+
340
+ msgpack_pack_inline_func(_uint8)(msgpack_pack_user x, uint8_t d)
341
+ {
342
+ msgpack_pack_real_uint8(x, d);
343
+ }
344
+
345
+ msgpack_pack_inline_func(_uint16)(msgpack_pack_user x, uint16_t d)
346
+ {
347
+ msgpack_pack_real_uint16(x, d);
348
+ }
349
+
350
+ msgpack_pack_inline_func(_uint32)(msgpack_pack_user x, uint32_t d)
351
+ {
352
+ msgpack_pack_real_uint32(x, d);
353
+ }
354
+
355
+ msgpack_pack_inline_func(_uint64)(msgpack_pack_user x, uint64_t d)
356
+ {
357
+ msgpack_pack_real_uint64(x, d);
358
+ }
359
+
360
+ msgpack_pack_inline_func(_int8)(msgpack_pack_user x, int8_t d)
361
+ {
362
+ msgpack_pack_real_int8(x, d);
363
+ }
364
+
365
+ msgpack_pack_inline_func(_int16)(msgpack_pack_user x, int16_t d)
366
+ {
367
+ msgpack_pack_real_int16(x, d);
368
+ }
369
+
370
+ msgpack_pack_inline_func(_int32)(msgpack_pack_user x, int32_t d)
371
+ {
372
+ msgpack_pack_real_int32(x, d);
373
+ }
374
+
375
+ msgpack_pack_inline_func(_int64)(msgpack_pack_user x, int64_t d)
376
+ {
377
+ msgpack_pack_real_int64(x, d);
378
+ }
379
+
380
+ msgpack_pack_inline_func(_char)(msgpack_pack_user x, char d)
381
+ {
382
+ #if defined(CHAR_MIN)
383
+ #if CHAR_MIN < 0
384
+ msgpack_pack_real_int8(x, d);
385
+ #else
386
+ msgpack_pack_real_uint8(x, d);
387
+ #endif
388
+ #else
389
+ #error CHAR_MIN is not defined
390
+ #endif
391
+ }
392
+
393
+ msgpack_pack_inline_func(_signed_char)(msgpack_pack_user x, signed char d)
394
+ {
395
+ msgpack_pack_real_int8(x, d);
396
+ }
397
+
398
+ msgpack_pack_inline_func(_unsigned_char)(msgpack_pack_user x, unsigned char d)
399
+ {
400
+ msgpack_pack_real_uint8(x, d);
401
+ }
402
+
403
+ #ifdef msgpack_pack_inline_func_cint
404
+
405
+ msgpack_pack_inline_func_cint(_short)(msgpack_pack_user x, short d)
406
+ {
407
+ #if defined(SIZEOF_SHORT)
408
+ #if SIZEOF_SHORT == 2
409
+ msgpack_pack_real_int16(x, d);
410
+ #elif SIZEOF_SHORT == 4
411
+ msgpack_pack_real_int32(x, d);
412
+ #else
413
+ msgpack_pack_real_int64(x, d);
414
+ #endif
415
+
416
+ #elif defined(SHRT_MAX)
417
+ #if SHRT_MAX == 0x7fff
418
+ msgpack_pack_real_int16(x, d);
419
+ #elif SHRT_MAX == 0x7fffffff
420
+ msgpack_pack_real_int32(x, d);
421
+ #else
422
+ msgpack_pack_real_int64(x, d);
423
+ #endif
424
+
425
+ #else
426
+ if(sizeof(short) == 2) {
427
+ msgpack_pack_real_int16(x, d);
428
+ } else if(sizeof(short) == 4) {
429
+ msgpack_pack_real_int32(x, d);
430
+ } else {
431
+ msgpack_pack_real_int64(x, d);
432
+ }
433
+ #endif
434
+ }
435
+
436
+ msgpack_pack_inline_func_cint(_int)(msgpack_pack_user x, int d)
437
+ {
438
+ #if defined(SIZEOF_INT)
439
+ #if SIZEOF_INT == 2
440
+ msgpack_pack_real_int16(x, d);
441
+ #elif SIZEOF_INT == 4
442
+ msgpack_pack_real_int32(x, d);
443
+ #else
444
+ msgpack_pack_real_int64(x, d);
445
+ #endif
446
+
447
+ #elif defined(INT_MAX)
448
+ #if INT_MAX == 0x7fff
449
+ msgpack_pack_real_int16(x, d);
450
+ #elif INT_MAX == 0x7fffffff
451
+ msgpack_pack_real_int32(x, d);
452
+ #else
453
+ msgpack_pack_real_int64(x, d);
454
+ #endif
455
+
456
+ #else
457
+ if(sizeof(int) == 2) {
458
+ msgpack_pack_real_int16(x, d);
459
+ } else if(sizeof(int) == 4) {
460
+ msgpack_pack_real_int32(x, d);
461
+ } else {
462
+ msgpack_pack_real_int64(x, d);
463
+ }
464
+ #endif
465
+ }
466
+
467
+ msgpack_pack_inline_func_cint(_long)(msgpack_pack_user x, long d)
468
+ {
469
+ #if defined(SIZEOF_LONG)
470
+ #if SIZEOF_LONG == 2
471
+ msgpack_pack_real_int16(x, d);
472
+ #elif SIZEOF_LONG == 4
473
+ msgpack_pack_real_int32(x, d);
474
+ #else
475
+ msgpack_pack_real_int64(x, d);
476
+ #endif
477
+
478
+ #elif defined(LONG_MAX)
479
+ #if LONG_MAX == 0x7fffL
480
+ msgpack_pack_real_int16(x, d);
481
+ #elif LONG_MAX == 0x7fffffffL
482
+ msgpack_pack_real_int32(x, d);
483
+ #else
484
+ msgpack_pack_real_int64(x, d);
485
+ #endif
486
+
487
+ #else
488
+ if(sizeof(long) == 2) {
489
+ msgpack_pack_real_int16(x, d);
490
+ } else if(sizeof(long) == 4) {
491
+ msgpack_pack_real_int32(x, d);
492
+ } else {
493
+ msgpack_pack_real_int64(x, d);
494
+ }
495
+ #endif
496
+ }
497
+
498
+ msgpack_pack_inline_func_cint(_long_long)(msgpack_pack_user x, long long d)
499
+ {
500
+ #if defined(SIZEOF_LONG_LONG)
501
+ #if SIZEOF_LONG_LONG == 2
502
+ msgpack_pack_real_int16(x, d);
503
+ #elif SIZEOF_LONG_LONG == 4
504
+ msgpack_pack_real_int32(x, d);
505
+ #else
506
+ msgpack_pack_real_int64(x, d);
507
+ #endif
508
+
509
+ #elif defined(LLONG_MAX)
510
+ #if LLONG_MAX == 0x7fffL
511
+ msgpack_pack_real_int16(x, d);
512
+ #elif LLONG_MAX == 0x7fffffffL
513
+ msgpack_pack_real_int32(x, d);
514
+ #else
515
+ msgpack_pack_real_int64(x, d);
516
+ #endif
517
+
518
+ #else
519
+ if(sizeof(long long) == 2) {
520
+ msgpack_pack_real_int16(x, d);
521
+ } else if(sizeof(long long) == 4) {
522
+ msgpack_pack_real_int32(x, d);
523
+ } else {
524
+ msgpack_pack_real_int64(x, d);
525
+ }
526
+ #endif
527
+ }
528
+
529
+ msgpack_pack_inline_func_cint(_unsigned_short)(msgpack_pack_user x, unsigned short d)
530
+ {
531
+ #if defined(SIZEOF_SHORT)
532
+ #if SIZEOF_SHORT == 2
533
+ msgpack_pack_real_uint16(x, d);
534
+ #elif SIZEOF_SHORT == 4
535
+ msgpack_pack_real_uint32(x, d);
536
+ #else
537
+ msgpack_pack_real_uint64(x, d);
538
+ #endif
539
+
540
+ #elif defined(USHRT_MAX)
541
+ #if USHRT_MAX == 0xffffU
542
+ msgpack_pack_real_uint16(x, d);
543
+ #elif USHRT_MAX == 0xffffffffU
544
+ msgpack_pack_real_uint32(x, d);
545
+ #else
546
+ msgpack_pack_real_uint64(x, d);
547
+ #endif
548
+
549
+ #else
550
+ if(sizeof(unsigned short) == 2) {
551
+ msgpack_pack_real_uint16(x, d);
552
+ } else if(sizeof(unsigned short) == 4) {
553
+ msgpack_pack_real_uint32(x, d);
554
+ } else {
555
+ msgpack_pack_real_uint64(x, d);
556
+ }
557
+ #endif
558
+ }
559
+
560
+ msgpack_pack_inline_func_cint(_unsigned_int)(msgpack_pack_user x, unsigned int d)
561
+ {
562
+ #if defined(SIZEOF_INT)
563
+ #if SIZEOF_INT == 2
564
+ msgpack_pack_real_uint16(x, d);
565
+ #elif SIZEOF_INT == 4
566
+ msgpack_pack_real_uint32(x, d);
567
+ #else
568
+ msgpack_pack_real_uint64(x, d);
569
+ #endif
570
+
571
+ #elif defined(UINT_MAX)
572
+ #if UINT_MAX == 0xffffU
573
+ msgpack_pack_real_uint16(x, d);
574
+ #elif UINT_MAX == 0xffffffffU
575
+ msgpack_pack_real_uint32(x, d);
576
+ #else
577
+ msgpack_pack_real_uint64(x, d);
578
+ #endif
579
+
580
+ #else
581
+ if(sizeof(unsigned int) == 2) {
582
+ msgpack_pack_real_uint16(x, d);
583
+ } else if(sizeof(unsigned int) == 4) {
584
+ msgpack_pack_real_uint32(x, d);
585
+ } else {
586
+ msgpack_pack_real_uint64(x, d);
587
+ }
588
+ #endif
589
+ }
590
+
591
+ msgpack_pack_inline_func_cint(_unsigned_long)(msgpack_pack_user x, unsigned long d)
592
+ {
593
+ #if defined(SIZEOF_LONG)
594
+ #if SIZEOF_LONG == 2
595
+ msgpack_pack_real_uint16(x, d);
596
+ #elif SIZEOF_LONG == 4
597
+ msgpack_pack_real_uint32(x, d);
598
+ #else
599
+ msgpack_pack_real_uint64(x, d);
600
+ #endif
601
+
602
+ #elif defined(ULONG_MAX)
603
+ #if ULONG_MAX == 0xffffUL
604
+ msgpack_pack_real_uint16(x, d);
605
+ #elif ULONG_MAX == 0xffffffffUL
606
+ msgpack_pack_real_uint32(x, d);
607
+ #else
608
+ msgpack_pack_real_uint64(x, d);
609
+ #endif
610
+
611
+ #else
612
+ if(sizeof(unsigned long) == 2) {
613
+ msgpack_pack_real_uint16(x, d);
614
+ } else if(sizeof(unsigned long) == 4) {
615
+ msgpack_pack_real_uint32(x, d);
616
+ } else {
617
+ msgpack_pack_real_uint64(x, d);
618
+ }
619
+ #endif
620
+ }
621
+
622
+ msgpack_pack_inline_func_cint(_unsigned_long_long)(msgpack_pack_user x, unsigned long long d)
623
+ {
624
+ #if defined(SIZEOF_LONG_LONG)
625
+ #if SIZEOF_LONG_LONG == 2
626
+ msgpack_pack_real_uint16(x, d);
627
+ #elif SIZEOF_LONG_LONG == 4
628
+ msgpack_pack_real_uint32(x, d);
629
+ #else
630
+ msgpack_pack_real_uint64(x, d);
631
+ #endif
632
+
633
+ #elif defined(ULLONG_MAX)
634
+ #if ULLONG_MAX == 0xffffUL
635
+ msgpack_pack_real_uint16(x, d);
636
+ #elif ULLONG_MAX == 0xffffffffUL
637
+ msgpack_pack_real_uint32(x, d);
638
+ #else
639
+ msgpack_pack_real_uint64(x, d);
640
+ #endif
641
+
642
+ #else
643
+ if(sizeof(unsigned long long) == 2) {
644
+ msgpack_pack_real_uint16(x, d);
645
+ } else if(sizeof(unsigned long long) == 4) {
646
+ msgpack_pack_real_uint32(x, d);
647
+ } else {
648
+ msgpack_pack_real_uint64(x, d);
649
+ }
650
+ #endif
651
+ }
652
+
653
+ #undef msgpack_pack_inline_func_cint
654
+ #endif
655
+
656
+
657
+
658
+ /*
659
+ * Float
660
+ */
661
+
662
+ msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
663
+ {
664
+ unsigned char buf[5];
665
+ union { float f; uint32_t i; } mem;
666
+ mem.f = d;
667
+ buf[0] = 0xca; _msgpack_store32(&buf[1], mem.i);
668
+ msgpack_pack_append_buffer(x, buf, 5);
669
+ }
670
+
671
+ msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
672
+ {
673
+ unsigned char buf[9];
674
+ union { double f; uint64_t i; } mem;
675
+ mem.f = d;
676
+ buf[0] = 0xcb;
677
+ #if defined(TARGET_OS_IPHONE)
678
+ // ok
679
+ #elif defined(__arm__) && !(__ARM_EABI__) // arm-oabi
680
+ // https://github.com/msgpack/msgpack-perl/pull/1
681
+ mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
682
+ #endif
683
+ _msgpack_store64(&buf[1], mem.i);
684
+ msgpack_pack_append_buffer(x, buf, 9);
685
+ }
686
+
687
+
688
+ /*
689
+ * Nil
690
+ */
691
+
692
+ msgpack_pack_inline_func(_nil)(msgpack_pack_user x)
693
+ {
694
+ static const unsigned char d = 0xc0;
695
+ msgpack_pack_append_buffer(x, &d, 1);
696
+ }
697
+
698
+
699
+ /*
700
+ * Boolean
701
+ */
702
+
703
+ msgpack_pack_inline_func(_true)(msgpack_pack_user x)
704
+ {
705
+ static const unsigned char d = 0xc3;
706
+ msgpack_pack_append_buffer(x, &d, 1);
707
+ }
708
+
709
+ msgpack_pack_inline_func(_false)(msgpack_pack_user x)
710
+ {
711
+ static const unsigned char d = 0xc2;
712
+ msgpack_pack_append_buffer(x, &d, 1);
713
+ }
714
+
715
+
716
+ /*
717
+ * Array
718
+ */
719
+
720
+ msgpack_pack_inline_func(_array)(msgpack_pack_user x, size_t n)
721
+ {
722
+ if(n < 16) {
723
+ unsigned char d = 0x90 | (uint8_t)n;
724
+ msgpack_pack_append_buffer(x, &d, 1);
725
+ } else if(n < 65536) {
726
+ unsigned char buf[3];
727
+ buf[0] = 0xdc; _msgpack_store16(&buf[1], (uint16_t)n);
728
+ msgpack_pack_append_buffer(x, buf, 3);
729
+ } else {
730
+ unsigned char buf[5];
731
+ buf[0] = 0xdd; _msgpack_store32(&buf[1], (uint32_t)n);
732
+ msgpack_pack_append_buffer(x, buf, 5);
733
+ }
734
+ }
735
+
736
+
737
+ /*
738
+ * Map
739
+ */
740
+
741
+ msgpack_pack_inline_func(_map)(msgpack_pack_user x, size_t n)
742
+ {
743
+ if(n < 16) {
744
+ unsigned char d = 0x80 | (uint8_t)n;
745
+ msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
746
+ } else if(n < 65536) {
747
+ unsigned char buf[3];
748
+ buf[0] = 0xde; _msgpack_store16(&buf[1], (uint16_t)n);
749
+ msgpack_pack_append_buffer(x, buf, 3);
750
+ } else {
751
+ unsigned char buf[5];
752
+ buf[0] = 0xdf; _msgpack_store32(&buf[1], (uint32_t)n);
753
+ msgpack_pack_append_buffer(x, buf, 5);
754
+ }
755
+ }
756
+
757
+
758
+ /*
759
+ * Str
760
+ */
761
+
762
+ msgpack_pack_inline_func(_str)(msgpack_pack_user x, size_t l)
763
+ {
764
+ if(l < 32) {
765
+ unsigned char d = 0xa0 | (uint8_t)l;
766
+ msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
767
+ } else if(l < 256) {
768
+ unsigned char buf[2];
769
+ buf[0] = 0xd9; buf[1] = (uint8_t)l;
770
+ msgpack_pack_append_buffer(x, buf, 2);
771
+ } else if(l < 65536) {
772
+ unsigned char buf[3];
773
+ buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
774
+ msgpack_pack_append_buffer(x, buf, 3);
775
+ } else {
776
+ unsigned char buf[5];
777
+ buf[0] = 0xdb; _msgpack_store32(&buf[1], (uint32_t)l);
778
+ msgpack_pack_append_buffer(x, buf, 5);
779
+ }
780
+ }
781
+
782
+ msgpack_pack_inline_func(_str_body)(msgpack_pack_user x, const void* b, size_t l)
783
+ {
784
+ msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
785
+ }
786
+
787
+ /*
788
+ * Raw (V4)
789
+ */
790
+
791
+ msgpack_pack_inline_func(_v4raw)(msgpack_pack_user x, size_t l)
792
+ {
793
+ if(l < 32) {
794
+ unsigned char d = 0xa0 | (uint8_t)l;
795
+ msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
796
+ } else if(l < 65536) {
797
+ unsigned char buf[3];
798
+ buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
799
+ msgpack_pack_append_buffer(x, buf, 3);
800
+ } else {
801
+ unsigned char buf[5];
802
+ buf[0] = 0xdb; _msgpack_store32(&buf[1], (uint32_t)l);
803
+ msgpack_pack_append_buffer(x, buf, 5);
804
+ }
805
+ }
806
+
807
+ msgpack_pack_inline_func(_v4raw_body)(msgpack_pack_user x, const void* b, size_t l)
808
+ {
809
+ msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
810
+ }
811
+
812
+ /*
813
+ * Bin
814
+ */
815
+
816
+ msgpack_pack_inline_func(_bin)(msgpack_pack_user x, size_t l)
817
+ {
818
+ if(l < 256) {
819
+ unsigned char buf[2];
820
+ buf[0] = 0xc4; buf[1] = (uint8_t)l;
821
+ msgpack_pack_append_buffer(x, buf, 2);
822
+ } else if(l < 65536) {
823
+ unsigned char buf[3];
824
+ buf[0] = 0xc5; _msgpack_store16(&buf[1], (uint16_t)l);
825
+ msgpack_pack_append_buffer(x, buf, 3);
826
+ } else {
827
+ unsigned char buf[5];
828
+ buf[0] = 0xc6; _msgpack_store32(&buf[1], (uint32_t)l);
829
+ msgpack_pack_append_buffer(x, buf, 5);
830
+ }
831
+ }
832
+
833
+ msgpack_pack_inline_func(_bin_body)(msgpack_pack_user x, const void* b, size_t l)
834
+ {
835
+ msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
836
+ }
837
+
838
+ /*
839
+ * Ext
840
+ */
841
+
842
+ msgpack_pack_inline_func(_ext)(msgpack_pack_user x, size_t l, int8_t type)
843
+ {
844
+ switch(l) {
845
+ case 1: {
846
+ unsigned char buf[2];
847
+ buf[0] = 0xd4;
848
+ buf[1] = (unsigned char)type;
849
+ msgpack_pack_append_buffer(x, buf, 2);
850
+ } break;
851
+ case 2: {
852
+ unsigned char buf[2];
853
+ buf[0] = 0xd5;
854
+ buf[1] = (unsigned char)type;
855
+ msgpack_pack_append_buffer(x, buf, 2);
856
+ } break;
857
+ case 4: {
858
+ unsigned char buf[2];
859
+ buf[0] = 0xd6;
860
+ buf[1] = (unsigned char)type;
861
+ msgpack_pack_append_buffer(x, buf, 2);
862
+ } break;
863
+ case 8: {
864
+ unsigned char buf[2];
865
+ buf[0] = 0xd7;
866
+ buf[1] = (unsigned char)type;
867
+ msgpack_pack_append_buffer(x, buf, 2);
868
+ } break;
869
+ case 16: {
870
+ unsigned char buf[2];
871
+ buf[0] = 0xd8;
872
+ buf[1] = (unsigned char)type;
873
+ msgpack_pack_append_buffer(x, buf, 2);
874
+ } break;
875
+ default:
876
+ if(l < 256) {
877
+ unsigned char buf[3];
878
+ buf[0] = 0xc7;
879
+ buf[1] = (unsigned char)l;
880
+ buf[2] = (unsigned char)type;
881
+ msgpack_pack_append_buffer(x, buf, 3);
882
+ } else if(l < 65536) {
883
+ unsigned char buf[4];
884
+ buf[0] = 0xc8;
885
+ _msgpack_store16(&buf[1], l);
886
+ buf[3] = (unsigned char)type;
887
+ msgpack_pack_append_buffer(x, buf, 4);
888
+ } else {
889
+ unsigned char buf[6];
890
+ buf[0] = 0xc9;
891
+ _msgpack_store32(&buf[1], l);
892
+ buf[5] = (unsigned char)type;
893
+ msgpack_pack_append_buffer(x, buf, 6);
894
+ }
895
+ break;
896
+ }
897
+ }
898
+
899
+ msgpack_pack_inline_func(_ext_body)(msgpack_pack_user x, const void* b, size_t l)
900
+ {
901
+ msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
902
+ }
903
+
904
+ msgpack_pack_inline_func(_timestamp)(msgpack_pack_user x, const msgpack_timestamp* d)
905
+ {
906
+ if ((((int64_t)d->tv_sec) >> 34) == 0) {
907
+ uint64_t data64 = ((uint64_t) d->tv_nsec << 34) | (uint64_t)d->tv_sec;
908
+ if ((data64 & 0xffffffff00000000L) == 0) {
909
+ // timestamp 32
910
+ char buf[4];
911
+ uint32_t data32 = (uint32_t)data64;
912
+ msgpack_pack_ext(x, 4, -1);
913
+ _msgpack_store32(buf, data32);
914
+ msgpack_pack_append_buffer(x, buf, 4);
915
+ } else {
916
+ // timestamp 64
917
+ char buf[8];
918
+ msgpack_pack_ext(x, 8, -1);
919
+ _msgpack_store64(buf, data64);
920
+ msgpack_pack_append_buffer(x, buf, 8);
921
+ }
922
+ } else {
923
+ // timestamp 96
924
+ char buf[12];
925
+ _msgpack_store32(&buf[0], d->tv_nsec);
926
+ _msgpack_store64(&buf[4], d->tv_sec);
927
+ msgpack_pack_ext(x, 12, -1);
928
+ msgpack_pack_append_buffer(x, buf, 12);
929
+ }
930
+ }
931
+
932
+ #undef msgpack_pack_inline_func
933
+ #undef msgpack_pack_user
934
+ #undef msgpack_pack_append_buffer
935
+
936
+ #undef TAKE8_8
937
+ #undef TAKE8_16
938
+ #undef TAKE8_32
939
+ #undef TAKE8_64
940
+
941
+ #undef msgpack_pack_real_uint8
942
+ #undef msgpack_pack_real_uint16
943
+ #undef msgpack_pack_real_uint32
944
+ #undef msgpack_pack_real_uint64
945
+ #undef msgpack_pack_real_int8
946
+ #undef msgpack_pack_real_int16
947
+ #undef msgpack_pack_real_int32
948
+ #undef msgpack_pack_real_int64
949
+
950
+ #if defined(_MSC_VER)
951
+ # pragma warning(pop)
952
+ #endif