cpu/msp430_common: add real malloc/free functions#10944
cpu/msp430_common: add real malloc/free functions#10944kaspar030 merged 1 commit intoRIOT-OS:masterfrom
Conversation
06d4765 to
13b208d
Compare
|
If this is not msp430-specific, I'd rather have it as a module in sys (like oneway_malloc) so it can be reused. I started some work long ago on modularizing some parts of the newlib support code (#9258 ). One problem I see with this implementation is that it is not thread safe. How does this compare to the implementation in baselibc? |
Hm, I think it is MSP430 specific since only AVR and MSP430 do not use newlibc. Since AVR uses
Since it is a simply a slight adaption of
Concerning the complexity and the code size, it seems to be very similar to
|
|
Ok, then let's leave it inside the msp port. But please add some irq save/restore around critical sections. It strikes me that the avr version is not thread safe. I guess that's a good reason to use an alternate implementation (or not use avr.) #10292 should help, yes, but there's this malloc i've been wanting to add for some time now that I think is even better for teeny tiny devices. The problem is riot/newlib integration and the lack of comprehensive tests for malloc. I'm working on this last issue. |
I will do that 😄
The sources of |
@kaspar030 Do you know whether MSP430 is able to interrupt an ISR or is it enough to disable interrupts in critical sections? |
IIRC, both. MSP430 supports nested interrupts, but disabling ISRs protects critical sections from being interrupted. |
|
@jcarrano I have added Furthermore, I used |
jcarrano
left a comment
There was a problem hiding this comment.
Squash and fix the issue reported by coccinelle and we merge.
For this purpose, adapted AVR libc functions are used. When used, malloc and free functions require 304 additional bytes of code compared to the oneway_malloc module.
fc17cb2 to
419cedf
Compare
|
@jcarrano Fixed and finally squashed. Murdock is also satisfied. |
|
@jcarrano We forgot to merge it before feature freeze. That's surly not a problem but we should not forget it again. I didn't megre it since it's a bad style to merge own PRs. |
|
LGTM! |
|
@kaspar030 Thanks 😄 |
Contribution description
This PR realizes real
malloc/freefunctions for MSP430 CPUs. For this purpose adapted AVR libc function are used. Thus, the remaining RAM becomes available as heap.When used,
mallocandfreefunctions require 318 additional bytes of ROM and 7 additional bytes of RAM compared to theoneway_mallocmodule.Testing procedure
Use
tests/mallocwith the current master and the changes in this PR to verify the differences, for example:With current master,
tests/mallocdoesn't work at all and gives no output. With the changes in this PR,mallocandfreefunctions work as expected.Issues/PRs references
Depends on PR #10943