-
Notifications
You must be signed in to change notification settings - Fork 2k
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
timex_t functions byReference instead of byValue #2298
Comments
#include <stdint.h>
typedef struct {
uint32_t seconds;
uint32_t microseconds;
} timex_t;
extern timex_t add1(const timex_t a, const timex_t b);
extern timex_t add2(const timex_t *a, const timex_t *b);
extern void add3(const timex_t *a, const timex_t *b, timex_t *r);
extern timex_t a, b, r;
void test_add1(void) {
r = add1(a, b);
}
void test_add2(void) {
r = add2(&a, &b);
}
void test_add3(void) {
add3(&a, &b, &r);
} Interesting are the push and pop operations: i386:
arm-none-eabi:
avr:
msp430:
In terms of stack space I think we have a winner. |
There was some discussion already here: #1843 (comment) |
I changed the classification of this issue to reflect the answer to the former question. |
@Kijewski Nice comparison. Makes me want a script that creates it... |
@Kijewski Could you compare again compiling with LTO? edit let me think more about this, if LTO has any effect, it probably won't affect stack usage. |
This is the line that I used to get the data: msp430-gcc -fdata-sections -ffunction-sections -fomit-frame-pointer -ggdb3 -Os -c x.c && msp430-objdump -dC x.o Seeing LTO in action will be more difficult to test. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Sometimes I get the warning/error - not sure what it is - from travis/cppcheck saying:
#2155#issuecomment-69809181
Looking at the function definitions:
Wouldn't it make sense to really change these parameters to be pointers instead?
What's your view on this?
The text was updated successfully, but these errors were encountered: