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

Support C11 free() #51

Open
phillipjohnston opened this issue Jul 16, 2019 · 3 comments
Open

Support C11 free() #51

phillipjohnston opened this issue Jul 16, 2019 · 3 comments

Comments

@phillipjohnston
Copy link
Member

With aligned_alloc() in the C11 standard, free() is called to free memory, rather than an equivalent aligned_free().

We should update our library with some logic that can be used to correctly call aligned_free() if free() is used instead.

@phillipjohnston
Copy link
Member Author

Maybe we waste a few extra bytes in the aligned space... need a "magic" marker that indicates that this was allocated by aligned_malloc(). If the sentinel matches, then we call the aligned version.

@belmeopmenieuwesim
Copy link

👍 I would be all for this. It is good to mimic how GLIBC behaves. And I don't think the costs outweigh the benefit

@michaeljclark
Copy link

I implemented this in #91 but it is mostly just posted for review at this moment as it needs more testing. I tried it out in emu test_0007_smp.exe where I use it to allocate save restore space for AVX registers using XSAVE/XRSTOR and that will fault if memory is not 64-byte aligned, and it appears to work, but I have not done exhaustive testing yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants