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

Experiment: replace the standard heap in NuttX with O1Heap #1

Open
pavel-kirienko opened this issue Jan 25, 2020 · 2 comments
Open
Labels
help wanted Extra attention is needed

Comments

@pavel-kirienko
Copy link
Owner

Stock NuttX seems to be using a standard O(n) best-fit list-traversal allocator. It should be trivial to replace and benchmark.

@nacansino
Copy link

Regarding using O1Heap with NuttX, I tried allocating a memory arena for use with O1Heap on a dynamically allocated C++ wrapper class (with new) on a PX4 fmuv3 build.

The compiler then throws an error upon instantiating the class about alignment. (Note that this should just be a warning but it seems that the PX4 build demands that all warnings be turned into errors.

error:

error: ‘new’ of type ‘UAVCAN’ with extended alignment 16 [-Waligned-new=]

Code

private:

    static size_t constexpr HEAP_SIZE = 4096;

    uint8_t _base[HEAP_SIZE] __attribute__ ((aligned (O1HEAP_ALIGNMENT)));

Setting the alignment to 8 suppresses the warning, but as per O1Heap specifications, the heap must be aligned at the value specified on the O1HEAP_ALIGNMENT definition.

Is this a known issue?

@pavel-kirienko
Copy link
Owner Author

It's not an issue. The compiler is merely telling you that O1HEAP_ALIGNMENT > alignof(std::max_align_t), where O1HEAP_ALIGNMENT = 16 and alignof(std::max_align_t) = 8, which is natural for many 32-bit platforms. You should relax the alignment requirement on your type to avoid this diagnostic; at any rate, it is not related to O1Heap in any way.

@pavel-kirienko pavel-kirienko added the help wanted Extra attention is needed label May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants