ox 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ox might be problematic. Click here for more details.

data/README.md CHANGED
@@ -20,7 +20,7 @@ A fast XML parser and Object marshaller as a Ruby gem.
20
20
 
21
21
  ## <a name="build_status">Build Status</a>
22
22
 
23
- [![Build Status](http://travis-ci.org/ohler55/ox.png)](http://travis-ci.org/ohler55/ox)
23
+ [![Build Status](https://secure.travis-ci.org/ohler55/ox.png?branch=master)](http://travis-ci.org/ohler55/ox)
24
24
 
25
25
  ## <a name="links">Links of Interest</a>
26
26
 
@@ -34,9 +34,9 @@ A fast XML parser and Object marshaller as a Ruby gem.
34
34
 
35
35
  ## <a name="release">Release Notes</a>
36
36
 
37
- ### Release 1.6.2
37
+ ### Release 1.6.3
38
38
 
39
- - Added check for Solaris and Linux builds to not use the timezone member of time struct (struct tm).
39
+ - Fixed compatibility issues with Linux (Ubuntu) mostly related to pointer sizes.
40
40
 
41
41
  ## <a name="description">Description</a>
42
42
 
@@ -8,29 +8,31 @@
8
8
  #include "ruby.h"
9
9
  #include "cache8.h"
10
10
 
11
- #define BITS 4
12
- #define MASK 0x000000000000000F
13
- #define SLOT_CNT 16
14
- #define DEPTH 16
11
+ #define BITS 4
12
+ #define MASK 0x000000000000000FULL
13
+ #define SLOT_CNT 16
14
+ #define DEPTH 16
15
+
16
+ typedef union {
17
+ struct _Cache8 *child;
18
+ slot_t value;
19
+ } Bucket;
15
20
 
16
21
  struct _Cache8 {
17
- union {
18
- struct _Cache8 *slots[SLOT_CNT];
19
- unsigned long values[SLOT_CNT];
20
- };
22
+ Bucket buckets[SLOT_CNT];
21
23
  };
22
24
 
23
- static void cache8_delete(Cache8 cache, int depth);
24
- static void slot_print(Cache8 cache, VALUE key, unsigned int depth);
25
+ static void cache8_delete(Cache8 cache, int depth);
26
+ static void slot_print(Cache8 cache, sid_t key, unsigned int depth);
25
27
 
26
28
  void
27
29
  ox_cache8_new(Cache8 *cache) {
28
- Cache8 *cp;
29
- int i;
30
+ Bucket *b;
31
+ int i;
30
32
 
31
33
  *cache = ALLOC(struct _Cache8);
32
- for (i = SLOT_CNT, cp = (*cache)->slots; 0 < i; i--, cp++) {
33
- *cp = 0;
34
+ for (i = SLOT_CNT, b = (*cache)->buckets; 0 < i; i--, b++) {
35
+ b->value = 0;
34
36
  }
35
37
  }
36
38
 
@@ -41,34 +43,35 @@ ox_cache8_delete(Cache8 cache) {
41
43
 
42
44
  static void
43
45
  cache8_delete(Cache8 cache, int depth) {
44
- Cache8 *cp;
45
- unsigned int i;
46
+ Bucket *b;
47
+ unsigned int i;
46
48
 
47
- for (i = 0, cp = cache->slots; i < SLOT_CNT; i++, cp++) {
48
- if (0 != *cp) {
49
- if (DEPTH - 1 != depth) {
50
- cache8_delete(*cp, depth + 1);
51
- }
52
- }
49
+ for (i = 0, b = cache->buckets; i < SLOT_CNT; i++, b++) {
50
+ if (0 != b->child) {
51
+ if (DEPTH - 1 != depth) {
52
+ cache8_delete(b->child, depth + 1);
53
+ }
54
+ }
53
55
  }
54
56
  xfree(cache);
55
57
  }
56
58
 
57
59
  slot_t
58
- ox_cache8_get(Cache8 cache, VALUE key, slot_t **slot) {
59
- Cache8 *cp;
60
- int i;
61
- VALUE k;
60
+ ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot) {
61
+ Bucket *b;
62
+ int i;
63
+ sid_t k8 = (sid_t)key;
64
+ sid_t k;
62
65
 
63
66
  for (i = 64 - BITS; 0 < i; i -= BITS) {
64
- k = (key >> i) & MASK;
65
- cp = cache->slots + k;
66
- if (0 == *cp) {
67
- ox_cache8_new(cp);
68
- }
69
- cache = *cp;
67
+ k = (k8 >> i) & MASK;
68
+ b = cache->buckets + k;
69
+ if (0 == b->child) {
70
+ ox_cache8_new(&b->child);
71
+ }
72
+ cache = b->child;
70
73
  }
71
- *slot = cache->values + (key & MASK);
74
+ *slot = &(cache->buckets + (k8 & MASK))->value;
72
75
 
73
76
  return **slot;
74
77
  }
@@ -80,20 +83,21 @@ ox_cache8_print(Cache8 cache) {
80
83
  }
81
84
 
82
85
  static void
83
- slot_print(Cache8 c, VALUE key, unsigned int depth) {
84
- Cache8 *cp;
85
- unsigned int i;
86
- unsigned long k;
86
+ slot_print(Cache8 c, sid_t key, unsigned int depth) {
87
+ Bucket *b;
88
+ unsigned int i;
89
+ sid_t k8 = (sid_t)key;
90
+ sid_t k;
87
91
 
88
- for (i = 0, cp = c->slots; i < SLOT_CNT; i++, cp++) {
89
- if (0 != *cp) {
90
- k = (key << BITS) | i;
91
- /*printf("*** key: 0x%016lx depth: %u i: %u\n", k, depth, i); */
92
- if (DEPTH - 1 == depth) {
93
- printf("0x%016lx: %4lu\n", k, (unsigned long)*cp);
94
- } else {
95
- slot_print(*cp, k, depth + 1);
96
- }
97
- }
92
+ for (i = 0, b = c->buckets; i < SLOT_CNT; i++, b++) {
93
+ if (0 != b->child) {
94
+ k = (k8 << BITS) | i;
95
+ /*printf("*** key: 0x%016llx depth: %u i: %u\n", k, depth, i); */
96
+ if (DEPTH - 1 == depth) {
97
+ printf("0x%016llx: %4llu\n", k, b->value);
98
+ } else {
99
+ slot_print(b->child, k, depth + 1);
100
+ }
101
+ }
98
102
  }
99
103
  }
@@ -32,15 +32,17 @@
32
32
  #define __OX_CACHE8_H__
33
33
 
34
34
  #include "ruby.h"
35
+ #include "stdint.h"
35
36
 
36
- typedef struct _Cache8 *Cache8;
37
- typedef unsigned long slot_t;
37
+ typedef struct _Cache8 *Cache8;
38
+ typedef uint64_t slot_t;
39
+ typedef uint64_t sid_t;
38
40
 
39
- extern void ox_cache8_new(Cache8 *cache);
40
- extern void ox_cache8_delete(Cache8 cache);
41
+ extern void ox_cache8_new(Cache8 *cache);
42
+ extern void ox_cache8_delete(Cache8 cache);
41
43
 
42
- extern slot_t ox_cache8_get(Cache8 cache, VALUE key, slot_t **slot);
44
+ extern slot_t ox_cache8_get(Cache8 cache, sid_t key, slot_t **slot);
43
45
 
44
- extern void ox_cache8_print(Cache8 cache);
46
+ extern void ox_cache8_print(Cache8 cache);
45
47
 
46
48
  #endif /* __OX_CACHE8_H__ */
@@ -32,13 +32,13 @@
32
32
  #include "cache8.h"
33
33
 
34
34
  static slot_t data[] = {
35
- 0x000000A0A0A0A0A0UL,
36
- 0x0000000000ABCDEFUL,
37
- 0x0123456789ABCDEFUL,
38
- 0x0000000000000001UL,
39
- 0x0000000000000002UL,
40
- 0x0000000000000003UL,
41
- 0x0000000000000004UL,
35
+ 0x000000A0A0A0A0A0ULL,
36
+ 0x0000000000ABCDEFULL,
37
+ 0x0123456789ABCDEFULL,
38
+ 0x0000000000000001ULL,
39
+ 0x0000000000000002ULL,
40
+ 0x0000000000000003ULL,
41
+ 0x0000000000000004ULL,
42
42
  0
43
43
  };
44
44
 
@@ -55,13 +55,13 @@ ox_cache8_test() {
55
55
  v = ox_cache8_get(c, *d, &slot);
56
56
  if (0 == v) {
57
57
  if (0 == slot) {
58
- printf("*** failed to get a slot for 0x%016lx\n", *d);
58
+ printf("*** failed to get a slot for 0x%016llx\n", *d);
59
59
  } else {
60
- printf("*** adding 0x%016lx to cache with value %lu\n", *d, cnt);
60
+ printf("*** adding 0x%016llx to cache with value %llu\n", *d, cnt);
61
61
  *slot = cnt++;
62
62
  }
63
63
  } else {
64
- printf("*** get on 0x%016lx returned %lu\n", *d, v);
64
+ printf("*** get on 0x%016llx returned %llu\n", *d, v);
65
65
  }
66
66
  /*ox_cache8_print(c); */
67
67
  }
@@ -229,9 +229,9 @@ ulong2str(ulong num, char *end) {
229
229
 
230
230
  static int
231
231
  check_circular(Out out, VALUE obj, Element e) {
232
- ulong *slot;
233
- ulong id;
234
- int result;
232
+ slot_t *slot;
233
+ slot_t id;
234
+ int result;
235
235
 
236
236
  if (0 == (id = ox_cache8_get(out->circ_cache, obj, &slot))) {
237
237
  out->circ_cnt++;
@@ -16,7 +16,7 @@ module Ox
16
16
  # @param [Object] other Object to compare _self_ to.
17
17
  def eql?(other)
18
18
  return false if (other.nil? or self.class != other.class)
19
- other.value == @value
19
+ other.value == self.value
20
20
  end
21
21
  alias == eql?
22
22
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.6.2'
4
+ VERSION = '1.6.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-07 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! "A fast XML parser and object serializer that uses only standard C
15
15
  lib.\n \nOptimized XML (Ox), as the name implies was written to provide