-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package GMP, get rid of gmp_wrapper.c #1887
Comments
I see that on OS X, there is a |
For the record, there are two things that need done for removing gmp_wrapper.c ... it may be doable
|
Ah! Yes, I knew there was a reason for this, but I failed to notice the dereferencing when I was looking through the file. What's up with the exported function name mangling? The |
For reasons that are somewhat obscure, the deref in there isn't actually a deref (a pointer cast to void* would work just as well), so that's actually no problem (it has to do with the interaction of passing an array to a function that expects a pointer and the typedefs used by GMP). They work great for usual C usage in that they behave just as if they were usual structs, but they are actually not. |
The source is so convoluted I can't even figure out what the definition of |
Sure, Jeff, Jameson and I had quite a bit of fun with this one Yesterday. Essentially there is a struct mzp_struct; which is a BigInt. The implementation is not important. Then there are typedef mpz_struct[1] mpz_t;
typedef mpz_struct* mpz_ptr; Now, what we are doing is mpz_t *integer = malloc(sizeof(mpz_t))
mpz_init(*integer) (Note these are all somewhat simplyfied and don't show the actual definition, but should be enough to understand why).
we have
So at least we are allocating the right amount of memory. But notice also that what we are returning is essentially a mpz_ptr (since it's a pointer to an area of memory the size of mpz_struct). Now, why does this still work? Well, consider the prototype of mpz_init
From our above analysis, we see that this should clearly work: mpz_t *integer = malloc(sizeof(mpz_t))
mpz_init((mpz_ptr)integer) but here is the tricky part that involves passing an array to a function that expects a pointer (think of it as passing a char[] to a function that expect a char*). Do do so, the function essentially takes the address of whatever array we are passing to it and passes that as a pointer (but still gives the impression of passing the array by value). So essentially what it's doing is, if we have
So since mpz_t* already points to the memory we need, we need to deref it to essentially cancel the taking of address done by the function call. Hope that helps.
|
Jeez. This feels like C++. Thanks for explaining. |
I guess we cannot really do away with the wrapper then. Close this? |
Yeah, we can, the GMP functions all just take a pointer. |
On the name mangling, in deps/gmp-5.0.5/gmp.h, generated at compile time from gmp-h.in
I am not sure how these differ from one system to another. |
I don't think that varies from system to system at all actually. |
Closed by a42f263 |
$ git log --pretty=oneline --abbrev=commit f9a5cc7..13456b9 13456b944fd21ec180111c6c29d06b610d47d088 Deprecate the REPL command `] generate` (#1923) 3eee6eb25974c2f320706da1b81ce1f7e1d82165 BinaryPlatforms: Recognize MacOS(:aarch64) (#1916) a8cc6d670ebe55002c5d5efb7fb19315c0c1cd55 Telemetry CI variables: add CI_SERVER, JULIA_PKGEVAL, JULIA_REGISTRYCI_AUTOMERGE, and PKGEVAL (#1906) ae897bc44070f902b5b01da80478ed51c1b518c0 Fix invalidations from loading OrderedCollections (#1897) 69bc387b3932d3d709b656e1ef929c4a2592fcee fix path returned from find_install (#1908) 46c9d430d545ecd70b147942857d775b2834e54b Update environments.md (#1896) 20f9b9e14ab59d81991b5984a2f9eb87d38b6230 Merge pull request #1869 from JuliaLang/teh/inval3 605f48849fa6b3bf29e6785967d4ef2249da9976 - only test on nightly, test without Pkg server as well - CI: build docs on nightly 7e0c911591f5d62acb476f74c59a9cad9c7a1f7d Avoid a strange inference limit when broadcasting f92ee5786468a7d0e836a94b0bb09711faef78da Use `maximum(itr; init=default)` d524d0f7f8cfef8abe429d3b947157eacb84f8ea Avoid calling ==(::Any, ::Nothing) in read_field 2acb2f9ca7f8b908954d6fdde074b65e30b8395f Add more type info 9b5e38e0ee2a0747b5ca7125a3a1f347cbd61708 Improve inference for Platform 0ebffb95d9793689d4c72198ae4804b0745ee16e Pre-allocate `seen` to improve inference in `unique(f, itr)` 160efbea2b56dc8a7a9a5ed8f795fa8995a4f09b Eliminate some boxing cdfc445873fc1d5df8838dd080e125bcce587dc6 docs: delete note about gen-project script (#1887) 531861f6677f434f6d594212d1085ac5bc309328 Make tree hash computation non-fatal when installing artifacts. (#1885) ce4a41ee7d232b90da925fa9ebe246618de8ada4 Misc fixes (#1884) f80d44345f61d0c1a02650f33322f9a330aa77d1 Disable SIGQUIT test that regularly segfaults on CI. (#1883) 2328d1bcd919bd9fc038af3f1cedf43a22d28e30 telemetry: don't send hash without active project 08fe651707d6deb392950f71c3ea776a2c8337c9 telemetry: use RandomDevice for random values c213096ea6210f66945443658b6548012dff5ec9 Improve Artifacts documentation by adding a Basic Usage section (#1879) d8fde7e85b72c86cdae395a1ea13485c193dc35e fix typo in telemetry notice (#1877) 188893dfdb6608cd5bcab18c6d365843cf1c6056 Merge pull request #1871 from JuliaLang/sk/telemetry ab88ea9c3ea05a70c2e014e6ceb5ce55a7fa9cf7 telemetry notice: reword a bit, factor into function 341dfd0bfafb994bd7c71271d2a458e314f3af4c telemetry: don't send salt hash header ae99ba2ed9d9cd7f9962a2515fd62054eb644097 telemetry notice: only print once per process 636d333a263640650d09b08a568e8e128bf6c00c Add a poor-mans file lock for telemetry file. b24ca68ed000139507d179f49a04df7c7b93d14c telemetry: print legal notice first time talking to each pkg server bd07a8d6439ffbe55f9aaf22ea5e2c451ee480cb telemetry: ~/.julia/servers/telemetry.toml for defaults 70dfbd2c59c4110a6c4775414202b4df840acf21 telemetry: HyperLogLog estimator 3e3f9d7a3baf3a96c860d2b1bc895d5fd2d40d35 README: howto build Julia with git checkout of Pkg (#1864) 100eaa9b0ea0a2b95072c77bdf7060e72479fe13 Fix bug which made `registry up` a no-op instead of updating all user-registries. (#1862)
$ git log --pretty=oneline --abbrev=commit f9a5cc7..13456b9 13456b944fd21ec180111c6c29d06b610d47d088 Deprecate the REPL command `] generate` (#1923) 3eee6eb25974c2f320706da1b81ce1f7e1d82165 BinaryPlatforms: Recognize MacOS(:aarch64) (#1916) a8cc6d670ebe55002c5d5efb7fb19315c0c1cd55 Telemetry CI variables: add CI_SERVER, JULIA_PKGEVAL, JULIA_REGISTRYCI_AUTOMERGE, and PKGEVAL (#1906) ae897bc44070f902b5b01da80478ed51c1b518c0 Fix invalidations from loading OrderedCollections (#1897) 69bc387b3932d3d709b656e1ef929c4a2592fcee fix path returned from find_install (#1908) 46c9d430d545ecd70b147942857d775b2834e54b Update environments.md (#1896) 20f9b9e14ab59d81991b5984a2f9eb87d38b6230 Merge pull request #1869 from JuliaLang/teh/inval3 605f48849fa6b3bf29e6785967d4ef2249da9976 - only test on nightly, test without Pkg server as well - CI: build docs on nightly 7e0c911591f5d62acb476f74c59a9cad9c7a1f7d Avoid a strange inference limit when broadcasting f92ee5786468a7d0e836a94b0bb09711faef78da Use `maximum(itr; init=default)` d524d0f7f8cfef8abe429d3b947157eacb84f8ea Avoid calling ==(::Any, ::Nothing) in read_field 2acb2f9ca7f8b908954d6fdde074b65e30b8395f Add more type info 9b5e38e0ee2a0747b5ca7125a3a1f347cbd61708 Improve inference for Platform 0ebffb95d9793689d4c72198ae4804b0745ee16e Pre-allocate `seen` to improve inference in `unique(f, itr)` 160efbea2b56dc8a7a9a5ed8f795fa8995a4f09b Eliminate some boxing cdfc445873fc1d5df8838dd080e125bcce587dc6 docs: delete note about gen-project script (#1887) 531861f6677f434f6d594212d1085ac5bc309328 Make tree hash computation non-fatal when installing artifacts. (#1885) ce4a41ee7d232b90da925fa9ebe246618de8ada4 Misc fixes (#1884) f80d44345f61d0c1a02650f33322f9a330aa77d1 Disable SIGQUIT test that regularly segfaults on CI. (#1883) 2328d1bcd919bd9fc038af3f1cedf43a22d28e30 telemetry: don't send hash without active project 08fe651707d6deb392950f71c3ea776a2c8337c9 telemetry: use RandomDevice for random values c213096ea6210f66945443658b6548012dff5ec9 Improve Artifacts documentation by adding a Basic Usage section (#1879) d8fde7e85b72c86cdae395a1ea13485c193dc35e fix typo in telemetry notice (#1877) 188893dfdb6608cd5bcab18c6d365843cf1c6056 Merge pull request #1871 from JuliaLang/sk/telemetry ab88ea9c3ea05a70c2e014e6ceb5ce55a7fa9cf7 telemetry notice: reword a bit, factor into function 341dfd0bfafb994bd7c71271d2a458e314f3af4c telemetry: don't send salt hash header ae99ba2ed9d9cd7f9962a2515fd62054eb644097 telemetry notice: only print once per process 636d333a263640650d09b08a568e8e128bf6c00c Add a poor-mans file lock for telemetry file. b24ca68ed000139507d179f49a04df7c7b93d14c telemetry: print legal notice first time talking to each pkg server bd07a8d6439ffbe55f9aaf22ea5e2c451ee480cb telemetry: ~/.julia/servers/telemetry.toml for defaults 70dfbd2c59c4110a6c4775414202b4df840acf21 telemetry: HyperLogLog estimator 3e3f9d7a3baf3a96c860d2b1bc895d5fd2d40d35 README: howto build Julia with git checkout of Pkg (#1864) 100eaa9b0ea0a2b95072c77bdf7060e72479fe13 Fix bug which made `registry up` a no-op instead of updating all user-registries. (#1862)
$ git log --pretty=oneline --abbrev=commit f9a5cc7..13456b9 13456b944fd21ec180111c6c29d06b610d47d088 Deprecate the REPL command `] generate` (JuliaLang#1923) 3eee6eb25974c2f320706da1b81ce1f7e1d82165 BinaryPlatforms: Recognize MacOS(:aarch64) (JuliaLang#1916) a8cc6d670ebe55002c5d5efb7fb19315c0c1cd55 Telemetry CI variables: add CI_SERVER, JULIA_PKGEVAL, JULIA_REGISTRYCI_AUTOMERGE, and PKGEVAL (JuliaLang#1906) ae897bc44070f902b5b01da80478ed51c1b518c0 Fix invalidations from loading OrderedCollections (JuliaLang#1897) 69bc387b3932d3d709b656e1ef929c4a2592fcee fix path returned from find_install (JuliaLang#1908) 46c9d430d545ecd70b147942857d775b2834e54b Update environments.md (JuliaLang#1896) 20f9b9e14ab59d81991b5984a2f9eb87d38b6230 Merge pull request JuliaLang#1869 from JuliaLang/teh/inval3 605f48849fa6b3bf29e6785967d4ef2249da9976 - only test on nightly, test without Pkg server as well - CI: build docs on nightly 7e0c911591f5d62acb476f74c59a9cad9c7a1f7d Avoid a strange inference limit when broadcasting f92ee5786468a7d0e836a94b0bb09711faef78da Use `maximum(itr; init=default)` d524d0f7f8cfef8abe429d3b947157eacb84f8ea Avoid calling ==(::Any, ::Nothing) in read_field 2acb2f9ca7f8b908954d6fdde074b65e30b8395f Add more type info 9b5e38e0ee2a0747b5ca7125a3a1f347cbd61708 Improve inference for Platform 0ebffb95d9793689d4c72198ae4804b0745ee16e Pre-allocate `seen` to improve inference in `unique(f, itr)` 160efbea2b56dc8a7a9a5ed8f795fa8995a4f09b Eliminate some boxing cdfc445873fc1d5df8838dd080e125bcce587dc6 docs: delete note about gen-project script (JuliaLang#1887) 531861f6677f434f6d594212d1085ac5bc309328 Make tree hash computation non-fatal when installing artifacts. (JuliaLang#1885) ce4a41ee7d232b90da925fa9ebe246618de8ada4 Misc fixes (JuliaLang#1884) f80d44345f61d0c1a02650f33322f9a330aa77d1 Disable SIGQUIT test that regularly segfaults on CI. (JuliaLang#1883) 2328d1bcd919bd9fc038af3f1cedf43a22d28e30 telemetry: don't send hash without active project 08fe651707d6deb392950f71c3ea776a2c8337c9 telemetry: use RandomDevice for random values c213096ea6210f66945443658b6548012dff5ec9 Improve Artifacts documentation by adding a Basic Usage section (JuliaLang#1879) d8fde7e85b72c86cdae395a1ea13485c193dc35e fix typo in telemetry notice (JuliaLang#1877) 188893dfdb6608cd5bcab18c6d365843cf1c6056 Merge pull request JuliaLang#1871 from JuliaLang/sk/telemetry ab88ea9c3ea05a70c2e014e6ceb5ce55a7fa9cf7 telemetry notice: reword a bit, factor into function 341dfd0bfafb994bd7c71271d2a458e314f3af4c telemetry: don't send salt hash header ae99ba2ed9d9cd7f9962a2515fd62054eb644097 telemetry notice: only print once per process 636d333a263640650d09b08a568e8e128bf6c00c Add a poor-mans file lock for telemetry file. b24ca68ed000139507d179f49a04df7c7b93d14c telemetry: print legal notice first time talking to each pkg server bd07a8d6439ffbe55f9aaf22ea5e2c451ee480cb telemetry: ~/.julia/servers/telemetry.toml for defaults 70dfbd2c59c4110a6c4775414202b4df840acf21 telemetry: HyperLogLog estimator 3e3f9d7a3baf3a96c860d2b1bc895d5fd2d40d35 README: howto build Julia with git checkout of Pkg (JuliaLang#1864) 100eaa9b0ea0a2b95072c77bdf7060e72479fe13 Fix bug which made `registry up` a no-op instead of updating all user-registries. (JuliaLang#1862)
BigInt and BigFloat should be provided as a GMP package rather than living in extras. Also, looking through gmp_wrapper.c, it seems like we can do all of this stuff without the wrapper entirely if we generated a libgmp dynamic library instead.
The text was updated successfully, but these errors were encountered: