newlib printf() stack usage

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

newlib printf() stack usage

511 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dpursell on Wed Aug 29 12:36:04 MST 2012
Hello,

I'm working in C++ with newlib (nohost) and retargeting stdout to a UART. I am finding that printf() takes up an absurd amount of stack space. I realize it is a very complex function, but looking at the disassembly I'm seeing the internal function _vfprintf_r() reserve 1392 bytes on the stack plus registers. In addition this function recurses, meaning my printf() call is taking almost 3000 bytes on the stack.

My questions are:
1. Is there a way to modify the stack requirements for _vfprintf_r(), possibly by defining a maximum string size or something similar?
2. What condition causes _vfprintf_r() to recurse? Can _vfprintf_r() recurse more than once?

To be clear, I don't really care how much code space the function takes, I'm just concerned with the run-time stack requirements.

Thank you!
0 项奖励
0 回复数