Skip to content
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

allow tomsfastmath to be built without stdlib #34

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

ryancdotorg
Copy link

This commit enables tomsfastmath to be built with --no-standard-libraries provided TFM_NO_STDLIB is defined, which happens automatically if a web assembly build target is detected.

The only functionality this disables is the fp_rand function.

This pull request is also contains the required changes in #32 and #33.

The only use of `malloc`/`free` in tomfastmath is in
src/numtheory/fp_prime_random_ex.c, and the size required can be
calculated from the function arguments, so we can just use
a variable-length automatic array instead.

Variable-length automatic arrays are a C99 feature, and TFM already doesn’t
compile as C90, so we might as well take advantage of it.
fp_ident is the only place tomsfast math uses string manipulation
functions when built as a library. This commit replaces them with
safe, trivial functions for concatonating static strings and numbers
together.
This commit enables tomsfastmath to be built with
`--no-standard-libraries` provided `TFM_NO_STDLIB` is defined, which
happens automatically if a web assembly build target is detected.

The only functionality this disables is the `fp_rand` function.
@ryancdotorg ryancdotorg marked this pull request as draft January 6, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant