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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
- data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
- data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +154 -26
- metadata.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
- /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
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /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
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /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 <
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
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
|
52
|
+
#define _mcDec128Align(n) __declspec(align(n))
|
53
53
|
#endif
|
54
54
|
#else
|
55
55
|
#if !defined HPUX_OS
|
56
|
-
#define _mcDec128Align(n) __attribute__
|
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
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
86
|
-
|
87
|
-
#define _mcDec128Combination(Bits) ((uint64_t)
|
88
|
-
#define _mcDec128ZeroExpCombo _mcDec128Combination
|
89
|
-
#define _mcDec128Const(N, Negate)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
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
|
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
|
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
|
120
|
-
#define _mcDec128InfCombo
|
121
|
-
|
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
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
150
|
-
|
151
|
-
|
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
|
-
|
166
|
-
|
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
|
-
|
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
|
-
|
194
|
-
|
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
|
-
|
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
|
-
|
218
|
-
|
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
|
-
|
229
|
-
{
|
230
|
-
|
231
|
-
|
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
|
-
|
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
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
DECL_IDF_COMPARE
|
266
|
-
DECL_IDF_COMPARE
|
267
|
-
DECL_IDF_COMPARE
|
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
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
DECL_PREDICATE
|
283
|
-
DECL_PREDICATE
|
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
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
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
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
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
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
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
|
-
|
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
|
-
|
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
|
388
|
-
|
389
|
-
|
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
|
-
|
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
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
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
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
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
|
-
|
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
|
-
|
466
|
-
|
467
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
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
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
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
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
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
|
-
|
564
|
-
{
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
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
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
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
|
-
|
600
|
-
{
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
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
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
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
|
-
|
720
|
-
{
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
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
|
-
|
733
|
-
|
734
|
-
|
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
|