libmongocrypt-helper 1.7.4.0.1002 → 1.8.0.0.1001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (396) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
  4. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
  6. data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
  7. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
  8. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
  9. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
  14. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
  15. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
  16. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
  19. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
  20. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
  21. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
  22. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
  23. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
  24. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
  25. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
  26. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
  27. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
  28. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
  29. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
  31. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
  32. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
  33. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
  34. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
  35. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
  36. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
  37. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
  38. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
  39. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
  41. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
  43. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
  44. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
  45. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
  48. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
  49. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
  51. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
  52. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
  53. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
  54. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
  55. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
  56. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
  57. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
  58. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  59. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
  60. data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
  61. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
  62. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
  63. data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
  64. data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
  65. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
  66. data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
  67. data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
  68. data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
  69. data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
  70. data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
  71. data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
  72. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
  73. data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
  74. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
  75. data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
  76. data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
  77. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
  78. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
  79. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
  80. data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
  81. data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
  82. data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
  83. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
  84. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
  85. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
  86. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
  87. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
  88. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
  89. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
  90. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
  91. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
  92. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
  93. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
  94. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
  95. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
  96. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
  97. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
  98. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
  99. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
  100. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
  101. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
  102. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
  103. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
  104. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
  105. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
  106. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
  107. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
  108. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
  109. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
  110. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
  111. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
  112. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
  113. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
  114. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
  115. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
  116. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
  117. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
  118. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
  119. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
  120. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
  121. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
  122. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
  123. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
  124. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
  125. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
  126. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
  127. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
  128. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
  129. data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
  130. data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
  131. data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
  132. data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
  133. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
  134. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
  135. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
  136. data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
  137. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
  138. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
  139. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
  140. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
  141. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
  142. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
  143. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
  144. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
  145. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
  146. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
  147. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
  148. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
  149. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
  150. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
  151. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
  152. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
  153. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
  154. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
  155. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
  156. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
  157. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
  158. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
  159. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
  160. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
  161. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
  162. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
  163. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
  164. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
  165. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
  166. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
  167. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
  168. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
  169. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
  170. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
  171. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
  172. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
  173. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
  174. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
  175. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
  176. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
  177. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
  178. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
  179. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
  180. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
  181. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
  182. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
  183. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
  184. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
  185. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
  186. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
  187. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
  188. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
  189. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
  190. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
  191. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
  192. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
  193. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
  194. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
  195. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
  196. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
  197. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
  198. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
  199. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
  202. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
  205. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
  211. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
  212. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
  213. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
  218. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
  219. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
  220. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
  221. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
  224. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
  231. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
  234. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
  235. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
  236. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
  237. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
  238. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
  239. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
  240. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
  241. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
  242. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
  243. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
  244. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
  245. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
  246. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
  247. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
  248. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
  249. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
  250. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
  251. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
  252. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
  253. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  254. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
  255. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
  256. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
  257. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
  258. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
  259. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
  260. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
  261. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
  262. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
  263. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
  264. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
  265. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
  266. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
  267. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
  268. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
  269. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
  270. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
  271. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
  272. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
  273. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
  274. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
  275. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
  276. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
  277. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
  278. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
  279. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
  280. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
  281. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
  282. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
  283. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
  284. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
  285. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
  286. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
  287. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
  288. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
  289. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
  290. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
  291. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
  292. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
  293. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
  294. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
  295. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
  296. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
  297. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
  298. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
  299. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
  300. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
  302. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
  303. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
  306. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
  308. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
  309. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
  310. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
  311. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
  312. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
  313. data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
  314. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
  315. data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
  316. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
  317. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
  318. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
  319. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
  320. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
  321. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
  322. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
  323. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
  324. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
  325. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
  326. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
  327. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
  328. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
  329. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
  330. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
  331. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
  332. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
  333. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
  334. data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
  335. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
  336. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
  337. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
  338. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
  339. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
  340. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
  341. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
  342. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
  343. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
  344. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
  345. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
  346. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
  347. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
  348. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
  349. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
  350. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
  351. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
  352. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
  353. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
  354. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
  355. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
  356. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
  357. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
  358. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
  359. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
  360. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
  361. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
  362. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
  363. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
  364. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
  365. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
  366. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
  367. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
  368. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
  369. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
  370. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
  371. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
  372. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
  373. data/lib/libmongocrypt_helper/version.rb +2 -2
  374. data.tar.gz.sig +0 -0
  375. metadata +154 -26
  376. metadata.gz.sig +0 -0
  377. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  378. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
  379. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
  380. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
  381. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  382. data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
  383. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
  384. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
  385. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
  386. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
  387. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
  388. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
  389. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
  390. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
  391. data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
  392. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
  393. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  394. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
  395. /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  396. /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
@@ -3,9 +3,9 @@
3
3
 
4
4
  #include <bson/bson.h>
5
5
 
6
- #include <mlib/macros.h>
7
- #include <mlib/int128.h>
8
6
  #include <mlib/endian.h>
7
+ #include <mlib/int128.h>
8
+ #include <mlib/macros.h>
9
9
 
10
10
  // Conditional preprocessor definition set by the usage of an intel_dfp from
11
11
  // the ImportDFP.cmake script:
@@ -22,25 +22,25 @@
22
22
  #include <bid_conf.h>
23
23
  #include <bid_functions.h>
24
24
 
25
+ #include <float.h>
25
26
  #include <inttypes.h>
26
- #include <string.h>
27
27
  #include <stdlib.h>
28
- #include <float.h>
28
+ #include <string.h>
29
29
 
30
30
  MLIB_C_LINKAGE_BEGIN
31
31
 
32
32
  /// Rounding controls for Decimal128 operations
33
33
  typedef enum mc_dec128_rounding_mode {
34
- MC_DEC128_ROUND_NEAREST_EVEN = 0,
35
- MC_DEC128_ROUND_DOWNWARD = 1,
36
- MC_DEC128_ROUND_UPWARD = 2,
37
- MC_DEC128_ROUND_TOWARD_ZERO = 3,
38
- MC_DEC128_ROUND_NEAREST_AWAY = 4,
39
- MC_DEC128_ROUND_DEFAULT = MC_DEC128_ROUND_NEAREST_EVEN,
34
+ MC_DEC128_ROUND_NEAREST_EVEN = 0,
35
+ MC_DEC128_ROUND_DOWNWARD = 1,
36
+ MC_DEC128_ROUND_UPWARD = 2,
37
+ MC_DEC128_ROUND_TOWARD_ZERO = 3,
38
+ MC_DEC128_ROUND_NEAREST_AWAY = 4,
39
+ MC_DEC128_ROUND_DEFAULT = MC_DEC128_ROUND_NEAREST_EVEN,
40
40
  } mc_dec128_rounding_mode;
41
41
 
42
42
  typedef struct mc_dec128_flagset {
43
- _IDEC_flags bits;
43
+ _IDEC_flags bits;
44
44
  } mc_dec128_flagset;
45
45
 
46
46
  // This alignment conditional is the same conditions used in Intel's DFP
@@ -49,108 +49,89 @@ typedef struct mc_dec128_flagset {
49
49
  #if defined _M_IX86 && !defined __INTEL_COMPILER
50
50
  #define _mcDec128Align(n)
51
51
  #else
52
- #define _mcDec128Align(n) __declspec(align (n))
52
+ #define _mcDec128Align(n) __declspec(align(n))
53
53
  #endif
54
54
  #else
55
55
  #if !defined HPUX_OS
56
- #define _mcDec128Align(n) __attribute__ ((aligned (n)))
56
+ #define _mcDec128Align(n) __attribute__((aligned(n)))
57
57
  #else
58
58
  #define _mcDec128Align(n)
59
59
  #endif
60
60
  #endif
61
61
 
62
- typedef union _mcDec128Align (16)
63
- {
64
- uint64_t _words[2];
65
- #if !defined(__INTELLISENSE__) && defined(__GNUC__) && defined(__amd64) && \
66
- !defined(__APPLE__) && !defined(__clang__)
67
- // If supported by the compiler, emit a field that can be used to visualize
68
- // the value in a debugger.
69
- float value_ __attribute__ ((mode (TD)));
62
+ typedef union _mcDec128Align(16) {
63
+ uint64_t _words[2];
64
+ #if !defined(__INTELLISENSE__) && defined(__GNUC__) && defined(__amd64) && !defined(__APPLE__) && !defined(__clang__)
65
+ // If supported by the compiler, emit a field that can be used to visualize
66
+ // the value in a debugger.
67
+ float value_ __attribute__((mode(TD)));
70
68
  #endif
71
69
  }
70
+
72
71
  mc_dec128;
73
72
 
74
73
  #undef _mcDec128Align
75
74
 
76
75
  /// Expands to a dec128 constant value.
77
76
  #ifdef __cplusplus
78
- #define MC_DEC128_C(N) \
79
- mc_dec128 _mcDec128Const (((N) < 0 ? -(N) : (N)), ((N) < 0 ? 1 : 0))
77
+ #define MC_DEC128_C(N) mc_dec128 _mcDec128Const(((N) < 0 ? -(N) : (N)), ((N) < 0 ? 1 : 0))
80
78
  #else
81
- #define MC_DEC128_C(N) \
82
- _mcDec128Const (((N) < 0 ? -(N) : (N)), ((N) < 0 ? 1 : 0))
79
+ #define MC_DEC128_C(N) _mcDec128Const(((N) < 0 ? -(N) : (N)), ((N) < 0 ? 1 : 0))
83
80
  #endif
84
81
 
85
- #define MC_DEC128(N) MLIB_INIT (mc_dec128) MC_DEC128_C (N)
86
-
87
- #define _mcDec128Combination(Bits) ((uint64_t) (Bits) << (47))
88
- #define _mcDec128ZeroExpCombo _mcDec128Combination (1 << 7 | 1 << 13 | 1 << 14)
89
- #define _mcDec128Const(N, Negate) \
90
- _mcDec128ConstFromParts ( \
91
- N, (_mcDec128ZeroExpCombo | ((uint64_t) (Negate) << 63)))
92
- #define _mcDec128ConstFromParts(CoeffLow, HighWord) \
93
- { \
94
- { \
95
- MLIB_IS_LITTLE_ENDIAN ? (uint64_t) (CoeffLow) \
96
- : (uint64_t) (HighWord), \
97
- MLIB_IS_LITTLE_ENDIAN ? (uint64_t) (HighWord) \
98
- : (uint64_t) (CoeffLow), \
99
- }, \
100
- }
101
-
102
- static const mc_dec128 MC_DEC128_ZERO = MC_DEC128_C (0);
103
- static const mc_dec128 MC_DEC128_ONE = MC_DEC128_C (1);
104
- static const mc_dec128 MC_DEC128_MINUSONE = MC_DEC128_C (-1);
82
+ #define MC_DEC128(N) MLIB_INIT(mc_dec128) MC_DEC128_C(N)
83
+
84
+ #define _mcDec128Combination(Bits) ((uint64_t)(Bits) << (47))
85
+ #define _mcDec128ZeroExpCombo _mcDec128Combination(1 << 7 | 1 << 13 | 1 << 14)
86
+ #define _mcDec128Const(N, Negate) _mcDec128ConstFromParts(N, (_mcDec128ZeroExpCombo | ((uint64_t)(Negate) << 63)))
87
+ #define _mcDec128ConstFromParts(CoeffLow, HighWord) \
88
+ { \
89
+ { \
90
+ MLIB_IS_LITTLE_ENDIAN ? (uint64_t)(CoeffLow) : (uint64_t)(HighWord), \
91
+ MLIB_IS_LITTLE_ENDIAN ? (uint64_t)(HighWord) : (uint64_t)(CoeffLow), \
92
+ }, \
93
+ }
94
+
95
+ static const mc_dec128 MC_DEC128_ZERO = MC_DEC128_C(0);
96
+ static const mc_dec128 MC_DEC128_ONE = MC_DEC128_C(1);
97
+ static const mc_dec128 MC_DEC128_MINUSONE = MC_DEC128_C(-1);
105
98
 
106
99
  /// The greatest-magnitude finite negative value representable in a Decimal128
107
- #define MC_DEC128_LARGEST_NEGATIVE \
108
- mc_dec128_from_string ("-9999999999999999999999999999999999E6111")
100
+ #define MC_DEC128_LARGEST_NEGATIVE mc_dec128_from_string("-9999999999999999999999999999999999E6111")
109
101
  /// The least-magnitude non-zero negative value representable in a Decimal128
110
- #define MC_DEC128_SMALLEST_NEGATIVE mc_dec128_from_string ("-1E-6176")
102
+ #define MC_DEC128_SMALLEST_NEGATIVE mc_dec128_from_string("-1E-6176")
111
103
  /// The greatest-magnitude finite positive value representable in a Decimal128
112
- #define MC_DEC128_LARGEST_POSITIVE \
113
- mc_dec128_from_string ("9999999999999999999999999999999999E6111")
104
+ #define MC_DEC128_LARGEST_POSITIVE mc_dec128_from_string("9999999999999999999999999999999999E6111")
114
105
  /// The least-magnitude non-zero positive value representable in a Decimal128
115
- #define MC_DEC128_SMALLEST_POSITIVE mc_dec128_from_string ("1E-6176")
106
+ #define MC_DEC128_SMALLEST_POSITIVE mc_dec128_from_string("1E-6176")
116
107
  /// The normalized zero of Decimal128
117
- #define MC_DEC128_NORMALIZED_ZERO MC_DEC128_C (0)
108
+ #define MC_DEC128_NORMALIZED_ZERO MC_DEC128_C(0)
118
109
  /// A zero of Decimal128 with the least exponent
119
- #define MC_DEC128_NEGATIVE_EXPONENT_ZERO mc_dec128_from_string ("0E-6176")
120
- #define _mcDec128InfCombo \
121
- _mcDec128Combination (1 << 15 | 1 << 14 | 1 << 13 | 1 << 12)
122
- #define _mcDec128QuietNaNCombo \
123
- _mcDec128Combination (1 << 15 | 1 << 14 | 1 << 13 | 1 << 12 | 1 << 11)
110
+ #define MC_DEC128_NEGATIVE_EXPONENT_ZERO mc_dec128_from_string("0E-6176")
111
+ #define _mcDec128InfCombo _mcDec128Combination(1 << 15 | 1 << 14 | 1 << 13 | 1 << 12)
112
+ #define _mcDec128QuietNaNCombo _mcDec128Combination(1 << 15 | 1 << 14 | 1 << 13 | 1 << 12 | 1 << 11)
124
113
 
125
114
  /// Positive infinity of Decimal128
126
- #define MC_DEC128_POSITIVE_INFINITY \
127
- _mcDec128ConstFromParts (0, _mcDec128InfCombo)
115
+ #define MC_DEC128_POSITIVE_INFINITY _mcDec128ConstFromParts(0, _mcDec128InfCombo)
128
116
  /// Negative infinity of Decimal128
129
- #define MC_DEC128_NEGATIVE_INFINITY \
130
- _mcDec128ConstFromParts (0, _mcDec128InfCombo | 1ull << 63)
117
+ #define MC_DEC128_NEGATIVE_INFINITY _mcDec128ConstFromParts(0, _mcDec128InfCombo | 1ull << 63)
131
118
  /// Positve quiet NaN of Decimal128
132
- #define MC_DEC128_POSITIVE_NAN \
133
- _mcDec128ConstFromParts (0, _mcDec128QuietNaNCombo)
119
+ #define MC_DEC128_POSITIVE_NAN _mcDec128ConstFromParts(0, _mcDec128QuietNaNCombo)
134
120
  /// Negative quiet NaN of Decimal128
135
- #define MC_DEC128_NEGATIVE_NAN \
136
- _mcDec128ConstFromParts (0, _mcDec128QuietNaNCombo | 1ull << 63)
121
+ #define MC_DEC128_NEGATIVE_NAN _mcDec128ConstFromParts(0, _mcDec128QuietNaNCombo | 1ull << 63)
137
122
 
138
123
  /// Convert an mc_dec128 value to a DFP 128-bit object
139
- static inline BID_UINT128
140
- _mc_to_bid128 (mc_dec128 d)
141
- {
142
- BID_UINT128 r;
143
- memcpy (&r, &d, sizeof d);
144
- return r;
124
+ static inline BID_UINT128 _mc_to_bid128(mc_dec128 d) {
125
+ BID_UINT128 r;
126
+ memcpy(&r, &d, sizeof d);
127
+ return r;
145
128
  }
146
129
 
147
130
  /// Convert a DFP 128-bit object to a mc_dec128 value
148
- static inline mc_dec128
149
- _bid128_to_mc (BID_UINT128 d)
150
- {
151
- mc_dec128 r;
152
- memcpy (&r, &d, sizeof d);
153
- return r;
131
+ static inline mc_dec128 _bid128_to_mc(BID_UINT128 d) {
132
+ mc_dec128 r;
133
+ memcpy(&r, &d, sizeof d);
134
+ return r;
154
135
  }
155
136
 
156
137
  /**
@@ -161,24 +142,17 @@ _bid128_to_mc (BID_UINT128 d)
161
142
  * @param rnd The rounding mode in case the value is not exactly representable
162
143
  * @param flags Out param for exception/error flags (Optional)
163
144
  */
164
- static inline mc_dec128
165
- mc_dec128_from_double_ex (double d,
166
- mc_dec128_rounding_mode rnd,
167
- mc_dec128_flagset *flags)
168
- {
169
- mc_dec128_flagset zero_flags = {0};
170
- return _bid128_to_mc (
171
- binary64_to_bid128 (d, rnd, flags ? &flags->bits : &zero_flags.bits));
145
+ static inline mc_dec128 mc_dec128_from_double_ex(double d, mc_dec128_rounding_mode rnd, mc_dec128_flagset *flags) {
146
+ mc_dec128_flagset zero_flags = {0};
147
+ return _bid128_to_mc(binary64_to_bid128(d, rnd, flags ? &flags->bits : &zero_flags.bits));
172
148
  }
173
149
 
174
150
  /**
175
151
  * @brief Convert a double-precision binary floating point value into the
176
152
  * nearest Decimal128 value
177
153
  */
178
- static inline mc_dec128
179
- mc_dec128_from_double (double d)
180
- {
181
- return mc_dec128_from_double_ex (d, MC_DEC128_ROUND_DEFAULT, NULL);
154
+ static inline mc_dec128 mc_dec128_from_double(double d) {
155
+ return mc_dec128_from_double_ex(d, MC_DEC128_ROUND_DEFAULT, NULL);
182
156
  }
183
157
 
184
158
  /**
@@ -189,24 +163,17 @@ mc_dec128_from_double (double d)
189
163
  * @param rnd The rounding mode to use if the result is not representable
190
164
  * @param flags Out param for exception/error flags (Optional)
191
165
  */
192
- static inline mc_dec128
193
- mc_dec128_from_string_ex (const char *s,
194
- mc_dec128_rounding_mode rnd,
195
- mc_dec128_flagset *flags)
196
- {
197
- mc_dec128_flagset zero_flags = {0};
198
- return _bid128_to_mc (bid128_from_string (
199
- (char *) s, rnd, flags ? &flags->bits : &zero_flags.bits));
166
+ static inline mc_dec128 mc_dec128_from_string_ex(const char *s, mc_dec128_rounding_mode rnd, mc_dec128_flagset *flags) {
167
+ mc_dec128_flagset zero_flags = {0};
168
+ return _bid128_to_mc(bid128_from_string((char *)s, rnd, flags ? &flags->bits : &zero_flags.bits));
200
169
  }
201
170
 
202
171
  /**
203
172
  * @brief Convert a string representation of a number into the nearest
204
173
  * Decimal128 value
205
174
  */
206
- static inline mc_dec128
207
- mc_dec128_from_string (const char *s)
208
- {
209
- return mc_dec128_from_string_ex (s, MC_DEC128_ROUND_DEFAULT, NULL);
175
+ static inline mc_dec128 mc_dec128_from_string(const char *s) {
176
+ return mc_dec128_from_string_ex(s, MC_DEC128_ROUND_DEFAULT, NULL);
210
177
  }
211
178
 
212
179
  /**
@@ -214,8 +181,8 @@ mc_dec128_from_string (const char *s)
214
181
  * engineering notation.
215
182
  */
216
183
  typedef struct mc_dec128_string {
217
- /// The character array of the rendered value. Null-terminated
218
- char str[48];
184
+ /// The character array of the rendered value. Null-terminated
185
+ char str[48];
219
186
  } mc_dec128_string;
220
187
 
221
188
  /**
@@ -224,154 +191,116 @@ typedef struct mc_dec128_string {
224
191
  * @param d The number to represent
225
192
  * @param flags Output parameter for exception/error flags (optional)
226
193
  */
227
- static inline mc_dec128_string
228
- mc_dec128_to_string_ex (mc_dec128 d, mc_dec128_flagset *flags)
229
- {
230
- mc_dec128_flagset zero_flags = {0};
231
- mc_dec128_string out = {{0}};
232
- bid128_to_string (
233
- out.str, _mc_to_bid128 (d), flags ? &flags->bits : &zero_flags.bits);
234
- return out;
194
+ static inline mc_dec128_string mc_dec128_to_string_ex(mc_dec128 d, mc_dec128_flagset *flags) {
195
+ mc_dec128_flagset zero_flags = {0};
196
+ mc_dec128_string out = {{0}};
197
+ bid128_to_string(out.str, _mc_to_bid128(d), flags ? &flags->bits : &zero_flags.bits);
198
+ return out;
235
199
  }
236
200
 
237
201
  /**
238
202
  * @brief Render a Decimal128 value as a string (in engineering notation)
239
203
  */
240
- static inline mc_dec128_string
241
- mc_dec128_to_string (mc_dec128 d)
242
- {
243
- return mc_dec128_to_string_ex (d, NULL);
204
+ static inline mc_dec128_string mc_dec128_to_string(mc_dec128 d) {
205
+ return mc_dec128_to_string_ex(d, NULL);
244
206
  }
245
207
 
246
208
  /// Compare two dec128 numbers
247
- #define DECL_IDF_COMPARE_1(Oper) \
248
- static inline bool mc_dec128_##Oper##_ex ( \
249
- mc_dec128 left, mc_dec128 right, mc_dec128_flagset *flags) \
250
- { \
251
- mc_dec128_flagset zero_flags = {0}; \
252
- return 0 != \
253
- bid128_quiet_##Oper (_mc_to_bid128 (left), \
254
- _mc_to_bid128 (right), \
255
- flags ? &flags->bits : &zero_flags.bits); \
256
- } \
257
- \
258
- static inline bool mc_dec128_##Oper (mc_dec128 left, mc_dec128 right) \
259
- { \
260
- return mc_dec128_##Oper##_ex (left, right, NULL); \
261
- }
262
-
263
- #define DECL_IDF_COMPARE(Op) DECL_IDF_COMPARE_1 (Op)
264
-
265
- DECL_IDF_COMPARE (equal)
266
- DECL_IDF_COMPARE (not_equal)
267
- DECL_IDF_COMPARE (greater)
268
- DECL_IDF_COMPARE (greater_equal)
269
- DECL_IDF_COMPARE (less)
270
- DECL_IDF_COMPARE (less_equal)
209
+ #define DECL_IDF_COMPARE_1(Oper) \
210
+ static inline bool mc_dec128_##Oper##_ex(mc_dec128 left, mc_dec128 right, mc_dec128_flagset *flags) { \
211
+ mc_dec128_flagset zero_flags = {0}; \
212
+ return 0 \
213
+ != bid128_quiet_##Oper(_mc_to_bid128(left), \
214
+ _mc_to_bid128(right), \
215
+ flags ? &flags->bits : &zero_flags.bits); \
216
+ } \
217
+ \
218
+ static inline bool mc_dec128_##Oper(mc_dec128 left, mc_dec128 right) { \
219
+ return mc_dec128_##Oper##_ex(left, right, NULL); \
220
+ }
221
+
222
+ #define DECL_IDF_COMPARE(Op) DECL_IDF_COMPARE_1(Op)
223
+
224
+ DECL_IDF_COMPARE(equal)
225
+ DECL_IDF_COMPARE(not_equal)
226
+ DECL_IDF_COMPARE(greater)
227
+ DECL_IDF_COMPARE(greater_equal)
228
+ DECL_IDF_COMPARE(less)
229
+ DECL_IDF_COMPARE(less_equal)
271
230
 
272
231
  #undef DECL_IDF_COMPARE
273
232
  #undef DECL_IDF_COMPARE_1
274
233
 
275
234
  /// Test properties of Decimal128 numbers
276
- #define DECL_PREDICATE(Name, BIDName) \
277
- static inline bool mc_dec128_##Name (mc_dec128 d) \
278
- { \
279
- return 0 != bid128_##BIDName (_mc_to_bid128 (d)); \
280
- }
281
-
282
- DECL_PREDICATE (is_zero, isZero)
283
- DECL_PREDICATE (is_negative, isSigned)
284
- DECL_PREDICATE (is_inf, isInf)
285
- DECL_PREDICATE (is_finite, isFinite)
286
- DECL_PREDICATE (is_nan, isNaN)
235
+ #define DECL_PREDICATE(Name, BIDName) \
236
+ static inline bool mc_dec128_##Name(mc_dec128 d) { return 0 != bid128_##BIDName(_mc_to_bid128(d)); }
237
+
238
+ DECL_PREDICATE(is_zero, isZero)
239
+ DECL_PREDICATE(is_negative, isSigned)
240
+ DECL_PREDICATE(is_inf, isInf)
241
+ DECL_PREDICATE(is_finite, isFinite)
242
+ DECL_PREDICATE(is_nan, isNaN)
287
243
 
288
244
  #undef DECL_PREDICATE
289
245
 
290
246
  /// Binary arithmetic operations on two Decimal128 numbers
291
- #define DECL_IDF_BINOP_WRAPPER(Oper) \
292
- static inline mc_dec128 mc_dec128_##Oper##_ex ( \
293
- mc_dec128 left, \
294
- mc_dec128 right, \
295
- mc_dec128_rounding_mode mode, \
296
- mc_dec128_flagset *flags) \
297
- { \
298
- mc_dec128_flagset zero_flags = {0}; \
299
- return _bid128_to_mc ( \
300
- bid128_##Oper (_mc_to_bid128 (left), \
301
- _mc_to_bid128 (right), \
302
- mode, \
303
- flags ? &flags->bits : &zero_flags.bits)); \
304
- } \
305
- \
306
- static inline mc_dec128 mc_dec128_##Oper (mc_dec128 left, mc_dec128 right) \
307
- { \
308
- return mc_dec128_##Oper##_ex ( \
309
- left, right, MC_DEC128_ROUND_DEFAULT, NULL); \
310
- }
311
-
312
- DECL_IDF_BINOP_WRAPPER (add)
313
- DECL_IDF_BINOP_WRAPPER (mul)
314
- DECL_IDF_BINOP_WRAPPER (div)
315
- DECL_IDF_BINOP_WRAPPER (sub)
316
- DECL_IDF_BINOP_WRAPPER (pow)
247
+ #define DECL_IDF_BINOP_WRAPPER(Oper) \
248
+ static inline mc_dec128 mc_dec128_##Oper##_ex(mc_dec128 left, \
249
+ mc_dec128 right, \
250
+ mc_dec128_rounding_mode mode, \
251
+ mc_dec128_flagset *flags) { \
252
+ mc_dec128_flagset zero_flags = {0}; \
253
+ return _bid128_to_mc( \
254
+ bid128_##Oper(_mc_to_bid128(left), _mc_to_bid128(right), mode, flags ? &flags->bits : &zero_flags.bits)); \
255
+ } \
256
+ \
257
+ static inline mc_dec128 mc_dec128_##Oper(mc_dec128 left, mc_dec128 right) { \
258
+ return mc_dec128_##Oper##_ex(left, right, MC_DEC128_ROUND_DEFAULT, NULL); \
259
+ }
260
+
261
+ DECL_IDF_BINOP_WRAPPER(add)
262
+ DECL_IDF_BINOP_WRAPPER(mul)
263
+ DECL_IDF_BINOP_WRAPPER(div)
264
+ DECL_IDF_BINOP_WRAPPER(sub)
265
+ DECL_IDF_BINOP_WRAPPER(pow)
317
266
 
318
267
  #undef DECL_IDF_BINOP_WRAPPER
319
268
 
320
269
  /// Unary arithmetic operations on two Decimal128 numbers
321
- #define DECL_IDF_UNOP_WRAPPER(Oper) \
322
- static inline mc_dec128 mc_dec128_##Oper##_ex (mc_dec128 operand, \
323
- mc_dec128_flagset *flags) \
324
- { \
325
- mc_dec128_flagset zero_flags = {0}; \
326
- return _bid128_to_mc ( \
327
- bid128_##Oper (_mc_to_bid128 (operand), \
328
- MC_DEC128_ROUND_DEFAULT, \
329
- flags ? &flags->bits : &zero_flags.bits)); \
330
- } \
331
- \
332
- static inline mc_dec128 mc_dec128_##Oper (mc_dec128 operand) \
333
- { \
334
- return mc_dec128_##Oper##_ex (operand, NULL); \
335
- }
336
-
337
- DECL_IDF_UNOP_WRAPPER (log2)
338
- DECL_IDF_UNOP_WRAPPER (log10)
270
+ #define DECL_IDF_UNOP_WRAPPER(Oper) \
271
+ static inline mc_dec128 mc_dec128_##Oper##_ex(mc_dec128 operand, mc_dec128_flagset *flags) { \
272
+ mc_dec128_flagset zero_flags = {0}; \
273
+ return _bid128_to_mc( \
274
+ bid128_##Oper(_mc_to_bid128(operand), MC_DEC128_ROUND_DEFAULT, flags ? &flags->bits : &zero_flags.bits)); \
275
+ } \
276
+ \
277
+ static inline mc_dec128 mc_dec128_##Oper(mc_dec128 operand) { return mc_dec128_##Oper##_ex(operand, NULL); }
278
+
279
+ DECL_IDF_UNOP_WRAPPER(log2)
280
+ DECL_IDF_UNOP_WRAPPER(log10)
339
281
  #undef DECL_IDF_UNOP_WRAPPER
340
282
 
341
283
  static inline mc_dec128
342
- mc_dec128_round_integral_ex (mc_dec128 value,
343
- mc_dec128_rounding_mode direction,
344
- mc_dec128_flagset *flags)
345
- {
346
- BID_UINT128 bid = _mc_to_bid128 (value);
347
- mc_dec128_flagset zero_flags = {0};
348
- _IDEC_flags *fl = flags ? &flags->bits : &zero_flags.bits;
349
- switch (direction) {
350
- case MC_DEC128_ROUND_TOWARD_ZERO:
351
- return _bid128_to_mc (bid128_round_integral_zero (bid, fl));
352
- case MC_DEC128_ROUND_NEAREST_AWAY:
353
- return _bid128_to_mc (bid128_round_integral_nearest_away (bid, fl));
354
- case MC_DEC128_ROUND_NEAREST_EVEN:
355
- return _bid128_to_mc (bid128_round_integral_nearest_even (bid, fl));
356
- case MC_DEC128_ROUND_DOWNWARD:
357
- return _bid128_to_mc (bid128_round_integral_negative (bid, fl));
358
- case MC_DEC128_ROUND_UPWARD:
359
- return _bid128_to_mc (bid128_round_integral_positive (bid, fl));
360
- default:
361
- abort ();
362
- }
284
+ mc_dec128_round_integral_ex(mc_dec128 value, mc_dec128_rounding_mode direction, mc_dec128_flagset *flags) {
285
+ BID_UINT128 bid = _mc_to_bid128(value);
286
+ mc_dec128_flagset zero_flags = {0};
287
+ _IDEC_flags *fl = flags ? &flags->bits : &zero_flags.bits;
288
+ switch (direction) {
289
+ case MC_DEC128_ROUND_TOWARD_ZERO: return _bid128_to_mc(bid128_round_integral_zero(bid, fl));
290
+ case MC_DEC128_ROUND_NEAREST_AWAY: return _bid128_to_mc(bid128_round_integral_nearest_away(bid, fl));
291
+ case MC_DEC128_ROUND_NEAREST_EVEN: return _bid128_to_mc(bid128_round_integral_nearest_even(bid, fl));
292
+ case MC_DEC128_ROUND_DOWNWARD: return _bid128_to_mc(bid128_round_integral_negative(bid, fl));
293
+ case MC_DEC128_ROUND_UPWARD: return _bid128_to_mc(bid128_round_integral_positive(bid, fl));
294
+ default: abort();
295
+ }
363
296
  }
364
297
 
365
- static inline mc_dec128
366
- mc_dec128_negate (mc_dec128 operand)
367
- {
368
- return _bid128_to_mc (bid128_negate (_mc_to_bid128 (operand)));
298
+ static inline mc_dec128 mc_dec128_negate(mc_dec128 operand) {
299
+ return _bid128_to_mc(bid128_negate(_mc_to_bid128(operand)));
369
300
  }
370
301
 
371
- static inline mc_dec128
372
- mc_dec128_abs (mc_dec128 operand)
373
- {
374
- return _bid128_to_mc (bid128_abs (_mc_to_bid128 (operand)));
302
+ static inline mc_dec128 mc_dec128_abs(mc_dec128 operand) {
303
+ return _bid128_to_mc(bid128_abs(_mc_to_bid128(operand)));
375
304
  }
376
305
 
377
306
  /**
@@ -384,17 +313,9 @@ mc_dec128_abs (mc_dec128 operand)
384
313
  * @return mc_dec128 The product
385
314
  */
386
315
  static inline mc_dec128
387
- mc_dec128_scale_ex (mc_dec128 fac,
388
- long int exp,
389
- mc_dec128_rounding_mode rounding,
390
- mc_dec128_flagset *flags)
391
- {
392
- mc_dec128_flagset zero_flags = {0};
393
- return _bid128_to_mc (
394
- bid128_scalbln (_mc_to_bid128 (fac),
395
- exp,
396
- rounding,
397
- flags ? &flags->bits : &zero_flags.bits));
316
+ mc_dec128_scale_ex(mc_dec128 fac, long int exp, mc_dec128_rounding_mode rounding, mc_dec128_flagset *flags) {
317
+ mc_dec128_flagset zero_flags = {0};
318
+ return _bid128_to_mc(bid128_scalbln(_mc_to_bid128(fac), exp, rounding, flags ? &flags->bits : &zero_flags.bits));
398
319
  }
399
320
 
400
321
  /**
@@ -404,18 +325,16 @@ mc_dec128_scale_ex (mc_dec128 fac,
404
325
  * @param exp The exponent: 10^exp is the scale factor
405
326
  * @return mc_dec128 The product
406
327
  */
407
- static inline mc_dec128
408
- mc_dec128_scale (mc_dec128 fac, long int exp)
409
- {
410
- return mc_dec128_scale_ex (fac, exp, MC_DEC128_ROUND_DEFAULT, NULL);
328
+ static inline mc_dec128 mc_dec128_scale(mc_dec128 fac, long int exp) {
329
+ return mc_dec128_scale_ex(fac, exp, MC_DEC128_ROUND_DEFAULT, NULL);
411
330
  }
412
331
 
413
332
  /// The result of a dec_128 modf operation
414
333
  typedef struct mc_dec128_modf_result {
415
- /// The whole part of the result
416
- mc_dec128 whole;
417
- /// The fractional part of the result
418
- mc_dec128 frac;
334
+ /// The whole part of the result
335
+ mc_dec128 whole;
336
+ /// The fractional part of the result
337
+ mc_dec128 frac;
419
338
  } mc_dec128_modf_result;
420
339
 
421
340
  /**
@@ -427,16 +346,13 @@ typedef struct mc_dec128_modf_result {
427
346
  * @param d The value to inspect
428
347
  * @param flags Results status flags
429
348
  */
430
- static inline mc_dec128_modf_result
431
- mc_dec128_modf_ex (mc_dec128 d, mc_dec128_flagset *flags)
432
- {
433
- mc_dec128_flagset zero_flags = {0};
434
- mc_dec128_modf_result res;
435
- BID_UINT128 whole;
436
- res.frac = _bid128_to_mc (bid128_modf (
437
- _mc_to_bid128 (d), &whole, flags ? &flags->bits : &zero_flags.bits));
438
- res.whole = _bid128_to_mc (whole);
439
- return res;
349
+ static inline mc_dec128_modf_result mc_dec128_modf_ex(mc_dec128 d, mc_dec128_flagset *flags) {
350
+ mc_dec128_flagset zero_flags = {0};
351
+ mc_dec128_modf_result res;
352
+ BID_UINT128 whole;
353
+ res.frac = _bid128_to_mc(bid128_modf(_mc_to_bid128(d), &whole, flags ? &flags->bits : &zero_flags.bits));
354
+ res.whole = _bid128_to_mc(whole);
355
+ return res;
440
356
  }
441
357
 
442
358
  /**
@@ -447,10 +363,8 @@ mc_dec128_modf_ex (mc_dec128 d, mc_dec128_flagset *flags)
447
363
  *
448
364
  * @param d The value to inspect
449
365
  */
450
- static inline mc_dec128_modf_result
451
- mc_dec128_modf (mc_dec128 d)
452
- {
453
- return mc_dec128_modf_ex (d, NULL);
366
+ static inline mc_dec128_modf_result mc_dec128_modf(mc_dec128 d) {
367
+ return mc_dec128_modf_ex(d, NULL);
454
368
  }
455
369
 
456
370
  /**
@@ -461,13 +375,10 @@ mc_dec128_modf (mc_dec128 d)
461
375
  * @param denom The divisor of the modulus
462
376
  * @param flags Control/status flags
463
377
  */
464
- static inline mc_dec128
465
- mc_dec128_fmod_ex (mc_dec128 numer, mc_dec128 denom, mc_dec128_flagset *flags)
466
- {
467
- mc_dec128_flagset zero_flags = {0};
468
- return _bid128_to_mc (bid128_fmod (_mc_to_bid128 (numer),
469
- _mc_to_bid128 (denom),
470
- flags ? &flags->bits : &zero_flags.bits));
378
+ static inline mc_dec128 mc_dec128_fmod_ex(mc_dec128 numer, mc_dec128 denom, mc_dec128_flagset *flags) {
379
+ mc_dec128_flagset zero_flags = {0};
380
+ return _bid128_to_mc(
381
+ bid128_fmod(_mc_to_bid128(numer), _mc_to_bid128(denom), flags ? &flags->bits : &zero_flags.bits));
471
382
  }
472
383
 
473
384
  /**
@@ -477,10 +388,8 @@ mc_dec128_fmod_ex (mc_dec128 numer, mc_dec128 denom, mc_dec128_flagset *flags)
477
388
  * @param numer The dividend of the modulus
478
389
  * @param denom The divisor of the modulus
479
390
  */
480
- static inline mc_dec128
481
- mc_dec128_fmod (mc_dec128 numer, mc_dec128 denom)
482
- {
483
- return mc_dec128_fmod_ex (numer, denom, NULL);
391
+ static inline mc_dec128 mc_dec128_fmod(mc_dec128 numer, mc_dec128 denom) {
392
+ return mc_dec128_fmod_ex(numer, denom, NULL);
484
393
  }
485
394
 
486
395
  /**
@@ -490,12 +399,9 @@ mc_dec128_fmod (mc_dec128 numer, mc_dec128 denom)
490
399
  * @param d The value to inspect
491
400
  * @param flags Control/status flags
492
401
  */
493
- static inline int64_t
494
- mc_dec128_to_int64_ex (mc_dec128 d, mc_dec128_flagset *flags)
495
- {
496
- mc_dec128_flagset zero_flags = {0};
497
- return bid128_to_int64_int (_mc_to_bid128 (d),
498
- flags ? &flags->bits : &zero_flags.bits);
402
+ static inline int64_t mc_dec128_to_int64_ex(mc_dec128 d, mc_dec128_flagset *flags) {
403
+ mc_dec128_flagset zero_flags = {0};
404
+ return bid128_to_int64_int(_mc_to_bid128(d), flags ? &flags->bits : &zero_flags.bits);
499
405
  }
500
406
 
501
407
  /**
@@ -504,87 +410,77 @@ mc_dec128_to_int64_ex (mc_dec128 d, mc_dec128_flagset *flags)
504
410
  *
505
411
  * @param d The value to inspect
506
412
  */
507
- static inline int64_t
508
- mc_dec128_to_int64 (mc_dec128 d)
509
- {
510
- return mc_dec128_to_int64_ex (d, NULL);
413
+ static inline int64_t mc_dec128_to_int64(mc_dec128 d) {
414
+ return mc_dec128_to_int64_ex(d, NULL);
511
415
  }
512
416
 
513
417
  /// Constants for inspection/deconstruction of Decimal128
514
418
  enum {
515
- /// Least non-canonical combination bits value
516
- MC_DEC128_COMBO_NONCANONICAL = 3 << 15,
517
- /// Least combination value indicating infinity
518
- MC_DEC128_COMBO_INFINITY = 0x1e << 12,
519
- /// The greatest Decimal128 biased exponent
520
- MC_DEC128_MAX_BIASED_EXPONENT = 6143 + 6144,
521
- /// The exponent bias of Decimal128
522
- MC_DEC128_EXPONENT_BIAS = 6143 + 33, // +33 to include the 34 decimal digits
523
- /// Minimum exponent value (without bias)
524
- MC_DEC_MIN_EXPONENT = -6143,
525
- /// Maximum exponent value (without bias)
526
- MC_DEC_MAX_EXPONENT = 6144,
419
+ /// Least non-canonical combination bits value
420
+ MC_DEC128_COMBO_NONCANONICAL = 3 << 15,
421
+ /// Least combination value indicating infinity
422
+ MC_DEC128_COMBO_INFINITY = 0x1e << 12,
423
+ /// The greatest Decimal128 biased exponent
424
+ MC_DEC128_MAX_BIASED_EXPONENT = 6143 + 6144,
425
+ /// The exponent bias of Decimal128
426
+ MC_DEC128_EXPONENT_BIAS = 6143 + 33, // +33 to include the 34 decimal digits
427
+ /// Minimum exponent value (without bias)
428
+ MC_DEC_MIN_EXPONENT = -6143,
429
+ /// Maximum exponent value (without bias)
430
+ MC_DEC_MAX_EXPONENT = 6144,
527
431
  };
528
432
 
529
433
  /// Obtain the value of the combination bits of a decimal128
530
- static inline uint32_t
531
- mc_dec128_combination (mc_dec128 d)
532
- {
533
- // Grab the high 64 bits:
534
- uint64_t hi = d._words[MLIB_IS_LITTLE_ENDIAN ? 1 : 0];
535
- // Sign is the 64th bit:
536
- int signpos = 64 - 1;
537
- // Combo is the next 16 bits:
538
- int fieldpos = signpos - 17;
539
- int fieldmask = (1 << 17) - 1;
540
- return (uint32_t) ((hi >> fieldpos) & (uint32_t) fieldmask);
434
+ static inline uint32_t mc_dec128_combination(mc_dec128 d) {
435
+ // Grab the high 64 bits:
436
+ uint64_t hi = d._words[MLIB_IS_LITTLE_ENDIAN ? 1 : 0];
437
+ // Sign is the 64th bit:
438
+ int signpos = 64 - 1;
439
+ // Combo is the next 16 bits:
440
+ int fieldpos = signpos - 17;
441
+ int fieldmask = (1 << 17) - 1;
442
+ return (uint32_t)((hi >> fieldpos) & (uint32_t)fieldmask);
541
443
  }
542
444
 
543
445
  /**
544
446
  * @brief Obtain the value of the high 49 bits of the Decimal128 coefficient
545
447
  */
546
- static inline uint64_t
547
- mc_dec128_coeff_high (mc_dec128 d)
548
- {
549
- uint64_t hi_field_mask = (1ull << 49) - 1;
550
- uint32_t combo = mc_dec128_combination (d);
551
- if (combo < MC_DEC128_COMBO_NONCANONICAL) {
552
- uint64_t hi = d._words[MLIB_IS_LITTLE_ENDIAN ? 1 : 0];
553
- return hi & hi_field_mask;
554
- } else {
555
- return 0;
556
- }
448
+ static inline uint64_t mc_dec128_coeff_high(mc_dec128 d) {
449
+ uint64_t hi_field_mask = (1ull << 49) - 1;
450
+ uint32_t combo = mc_dec128_combination(d);
451
+ if (combo < MC_DEC128_COMBO_NONCANONICAL) {
452
+ uint64_t hi = d._words[MLIB_IS_LITTLE_ENDIAN ? 1 : 0];
453
+ return hi & hi_field_mask;
454
+ } else {
455
+ return 0;
456
+ }
557
457
  }
558
458
 
559
459
  /**
560
460
  * @brief Obtain the value of the low 64 bits of the Decimal128 coefficient
561
461
  */
562
- static inline uint64_t
563
- mc_dec128_coeff_low (mc_dec128 d)
564
- {
565
- uint32_t combo = mc_dec128_combination (d);
566
- if (combo < MC_DEC128_COMBO_NONCANONICAL) {
567
- uint64_t lo = d._words[MLIB_IS_LITTLE_ENDIAN ? 0 : 1];
568
- return lo;
569
- } else {
570
- return 0;
571
- }
462
+ static inline uint64_t mc_dec128_coeff_low(mc_dec128 d) {
463
+ uint32_t combo = mc_dec128_combination(d);
464
+ if (combo < MC_DEC128_COMBO_NONCANONICAL) {
465
+ uint64_t lo = d._words[MLIB_IS_LITTLE_ENDIAN ? 0 : 1];
466
+ return lo;
467
+ } else {
468
+ return 0;
469
+ }
572
470
  }
573
471
 
574
472
  /**
575
473
  * @brief Obtain the full coefficient of the given Decimal128 number. Requires a
576
474
  * 128-bit integer.
577
475
  */
578
- static inline mlib_int128
579
- mc_dec128_coeff (mc_dec128 d)
580
- {
581
- // Hi bits
582
- uint64_t hi = mc_dec128_coeff_high (d);
583
- // Lo bits
584
- uint64_t lo = mc_dec128_coeff_low (d);
585
- // Shift and add
586
- mlib_int128 hi_128 = mlib_int128_lshift (MLIB_INT128_CAST (hi), 64);
587
- return mlib_int128_add (hi_128, MLIB_INT128_CAST (lo));
476
+ static inline mlib_int128 mc_dec128_coeff(mc_dec128 d) {
477
+ // Hi bits
478
+ uint64_t hi = mc_dec128_coeff_high(d);
479
+ // Lo bits
480
+ uint64_t lo = mc_dec128_coeff_low(d);
481
+ // Shift and add
482
+ mlib_int128 hi_128 = mlib_int128_lshift(MLIB_INT128_CAST(hi), 64);
483
+ return mlib_int128_add(hi_128, MLIB_INT128_CAST(lo));
588
484
  }
589
485
 
590
486
  /**
@@ -595,145 +491,137 @@ mc_dec128_coeff (mc_dec128 d)
595
491
  * positive and negative exponent range. The bias value is defined as
596
492
  * MC_DEC128_EXPONENT_BIAS.
597
493
  */
598
- static inline uint32_t
599
- mc_dec128_get_biased_exp (mc_dec128 d)
600
- {
601
- uint32_t combo = mc_dec128_combination (d);
602
- if (combo < MC_DEC128_COMBO_NONCANONICAL) {
603
- return combo >> 3;
604
- }
605
- if (combo >= MC_DEC128_COMBO_INFINITY) {
606
- return MC_DEC128_MAX_BIASED_EXPONENT + 1;
607
- } else {
608
- return (combo >> 1) & ((1 << 14) - 1);
609
- }
494
+ static inline uint32_t mc_dec128_get_biased_exp(mc_dec128 d) {
495
+ uint32_t combo = mc_dec128_combination(d);
496
+ if (combo < MC_DEC128_COMBO_NONCANONICAL) {
497
+ return combo >> 3;
498
+ }
499
+ if (combo >= MC_DEC128_COMBO_INFINITY) {
500
+ return MC_DEC128_MAX_BIASED_EXPONENT + 1;
501
+ } else {
502
+ return (combo >> 1) & ((1 << 14) - 1);
503
+ }
610
504
  }
611
505
 
612
506
  /// Create a decimal string from a dec128 number. The result must be freed.
613
- static inline char *
614
- mc_dec128_to_new_decimal_string (mc_dec128 d)
615
- {
616
- if (mc_dec128_is_zero (d)) {
617
- // Just return "0"
618
- char *s = (char *) calloc (2, 1);
619
- if (s) {
620
- s[0] = '0';
621
- }
622
- return s;
623
- }
624
-
625
- if (mc_dec128_is_negative (d)) {
626
- // Negate the result, return a string with a '-' prefix
627
- d = mc_dec128_negate (d);
628
- char *s = mc_dec128_to_new_decimal_string (d);
629
- if (!s) {
630
- return NULL;
631
- }
632
- char *s1 = (char *) calloc (strlen (s) + 2, 1);
633
- if (s1) {
634
- s1[0] = '-';
635
- strcpy (s1 + 1, s);
636
- }
637
- free (s);
638
- return s1;
639
- }
640
-
641
- if (mc_dec128_is_inf (d) || mc_dec128_is_nan (d)) {
642
- const char *r = mc_dec128_is_inf (d) ? "Infinity" : "NaN";
643
- char *c = (char *) calloc (strlen (r) + 1, 1);
644
- if (c) {
645
- strcpy (c, r);
646
- }
647
- return c;
648
- }
649
-
650
- const char DIGITS[] = "0123456789";
651
- const mc_dec128 TEN = MC_DEC128_C (10);
652
-
653
- // Format the whole and fractional part separately.
654
- mc_dec128_modf_result modf = mc_dec128_modf (d);
655
-
656
- if (mc_dec128_is_zero (modf.frac)) {
657
- // This is a non-zero integer
658
- // Allocate enough digits:
659
- mc_dec128 log10 = mc_dec128_modf (mc_dec128_log10 (d)).whole;
660
- int64_t ndigits = mc_dec128_to_int64 (log10) + 1;
661
- // +1 for null
662
- char *strbuf = (char *) calloc ((size_t) (ndigits + 1), 1);
663
- if (strbuf) {
664
- // Write the string backwards:
665
- char *optr = strbuf + ndigits - 1;
666
- while (!mc_dec128_is_zero (modf.whole)) {
667
- mc_dec128 rem = mc_dec128_fmod (modf.whole, TEN);
668
- int64_t remi = mc_dec128_to_int64 (rem);
669
- *optr-- = DIGITS[remi];
670
- // Divide ten
671
- modf = mc_dec128_modf (mc_dec128_div (modf.whole, TEN));
672
- }
673
- }
674
- return strbuf;
675
- } else if (mc_dec128_is_zero (modf.whole)) {
676
- // This is only a fraction (less than one, but more than zero)
677
- while (!mc_dec128_is_zero (mc_dec128_modf (d).frac)) {
678
- d = mc_dec128_mul (d, TEN);
679
- }
680
- // 'd' is now a whole number
681
- char *part = mc_dec128_to_new_decimal_string (d);
682
- if (!part) {
683
- return NULL;
684
- }
685
- char *buf = (char *) calloc (strlen (part) + 3, 1);
686
- if (buf) {
687
- buf[0] = '0';
688
- buf[1] = '.';
689
- strcpy (buf + 2, part);
690
- }
691
- free (part);
692
- return buf;
693
- } else {
694
- // We have both a whole part and a fractional part
695
- char *whole = mc_dec128_to_new_decimal_string (modf.whole);
696
- if (!whole) {
697
- return NULL;
698
- }
699
- char *frac = mc_dec128_to_new_decimal_string (modf.frac);
700
- if (!frac) {
701
- free (whole);
702
- return NULL;
703
- }
704
- char *ret = (char *) calloc (strlen (whole) + strlen (frac) + 1, 1);
705
- if (ret) {
706
- char *out = ret;
707
- strcpy (out, whole);
708
- out += strlen (whole);
709
- // "frac" contains a leading zero, which we don't want
710
- strcpy (out, frac + 1);
711
- }
712
- free (whole);
713
- free (frac);
714
- return ret;
715
- }
507
+ static inline char *mc_dec128_to_new_decimal_string(mc_dec128 d) {
508
+ if (mc_dec128_is_zero(d)) {
509
+ // Just return "0"
510
+ char *s = (char *)calloc(2, 1);
511
+ if (s) {
512
+ s[0] = '0';
513
+ }
514
+ return s;
515
+ }
516
+
517
+ if (mc_dec128_is_negative(d)) {
518
+ // Negate the result, return a string with a '-' prefix
519
+ d = mc_dec128_negate(d);
520
+ char *s = mc_dec128_to_new_decimal_string(d);
521
+ if (!s) {
522
+ return NULL;
523
+ }
524
+ char *s1 = (char *)calloc(strlen(s) + 2, 1);
525
+ if (s1) {
526
+ s1[0] = '-';
527
+ strcpy(s1 + 1, s);
528
+ }
529
+ free(s);
530
+ return s1;
531
+ }
532
+
533
+ if (mc_dec128_is_inf(d) || mc_dec128_is_nan(d)) {
534
+ const char *r = mc_dec128_is_inf(d) ? "Infinity" : "NaN";
535
+ char *c = (char *)calloc(strlen(r) + 1, 1);
536
+ if (c) {
537
+ strcpy(c, r);
538
+ }
539
+ return c;
540
+ }
541
+
542
+ const char DIGITS[] = "0123456789";
543
+ const mc_dec128 TEN = MC_DEC128_C(10);
544
+
545
+ // Format the whole and fractional part separately.
546
+ mc_dec128_modf_result modf = mc_dec128_modf(d);
547
+
548
+ if (mc_dec128_is_zero(modf.frac)) {
549
+ // This is a non-zero integer
550
+ // Allocate enough digits:
551
+ mc_dec128 log10 = mc_dec128_modf(mc_dec128_log10(d)).whole;
552
+ int64_t ndigits = mc_dec128_to_int64(log10) + 1;
553
+ // +1 for null
554
+ char *strbuf = (char *)calloc((size_t)(ndigits + 1), 1);
555
+ if (strbuf) {
556
+ // Write the string backwards:
557
+ char *optr = strbuf + ndigits - 1;
558
+ while (!mc_dec128_is_zero(modf.whole)) {
559
+ mc_dec128 rem = mc_dec128_fmod(modf.whole, TEN);
560
+ int64_t remi = mc_dec128_to_int64(rem);
561
+ *optr-- = DIGITS[remi];
562
+ // Divide ten
563
+ modf = mc_dec128_modf(mc_dec128_div(modf.whole, TEN));
564
+ }
565
+ }
566
+ return strbuf;
567
+ } else if (mc_dec128_is_zero(modf.whole)) {
568
+ // This is only a fraction (less than one, but more than zero)
569
+ while (!mc_dec128_is_zero(mc_dec128_modf(d).frac)) {
570
+ d = mc_dec128_mul(d, TEN);
571
+ }
572
+ // 'd' is now a whole number
573
+ char *part = mc_dec128_to_new_decimal_string(d);
574
+ if (!part) {
575
+ return NULL;
576
+ }
577
+ char *buf = (char *)calloc(strlen(part) + 3, 1);
578
+ if (buf) {
579
+ buf[0] = '0';
580
+ buf[1] = '.';
581
+ strcpy(buf + 2, part);
582
+ }
583
+ free(part);
584
+ return buf;
585
+ } else {
586
+ // We have both a whole part and a fractional part
587
+ char *whole = mc_dec128_to_new_decimal_string(modf.whole);
588
+ if (!whole) {
589
+ return NULL;
590
+ }
591
+ char *frac = mc_dec128_to_new_decimal_string(modf.frac);
592
+ if (!frac) {
593
+ free(whole);
594
+ return NULL;
595
+ }
596
+ char *ret = (char *)calloc(strlen(whole) + strlen(frac) + 1, 1);
597
+ if (ret) {
598
+ char *out = ret;
599
+ strcpy(out, whole);
600
+ out += strlen(whole);
601
+ // "frac" contains a leading zero, which we don't want
602
+ strcpy(out, frac + 1);
603
+ }
604
+ free(whole);
605
+ free(frac);
606
+ return ret;
607
+ }
716
608
  }
717
609
 
718
- static inline mc_dec128
719
- mc_dec128_from_bson_iter (bson_iter_t *it)
720
- {
721
- bson_decimal128_t b;
722
- if (!bson_iter_decimal128 (it, &b)) {
723
- mc_dec128 nan = MC_DEC128_POSITIVE_NAN;
724
- return nan;
725
- }
726
- mc_dec128 ret;
727
- memcpy (&ret, &b, sizeof b);
728
- return ret;
610
+ static inline mc_dec128 mc_dec128_from_bson_iter(bson_iter_t *it) {
611
+ bson_decimal128_t b;
612
+ if (!bson_iter_decimal128(it, &b)) {
613
+ mc_dec128 nan = MC_DEC128_POSITIVE_NAN;
614
+ return nan;
615
+ }
616
+ mc_dec128 ret;
617
+ memcpy(&ret, &b, sizeof b);
618
+ return ret;
729
619
  }
730
620
 
731
- static inline bson_decimal128_t
732
- mc_dec128_to_bson_decimal128 (mc_dec128 v)
733
- {
734
- bson_decimal128_t ret;
735
- memcpy (&ret, &v, sizeof ret);
736
- return ret;
621
+ static inline bson_decimal128_t mc_dec128_to_bson_decimal128(mc_dec128 v) {
622
+ bson_decimal128_t ret;
623
+ memcpy(&ret, &v, sizeof ret);
624
+ return ret;
737
625
  }
738
626
 
739
627
  MLIB_C_LINKAGE_END