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

How to implement a new version of malloc? #23121

Open
Tt421 opened this issue Dec 10, 2024 · 3 comments
Open

How to implement a new version of malloc? #23121

Tt421 opened this issue Dec 10, 2024 · 3 comments

Comments

@Tt421
Copy link

Tt421 commented Dec 10, 2024

I need to use the following version of malloc in my source code:

(i64) -> i32

But I only found the following version of malloc in emscripten:
(i32) -> i32

Does emscripten support other library functions including malloc in i64 version? If not, will it be realized in the future?
If I were to implement other library functions for the i64 version myself, how would I proceed? give me some suggestions, thanks.

@sbc100
Copy link
Collaborator

sbc100 commented Dec 10, 2024

I'm not quite sure I understand your question. The malloc function takes size_t argument and returns a pointer. This means under -sMEMORY64 it will take and return i64 and by default (with wasm32) it will take and return i32.

I don't think size_t can ever be different from pointer size on any platform so I don't see how the return type and the arg type could ever differ.

@Tt421
Copy link
Author

Tt421 commented Dec 11, 2024

Thanks for reply. I understand. And how to use Memory64 in emscripten (version 3.1.14)? I did not find any running programs and commands on official or other sources. Can you give an example to illustrate how to use Memory64?

@kripken
Copy link
Member

kripken commented Dec 11, 2024

The flag is here:

https://emscripten.org/docs/tools_reference/settings_reference.html#memory64

You can find working examples in the test suite by searching for that flag, MEMORY64.

But 3.1.14 may not be new enough. Looking in the changelog, 3.1.49 had many relevant fixes, and only in 3.1.72 was the flag no longer experimental. I would recommend using the latest version.

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

No branches or pull requests

3 participants