Skip to content

msp430: provide oneway-malloc implicitly#1182

Merged
Kijewski merged 3 commits intoRIOT-OS:masterfrom
Kijewski:msp-oneway-malloc
May 23, 2014
Merged

msp430: provide oneway-malloc implicitly#1182
Kijewski merged 3 commits intoRIOT-OS:masterfrom
Kijewski:msp-oneway-malloc

Conversation

@Kijewski
Copy link
Copy Markdown
Contributor

For MSP430 boards oneway-malloc is already used if malloc.h was
included. The problem is that malloc.h is not a standard header, even
though it is common. stdlib.h in the right place to look for
malloc() and friends.

This change removes this discrepancy. malloc() is just named like
that, without the leading underscore. The symbols now are weak, which
means that they won't override library functions if MSP's standard
library will provide these functions at some point. (Unlikely, since
using malloc() on tiny systems is less then optimal ...)

@Kijewski
Copy link
Copy Markdown
Contributor Author

Fixes #1061 and #863.

@BytesGalore
Copy link
Copy Markdown
Member

nice. I like the idea to exploit __attribute__((weak)) to keep compatibility with library functions.

@OlegHahm
Copy link
Copy Markdown
Member

Nice one indeed, but please migrate the doxygen documentation as well.

@Kijewski
Copy link
Copy Markdown
Contributor Author

Doxygen added.

@Kijewski
Copy link
Copy Markdown
Contributor Author

The last commit brings realloc() in order with the standard.

@Kijewski Kijewski added this to the Release 2014.05 milestone May 15, 2014
@OlegHahm
Copy link
Copy Markdown
Member

Here comes your first ACK. Second needed because of (minor) core changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the year

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only moved the file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mehlis
Copy link
Copy Markdown
Contributor

mehlis commented May 16, 2014

Yeaa, this makes the core even smaller!

I don't have the hardware, but I think this is PR is ok

@rousselk do you like it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now msp430 right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there such a Doxygen group?

@mehlis
Copy link
Copy Markdown
Contributor

mehlis commented May 16, 2014

this reduces the size of the text section for the hello world example from 51572 to 51556 : 16 bytes reduced

@Kijewski
Copy link
Copy Markdown
Contributor Author

I don't have the hardware, but I think this is PR is ok.

Darn, I forgot to take the MSB-430 with me after the LNdW.

@Kijewski
Copy link
Copy Markdown
Contributor Author

16 bytes reduced

I daresay that this is spurious, at lease it was not intended. It's just a residue of the alignment of the system.

(Github recently shows my comments twice for me, and deletes both if I try to delete the extra one. -_- As I'm not going to try to clean up any probably non-existent mess anymore, please delete any duplicated comments of me if you cross some.)

@OlegHahm
Copy link
Copy Markdown
Member

Hereby I revoke my former ACK (for now). Reason: The oneway malloc implementation might be useful for other platforms/toolchains than MSP430.

@LudwigKnuepfer
Copy link
Copy Markdown
Member

@Kijewski the double comments disappear if you reload the page - its a JS bug I guess.

@Kijewski
Copy link
Copy Markdown
Contributor Author

It's now a sys module, and a default module for MSP boards.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to change this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Into what? :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

@addtogroup oneway_malloc
@ingroup sys

?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be changed as the file is not in core anymore!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kijewski, you're gonna change this?

@OlegHahm OlegHahm assigned haukepetersen and unassigned OlegHahm May 19, 2014
@kaspar030
Copy link
Copy Markdown
Contributor

can we have a generic 'malloc' module and make all modules that need it depend on it?
The core doesn't need malloc, so a minimal compile shouldn't include it by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason, the header is not in $(RIOTBASE)/sys/include as all other sys-headers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to shadow the malloc.h of the libc. E.g. the function memalign is missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, makes sense.

@haukepetersen
Copy link
Copy Markdown
Contributor

I think the PR is fine. I would also opt for enabling the oneway-malloc module as default for msp430 platforms - when its not needed, it is not linked in...

So if the above issues are addressed I'd give it a go.

@Kijewski
Copy link
Copy Markdown
Contributor Author

@haukepetersen comments addressed.

@haukepetersen
Copy link
Copy Markdown
Contributor

Please view new comments.

@Kijewski
Copy link
Copy Markdown
Contributor Author

copyright notice added.

Kijewski added 3 commits May 22, 2014 15:40
For MSP430 boards oneway-malloc is already used *if* `malloc.h` was
included. The problem is that `malloc.h` is not a standard header, even
though it is common. `stdlib.h` in the right place to look for
`malloc()` and friends.

This change removes this discrepancy. `malloc()` is just named like
that, without the leading underscore. The symbols now are weak, which
means that they won't override library functions if MSP's standard
library will provide these functions at some point. (Unlikely, since
using `malloc()` on tiny systems is less then optimal ...)

Closes #1061 and #863.
@Kijewski
Copy link
Copy Markdown
Contributor Author

Doxygen group changed.

@Kijewski
Copy link
Copy Markdown
Contributor Author

Should be ready to merge.

@haukepetersen
Copy link
Copy Markdown
Contributor

ACK. Maybe you can squash before you merge...

Kijewski added a commit that referenced this pull request May 23, 2014
msp430: provide oneway-malloc implicitly
@Kijewski Kijewski merged commit e8bf4ef into RIOT-OS:master May 23, 2014
@Kijewski Kijewski deleted the msp-oneway-malloc branch May 23, 2014 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform: MSP Platform: This PR/issue effects MSP-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants