Guest User

Untitled

a guest
May 20th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. diff --git a/Makefile.PL b/Makefile.PL
  2. index 0e76ee4..53b736b 100644
  3. --- a/Makefile.PL
  4. +++ b/Makefile.PL
  5. @@ -52,5 +52,12 @@ sub const_cccmd {
  6. $inherited .= ' -o $@';
  7. }
  8.  
  9. + if ($Config{use64bitint}) {
  10. + $inherited .= ' -DUSE64BITINT';
  11. + }
  12. + else {
  13. + $inherited .= ' ';
  14. + }
  15. +
  16. return $inherited;
  17. }
  18. diff --git a/perl_mongo.c b/perl_mongo.c
  19. index 9ca1e45..4f1791c 100644
  20. --- a/perl_mongo.c
  21. +++ b/perl_mongo.c
  22. @@ -1032,9 +1032,15 @@ append_sv (buffer *buf, const char *key, SV *sv, AV *ids)
  23. case SVt_PVIV:
  24. case SVt_PVLV: {
  25. if (SvIOK(sv)) {
  26. - set_type(buf, BSON_INT);
  27. - perl_mongo_serialize_key(buf, key, ids);
  28. - perl_mongo_serialize_int(buf, (int)SvIV (sv));
  29. + #ifdef USE64BITINT
  30. + set_type(buf, BSON_LONG);
  31. + perl_mongo_serialize_key(buf, key, ids);
  32. + perl_mongo_serialize_long(buf, (int64_t)SvIV (sv));
  33. + #else
  34. + set_type(buf, BSON_INT);
  35. + perl_mongo_serialize_key(buf, key, ids);
  36. + perl_mongo_serialize_int(buf, (int)SvIV (sv));
  37. + #endif
  38. break;
  39. }
  40. }
  41. diff --git a/t/types.t b/t/types.t
  42. index 0db3ab0..ff9bce1 100644
  43. --- a/t/types.t
  44. +++ b/t/types.t
  45. @@ -20,7 +20,7 @@ if ($@) {
  46. plan skip_all => $@;
  47. }
  48. else {
  49. - plan tests => 32;
  50. + plan tests => 33;
  51. }
  52.  
  53. my $db = $conn->get_database('x');
  54. @@ -170,6 +170,18 @@ isa_ok($x->{max}, 'MongoDB::MaxKey');
  55. $coll->save({x => 2712631400});
  56. $result = $coll->find_one;
  57. is($result->{'x'}, 2712631400);
  58. +
  59. + $coll->remove;
  60. +}
  61. +
  62. +SKIP: {
  63. + use Config;
  64. + skip "Skipping 64 bit native SV"
  65. + if ( ! $Config{use64bitint} );
  66. +
  67. + $coll->update({ x => 1 }, { '$inc' => { y => 19401194714 } }, { upsert => 1 });
  68. + my $result = $coll->find_one;
  69. + is($result->{'y'},19401194714,'64 bit ints without Math::BigInt');
  70. }
  71.  
  72. END {
Add Comment
Please, Sign In to add comment