msgpack 0.6.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +26 -0
- data/ChangeLog +129 -0
- data/Dockerfile +62 -0
- data/LICENSE +177 -0
- data/README.rdoc +141 -0
- data/Rakefile +68 -0
- data/bench/pack.rb +23 -0
- data/bench/pack_log.rb +33 -0
- data/bench/pack_log_long.rb +65 -0
- data/bench/run.sh +14 -0
- data/bench/run_long.sh +35 -0
- data/bench/unpack.rb +21 -0
- data/bench/unpack_log.rb +34 -0
- data/bench/unpack_log_long.rb +67 -0
- data/doclib/msgpack.rb +77 -0
- data/doclib/msgpack/buffer.rb +193 -0
- data/doclib/msgpack/core_ext.rb +101 -0
- data/doclib/msgpack/error.rb +14 -0
- data/doclib/msgpack/packer.rb +134 -0
- data/doclib/msgpack/unpacker.rb +146 -0
- data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
- data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
- data/ext/java/org/msgpack/jruby/Encoder.java +308 -0
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
- data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +107 -0
- data/ext/java/org/msgpack/jruby/Packer.java +78 -0
- data/ext/java/org/msgpack/jruby/Types.java +37 -0
- data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
- data/ext/msgpack/buffer.c +695 -0
- data/ext/msgpack/buffer.h +447 -0
- data/ext/msgpack/buffer_class.c +507 -0
- data/ext/msgpack/buffer_class.h +32 -0
- data/ext/msgpack/compat.h +114 -0
- data/ext/msgpack/core_ext.c +129 -0
- data/ext/msgpack/core_ext.h +26 -0
- data/ext/msgpack/extconf.rb +30 -0
- data/ext/msgpack/packer.c +168 -0
- data/ext/msgpack/packer.h +441 -0
- data/ext/msgpack/packer_class.c +302 -0
- data/ext/msgpack/packer_class.h +30 -0
- data/ext/msgpack/rbinit.c +33 -0
- data/ext/msgpack/rmem.c +94 -0
- data/ext/msgpack/rmem.h +109 -0
- data/ext/msgpack/sysdep.h +115 -0
- data/ext/msgpack/sysdep_endian.h +50 -0
- data/ext/msgpack/sysdep_types.h +46 -0
- data/ext/msgpack/unpacker.c +771 -0
- data/ext/msgpack/unpacker.h +122 -0
- data/ext/msgpack/unpacker_class.c +405 -0
- data/ext/msgpack/unpacker_class.h +32 -0
- data/lib/msgpack.rb +13 -0
- data/lib/msgpack/version.rb +3 -0
- data/msgpack.gemspec +31 -0
- data/msgpack.org.md +46 -0
- data/spec/cases.json +1 -0
- data/spec/cases.msg +0 -0
- data/spec/cases_compact.msg +0 -0
- data/spec/cases_spec.rb +39 -0
- data/spec/cruby/buffer_io_spec.rb +256 -0
- data/spec/cruby/buffer_packer.rb +29 -0
- data/spec/cruby/buffer_spec.rb +572 -0
- data/spec/cruby/buffer_unpacker.rb +19 -0
- data/spec/cruby/packer_spec.rb +120 -0
- data/spec/cruby/unpacker_spec.rb +305 -0
- data/spec/format_spec.rb +282 -0
- data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
- data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
- data/spec/jruby/msgpack_spec.rb +142 -0
- data/spec/pack_spec.rb +67 -0
- data/spec/random_compat.rb +24 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/unpack_spec.rb +60 -0
- metadata +208 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
#ifndef MSGPACK_RUBY_PACKER_CLASS_H__
|
19
|
+
#define MSGPACK_RUBY_PACKER_CLASS_H__
|
20
|
+
|
21
|
+
#include "packer.h"
|
22
|
+
|
23
|
+
extern VALUE cMessagePack_Packer;
|
24
|
+
|
25
|
+
void MessagePack_Packer_module_init(VALUE mMessagePack);
|
26
|
+
|
27
|
+
VALUE MessagePack_pack(int argc, VALUE* argv);
|
28
|
+
|
29
|
+
#endif
|
30
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "buffer_class.h"
|
20
|
+
#include "packer_class.h"
|
21
|
+
#include "unpacker_class.h"
|
22
|
+
#include "core_ext.h"
|
23
|
+
|
24
|
+
void Init_msgpack(void)
|
25
|
+
{
|
26
|
+
VALUE mMessagePack = rb_define_module("MessagePack");
|
27
|
+
|
28
|
+
MessagePack_Buffer_module_init(mMessagePack);
|
29
|
+
MessagePack_Packer_module_init(mMessagePack);
|
30
|
+
MessagePack_Unpacker_module_init(mMessagePack);
|
31
|
+
MessagePack_core_ext_module_init();
|
32
|
+
}
|
33
|
+
|
data/ext/msgpack/rmem.c
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "rmem.h"
|
20
|
+
|
21
|
+
void msgpack_rmem_init(msgpack_rmem_t* pm)
|
22
|
+
{
|
23
|
+
memset(pm, 0, sizeof(msgpack_rmem_t));
|
24
|
+
pm->head.pages = malloc(MSGPACK_RMEM_PAGE_SIZE * 32);
|
25
|
+
pm->head.mask = 0xffffffff; /* all bit is 1 = available */
|
26
|
+
}
|
27
|
+
|
28
|
+
void msgpack_rmem_destroy(msgpack_rmem_t* pm)
|
29
|
+
{
|
30
|
+
msgpack_rmem_chunk_t* c = pm->array_first;
|
31
|
+
msgpack_rmem_chunk_t* cend = pm->array_last;
|
32
|
+
for(; c != cend; c++) {
|
33
|
+
free(c->pages);
|
34
|
+
}
|
35
|
+
free(pm->head.pages);
|
36
|
+
free(pm->array_first);
|
37
|
+
}
|
38
|
+
|
39
|
+
void* _msgpack_rmem_alloc2(msgpack_rmem_t* pm)
|
40
|
+
{
|
41
|
+
msgpack_rmem_chunk_t* c = pm->array_first;
|
42
|
+
msgpack_rmem_chunk_t* last = pm->array_last;
|
43
|
+
for(; c != last; c++) {
|
44
|
+
if(_msgpack_rmem_chunk_available(c)) {
|
45
|
+
void* mem = _msgpack_rmem_chunk_alloc(c);
|
46
|
+
|
47
|
+
/* move to head */
|
48
|
+
msgpack_rmem_chunk_t tmp = pm->head;
|
49
|
+
pm->head = *c;
|
50
|
+
*c = tmp;
|
51
|
+
return mem;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
if(c == pm->array_end) {
|
56
|
+
size_t capacity = c - pm->array_first;
|
57
|
+
size_t length = last - pm->array_first;
|
58
|
+
capacity = (capacity == 0) ? 8 : capacity * 2;
|
59
|
+
msgpack_rmem_chunk_t* array = realloc(pm->array_first, capacity * sizeof(msgpack_rmem_chunk_t));
|
60
|
+
pm->array_first = array;
|
61
|
+
pm->array_last = array + length;
|
62
|
+
pm->array_end = array + capacity;
|
63
|
+
}
|
64
|
+
|
65
|
+
/* allocate new chunk */
|
66
|
+
c = pm->array_last++;
|
67
|
+
|
68
|
+
/* move to head */
|
69
|
+
msgpack_rmem_chunk_t tmp = pm->head;
|
70
|
+
pm->head = *c;
|
71
|
+
*c = tmp;
|
72
|
+
|
73
|
+
pm->head.mask = 0xffffffff & (~1); /* "& (~1)" means first chunk is already allocated */
|
74
|
+
pm->head.pages = malloc(MSGPACK_RMEM_PAGE_SIZE * 32);
|
75
|
+
|
76
|
+
return pm->head.pages;
|
77
|
+
}
|
78
|
+
|
79
|
+
void _msgpack_rmem_chunk_free(msgpack_rmem_t* pm, msgpack_rmem_chunk_t* c)
|
80
|
+
{
|
81
|
+
if(pm->array_first->mask == 0xffffffff) {
|
82
|
+
/* free and move to last */
|
83
|
+
pm->array_last--;
|
84
|
+
free(c->pages);
|
85
|
+
*c = *pm->array_last;
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
|
89
|
+
/* move to first */
|
90
|
+
msgpack_rmem_chunk_t tmp = *pm->array_first;
|
91
|
+
*pm->array_first = *c;
|
92
|
+
*c = tmp;
|
93
|
+
}
|
94
|
+
|
data/ext/msgpack/rmem.h
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
#ifndef MSGPACK_RUBY_RMEM_H__
|
19
|
+
#define MSGPACK_RUBY_RMEM_H__
|
20
|
+
|
21
|
+
#include "compat.h"
|
22
|
+
#include "sysdep.h"
|
23
|
+
|
24
|
+
#ifndef MSGPACK_RMEM_PAGE_SIZE
|
25
|
+
#define MSGPACK_RMEM_PAGE_SIZE (4*1024)
|
26
|
+
#endif
|
27
|
+
|
28
|
+
struct msgpack_rmem_t;
|
29
|
+
typedef struct msgpack_rmem_t msgpack_rmem_t;
|
30
|
+
|
31
|
+
struct msgpack_rmem_chunk_t;
|
32
|
+
typedef struct msgpack_rmem_chunk_t msgpack_rmem_chunk_t;
|
33
|
+
|
34
|
+
/*
|
35
|
+
* a chunk contains 32 pages.
|
36
|
+
* size of each buffer is MSGPACK_RMEM_PAGE_SIZE bytes.
|
37
|
+
*/
|
38
|
+
struct msgpack_rmem_chunk_t {
|
39
|
+
unsigned int mask;
|
40
|
+
char* pages;
|
41
|
+
};
|
42
|
+
|
43
|
+
struct msgpack_rmem_t {
|
44
|
+
msgpack_rmem_chunk_t head;
|
45
|
+
msgpack_rmem_chunk_t* array_first;
|
46
|
+
msgpack_rmem_chunk_t* array_last;
|
47
|
+
msgpack_rmem_chunk_t* array_end;
|
48
|
+
};
|
49
|
+
|
50
|
+
/* assert MSGPACK_RMEM_PAGE_SIZE % sysconf(_SC_PAGE_SIZE) == 0 */
|
51
|
+
void msgpack_rmem_init(msgpack_rmem_t* pm);
|
52
|
+
|
53
|
+
void msgpack_rmem_destroy(msgpack_rmem_t* pm);
|
54
|
+
|
55
|
+
void* _msgpack_rmem_alloc2(msgpack_rmem_t* pm);
|
56
|
+
|
57
|
+
#define _msgpack_rmem_chunk_available(c) ((c)->mask != 0)
|
58
|
+
|
59
|
+
static inline void* _msgpack_rmem_chunk_alloc(msgpack_rmem_chunk_t* c)
|
60
|
+
{
|
61
|
+
_msgpack_bsp32(pos, c->mask);
|
62
|
+
(c)->mask &= ~(1 << pos);
|
63
|
+
return ((char*)(c)->pages) + (pos * (MSGPACK_RMEM_PAGE_SIZE));
|
64
|
+
}
|
65
|
+
|
66
|
+
static inline bool _msgpack_rmem_chunk_try_free(msgpack_rmem_chunk_t* c, void* mem)
|
67
|
+
{
|
68
|
+
ptrdiff_t pdiff = ((char*)(mem)) - ((char*)(c)->pages);
|
69
|
+
if(0 <= pdiff && pdiff < MSGPACK_RMEM_PAGE_SIZE * 32) {
|
70
|
+
size_t pos = pdiff / MSGPACK_RMEM_PAGE_SIZE;
|
71
|
+
(c)->mask |= (1 << pos);
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
|
77
|
+
static inline void* msgpack_rmem_alloc(msgpack_rmem_t* pm)
|
78
|
+
{
|
79
|
+
if(_msgpack_rmem_chunk_available(&pm->head)) {
|
80
|
+
return _msgpack_rmem_chunk_alloc(&pm->head);
|
81
|
+
}
|
82
|
+
return _msgpack_rmem_alloc2(pm);
|
83
|
+
}
|
84
|
+
|
85
|
+
void _msgpack_rmem_chunk_free(msgpack_rmem_t* pm, msgpack_rmem_chunk_t* c);
|
86
|
+
|
87
|
+
static inline bool msgpack_rmem_free(msgpack_rmem_t* pm, void* mem)
|
88
|
+
{
|
89
|
+
if(_msgpack_rmem_chunk_try_free(&pm->head, mem)) {
|
90
|
+
return true;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* search from last */
|
94
|
+
msgpack_rmem_chunk_t* c = pm->array_last - 1;
|
95
|
+
msgpack_rmem_chunk_t* before_first = pm->array_first - 1;
|
96
|
+
for(; c != before_first; c--) {
|
97
|
+
if(_msgpack_rmem_chunk_try_free(c, mem)) {
|
98
|
+
if(c != pm->array_first && c->mask == 0xffffffff) {
|
99
|
+
_msgpack_rmem_chunk_free(pm, c);
|
100
|
+
}
|
101
|
+
return true;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return false;
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
#endif
|
109
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
#ifndef MSGPACK_RUBY_SYSDEP_H__
|
19
|
+
#define MSGPACK_RUBY_SYSDEP_H__
|
20
|
+
|
21
|
+
#include "sysdep_types.h"
|
22
|
+
#include "sysdep_endian.h"
|
23
|
+
|
24
|
+
|
25
|
+
#define UNUSED(var) ((void)var)
|
26
|
+
|
27
|
+
|
28
|
+
#ifdef __LITTLE_ENDIAN__
|
29
|
+
|
30
|
+
/* _msgpack_be16 */
|
31
|
+
#ifdef _WIN32
|
32
|
+
# if defined(ntohs)
|
33
|
+
# define _msgpack_be16(x) ntohs(x)
|
34
|
+
# elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
35
|
+
# define _msgpack_be16(x) ((uint16_t)_byteswap_ushort((unsigned short)x))
|
36
|
+
# else
|
37
|
+
# define _msgpack_be16(x) ( \
|
38
|
+
((((uint16_t)x) << 8) ) | \
|
39
|
+
((((uint16_t)x) >> 8) ) )
|
40
|
+
# endif
|
41
|
+
#else
|
42
|
+
# define _msgpack_be16(x) ntohs(x)
|
43
|
+
#endif
|
44
|
+
|
45
|
+
/* _msgpack_be32 */
|
46
|
+
#ifdef _WIN32
|
47
|
+
# if defined(ntohl)
|
48
|
+
# define _msgpack_be32(x) ntohl(x)
|
49
|
+
# elif defined(_byteswap_ulong) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
50
|
+
# define _msgpack_be32(x) ((uint32_t)_byteswap_ulong((unsigned long)x))
|
51
|
+
# else
|
52
|
+
# define _msgpack_be32(x) \
|
53
|
+
( ((((uint32_t)x) << 24) ) | \
|
54
|
+
((((uint32_t)x) << 8) & 0x00ff0000U ) | \
|
55
|
+
((((uint32_t)x) >> 8) & 0x0000ff00U ) | \
|
56
|
+
((((uint32_t)x) >> 24) ) )
|
57
|
+
# endif
|
58
|
+
#else
|
59
|
+
# define _msgpack_be32(x) ntohl(x)
|
60
|
+
#endif
|
61
|
+
|
62
|
+
/* _msgpack_be64 */
|
63
|
+
#if defined(_byteswap_uint64) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
64
|
+
# define _msgpack_be64(x) (_byteswap_uint64(x))
|
65
|
+
#elif defined(bswap_64)
|
66
|
+
# define _msgpack_be64(x) bswap_64(x)
|
67
|
+
#elif defined(__DARWIN_OSSwapInt64)
|
68
|
+
# define _msgpack_be64(x) __DARWIN_OSSwapInt64(x)
|
69
|
+
#else
|
70
|
+
#define _msgpack_be64(x) \
|
71
|
+
( ((((uint64_t)x) << 56) ) | \
|
72
|
+
((((uint64_t)x) << 40) & 0x00ff000000000000ULL ) | \
|
73
|
+
((((uint64_t)x) << 24) & 0x0000ff0000000000ULL ) | \
|
74
|
+
((((uint64_t)x) << 8) & 0x000000ff00000000ULL ) | \
|
75
|
+
((((uint64_t)x) >> 8) & 0x00000000ff000000ULL ) | \
|
76
|
+
((((uint64_t)x) >> 24) & 0x0000000000ff0000ULL ) | \
|
77
|
+
((((uint64_t)x) >> 40) & 0x000000000000ff00ULL ) | \
|
78
|
+
((((uint64_t)x) >> 56) ) )
|
79
|
+
#endif
|
80
|
+
|
81
|
+
#else /* big endian */
|
82
|
+
#define _msgpack_be16(x) (x)
|
83
|
+
#define _msgpack_be32(x) (x)
|
84
|
+
#define _msgpack_be64(x) (x)
|
85
|
+
|
86
|
+
#endif
|
87
|
+
|
88
|
+
|
89
|
+
/* _msgpack_be_float */
|
90
|
+
#define _msgpack_be_float(x) _msgpack_be32(x)
|
91
|
+
|
92
|
+
/* _msgpack_be_double */
|
93
|
+
#if defined(__arm__) && !(__ARM_EABI__)
|
94
|
+
/* ARM OABI */
|
95
|
+
#define _msgpack_be_double(x) \
|
96
|
+
( (((x) & 0xFFFFFFFFUL) << 32UL) | ((x) >> 32UL) )
|
97
|
+
#else
|
98
|
+
/* the other ABI */
|
99
|
+
#define _msgpack_be_double(x) _msgpack_be64(x)
|
100
|
+
#endif
|
101
|
+
|
102
|
+
/* _msgpack_bsp32 */
|
103
|
+
#if defined(_MSC_VER)
|
104
|
+
#define _msgpack_bsp32(name, val) \
|
105
|
+
long name; \
|
106
|
+
_BitScanForward(&name, val)
|
107
|
+
#else
|
108
|
+
#define _msgpack_bsp32(name, val) \
|
109
|
+
int name = __builtin_ctz(val)
|
110
|
+
/* TODO default impl for _msgpack_bsp32 */
|
111
|
+
#endif
|
112
|
+
|
113
|
+
|
114
|
+
#endif
|
115
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
#ifndef MSGPACK_RUBY_SYSDEP_ENDIAN_H__
|
19
|
+
#define MSGPACK_RUBY_SYSDEP_ENDIAN_H__
|
20
|
+
|
21
|
+
/* including arpa/inet.h requires an extra dll on win32 */
|
22
|
+
#ifndef _WIN32
|
23
|
+
#include <arpa/inet.h> /* __BYTE_ORDER */
|
24
|
+
#endif
|
25
|
+
|
26
|
+
/*
|
27
|
+
* Use following command to add consitions here:
|
28
|
+
* cpp -dM `echo "#include <arpa/inet.h>" > test.c; echo test.c` | grep ENDIAN
|
29
|
+
*/
|
30
|
+
#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) /* Mac OS X */
|
31
|
+
# if defined(_LITTLE_ENDIAN) \
|
32
|
+
|| ( defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) \
|
33
|
+
&& __BYTE_ORDER == __LITTLE_ENDIAN ) /* Linux */ \
|
34
|
+
|| ( defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) \
|
35
|
+
&& __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) /* Solaris */
|
36
|
+
# define __LITTLE_ENDIAN__
|
37
|
+
# elif defined(_BIG_ENDIAN) \
|
38
|
+
|| (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) \
|
39
|
+
&& __BYTE_ORDER == __BIG_ENDIAN) /* Linux */ \
|
40
|
+
|| (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) \
|
41
|
+
&& __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) /* Solaris */
|
42
|
+
# define __BIG_ENDIAN__
|
43
|
+
# elif defined(_WIN32) /* Win32 */
|
44
|
+
# define __LITTLE_ENDIAN__
|
45
|
+
# endif
|
46
|
+
#endif
|
47
|
+
|
48
|
+
|
49
|
+
#endif
|
50
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for Ruby
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2013 Sadayuki Furuhashi
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
*/
|
18
|
+
#ifndef MSGPACK_RUBY_SYSDEP_TYPES_H__
|
19
|
+
#define MSGPACK_RUBY_SYSDEP_TYPES_H__
|
20
|
+
|
21
|
+
#include <string.h>
|
22
|
+
#include <stdlib.h>
|
23
|
+
|
24
|
+
#include <stddef.h>
|
25
|
+
|
26
|
+
#if defined(_MSC_VER) && _MSC_VER < 1600
|
27
|
+
typedef __int8 int8_t;
|
28
|
+
typedef unsigned __int8 uint8_t;
|
29
|
+
typedef __int16 int16_t;
|
30
|
+
typedef unsigned __int16 uint16_t;
|
31
|
+
typedef __int32 int32_t;
|
32
|
+
typedef unsigned __int32 uint32_t;
|
33
|
+
typedef __int64 int64_t;
|
34
|
+
typedef unsigned __int64 uint64_t;
|
35
|
+
|
36
|
+
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
|
37
|
+
#include <stdint.h>
|
38
|
+
|
39
|
+
#else
|
40
|
+
#include <stdint.h>
|
41
|
+
#include <stdbool.h>
|
42
|
+
#endif
|
43
|
+
|
44
|
+
|
45
|
+
#endif
|
46
|
+
|