bson 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 248b3e8738a02655d62fc2563e2d5e84afc22df0
4
- data.tar.gz: 1dee4f08bd2f3b9790c930b8a9828b0498f6c290
3
+ metadata.gz: 1d8b033ffe340fc96c7b66aaf19781431ffad898
4
+ data.tar.gz: 823b569f7937714f262af069499e076a97b5fac2
5
5
  SHA512:
6
- metadata.gz: 20db768d462ede1beaedd1acbf70b67c42848b9ed7a40c60190d245881002cb0cb41d1e3a02e25c59f8adac1986cc772d92088fc2ff8272a29d3608d77ea20f1
7
- data.tar.gz: 495269eca59a05e33af8bcc0907e6d04969eaafea0bb6b5eb68f3323d089df1dac23a31ba9a05da199633dc231624c10466a4e8bf650c662c8e13ddf373fefdd
6
+ metadata.gz: 8051d1c09e24966136c6c3f58331457cc036b515de444709008592b60a7b4ec1e35d35b97337e9118c8cf2aacd283138ffbd8626eaec868f73b339d90297fe02
7
+ data.tar.gz: fa54d2417b7ed10d5a266f5cc568fa096e546745e269329a4deb302c89feee49839349c298a983930424c354d26ae5db077cea6a275a779f2a761ca807aa114b
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- ���O��k�U�ok�^ŗ�mϞ&�(��}|�/�Μ�a&��%��:��̠�Qy��[r4��(��;5��E��7�{�$W? ]�ݔ��oGIXK�L��L
2
- �/�
3
- ��ɯ�s�c��،�"��c�% Mc��N)4ӨZ��|�O�`m��ϫ�܅�� M��*�#:�o�ޱ�ڢVW�(���c��"p����&7�g��v^n�rM� ��r���>��-� �]b�$c�u\mp�=iW�*�=C�?.����5��K
1
+ ��99��{
2
+ ������}��0����z��4t%�/���� �QE��Zt`R�����L�wzl��bk<M��n����ª�6�pH�D�[A�Ϋ�iV2_K��̎3PXNn%�f��GB0�Ih�W ���U���I�H=�,�좲յG{m�c���%��5A��"9�dpe�fȭ���2n9ڷ�^EN�4�������7�����z9n�pW����c2��В'��O��ٔt��ߌ��?��4����� �*Fh
@@ -44,10 +44,14 @@
44
44
  #endif
45
45
 
46
46
  #if defined(__sun)
47
+ # define BSON_UINT16_SWAP_LE_BE(v) __bson_uint16_swap_slow((uint16_t)v)
47
48
  # define BSON_UINT32_SWAP_LE_BE(v) __bson_uint32_swap_slow((uint32_t)v)
48
49
  # define BSON_UINT64_SWAP_LE_BE(v) __bson_uint64_swap_slow((uint64_t)v)
49
50
  #elif defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) && \
50
51
  (__clang_major__ >= 3) && (__clang_minor__ >= 1)
52
+ # if __has_builtin(__builtin_bswap16)
53
+ # define BSON_UINT16_SWAP_LE_BE(v) __builtin_bswap16(v)
54
+ # endif
51
55
  # if __has_builtin(__builtin_bswap32)
52
56
  # define BSON_UINT32_SWAP_LE_BE(v) __builtin_bswap32(v)
53
57
  # endif
@@ -61,6 +65,10 @@
61
65
  # endif
62
66
  #endif
63
67
 
68
+ #ifndef BSON_UINT16_SWAP_LE_BE
69
+ # define BSON_UINT16_SWAP_LE_BE(v) __bson_uint16_swap_slow((uint16_t)v)
70
+ #endif
71
+
64
72
  #ifndef BSON_UINT32_SWAP_LE_BE
65
73
  # define BSON_UINT32_SWAP_LE_BE(v) __bson_uint32_swap_slow((uint32_t)v)
66
74
  #endif
@@ -70,6 +78,7 @@
70
78
  #endif
71
79
 
72
80
  #if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN
81
+ # define BSON_UINT16_TO_BE(v) BSON_UINT16_SWAP_LE_BE(v)
73
82
  # define BSON_UINT32_FROM_LE(v) ((uint32_t)v)
74
83
  # define BSON_UINT32_TO_LE(v) ((uint32_t)v)
75
84
  # define BSON_UINT32_FROM_BE(v) BSON_UINT32_SWAP_LE_BE(v)
@@ -81,6 +90,7 @@
81
90
  # define BSON_DOUBLE_FROM_LE(v) ((double)v)
82
91
  # define BSON_DOUBLE_TO_LE(v) ((double)v)
83
92
  #elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN
93
+ # define BSON_UINT16_TO_BE(v) ((uint16_t)v)
84
94
  # define BSON_UINT32_FROM_LE(v) BSON_UINT32_SWAP_LE_BE(v)
85
95
  # define BSON_UINT32_TO_LE(v) BSON_UINT32_SWAP_LE_BE(v)
86
96
  # define BSON_UINT32_FROM_BE(v) ((uint32_t)v)
@@ -95,6 +105,27 @@
95
105
  # error "The endianness of target architecture is unknown."
96
106
  #endif
97
107
 
108
+ /*
109
+ *--------------------------------------------------------------------------
110
+ *
111
+ * __bson_uint16_swap_slow --
112
+ *
113
+ * Fallback endianness conversion for 16-bit integers.
114
+ *
115
+ * Returns:
116
+ * The endian swapped version.
117
+ *
118
+ * Side effects:
119
+ * None.
120
+ *
121
+ *--------------------------------------------------------------------------
122
+ */
123
+ static uint16_t __bson_uint16_swap_slow(uint16_t v)
124
+ {
125
+ return ((v & 0x00FF) << 8) |
126
+ ((v & 0xFF00) >> 8);
127
+ }
128
+
98
129
  /*
99
130
  *--------------------------------------------------------------------------
100
131
  *
@@ -93,7 +93,7 @@ static char rb_bson_machine_id_hash[HOST_NAME_HASH_MAX];
93
93
  /**
94
94
  * The counter for incrementing object ids.
95
95
  */
96
- static unsigned int rb_bson_object_id_counter;
96
+ static uint32_t rb_bson_object_id_counter;
97
97
 
98
98
  /**
99
99
  * Initialize the native extension.
@@ -536,28 +536,21 @@ VALUE rb_bson_object_id_generator_next(int argc, VALUE* args, VALUE self)
536
536
  char bytes[12];
537
537
  uint32_t t;
538
538
  uint32_t c;
539
- unsigned short pid = htons(getpid());
539
+ uint16_t pid = BSON_UINT16_TO_BE(getpid());
540
540
 
541
541
  if (argc == 0 || (argc == 1 && *args == Qnil)) {
542
- t = htonl((int) time(NULL));
542
+ t = BSON_UINT32_TO_BE((int) time(NULL));
543
543
  }
544
544
  else {
545
- t = htonl(NUM2ULONG(rb_funcall(*args, rb_intern("to_i"), 0)));
545
+ t = BSON_UINT32_TO_BE(NUM2ULONG(rb_funcall(*args, rb_intern("to_i"), 0)));
546
546
  }
547
547
 
548
- c = htonl(rb_bson_object_id_counter << 8);
548
+ c = BSON_UINT32_TO_BE(rb_bson_object_id_counter << 8);
549
549
 
550
- # if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN
551
550
  memcpy(&bytes, &t, 4);
552
551
  memcpy(&bytes[4], rb_bson_machine_id_hash, 3);
553
552
  memcpy(&bytes[7], &pid, 2);
554
553
  memcpy(&bytes[9], (unsigned char*) &c, 3);
555
- #elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN
556
- memcpy(&bytes, ((unsigned char*) &t) + 4, 4);
557
- memcpy(&bytes[4], rb_bson_machine_id_hash, 3);
558
- memcpy(&bytes[7], &pid, 2);
559
- memcpy(&bytes[9], ((unsigned char*) &c) + 4, 3);
560
- #endif
561
554
  rb_bson_object_id_counter++;
562
555
  return rb_str_new(bytes, 12);
563
556
  }
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.0.2"
16
+ VERSION = "4.0.3".freeze
17
17
  end
@@ -383,6 +383,15 @@ describe BSON::ObjectId do
383
383
  end
384
384
  end
385
385
 
386
+ describe "#initialize" do
387
+
388
+ it "does not generate duplicate ids" do
389
+ 100000.times do
390
+ expect(BSON::ObjectId.new).to_not eq(BSON::ObjectId.new)
391
+ end
392
+ end
393
+ end
394
+
386
395
  describe "#inspect" do
387
396
 
388
397
  let(:object_id) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -34,7 +34,7 @@ cert_chain:
34
34
  XZOS48LlWh15EG4yZo/gRzqNAW2LUIkYA5eMS2Kp6r+KV8IBUO/LaHdrXbdilpa8
35
35
  BRsuCo7UZDbFVRns04HLyjVvkj+K/ywIcdKdS0csz5M=
36
36
  -----END CERTIFICATE-----
37
- date: 2016-02-18 00:00:00.000000000 Z
37
+ date: 2016-02-28 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: A full featured BSON specification implementation, in Ruby
40
40
  email:
metadata.gz.sig CHANGED
Binary file