Я видел функцию freeMemory
в https://playground.arduino.cc/Code/AvailableMemory, и она, кажется, использует нечто, называемое __brkval
.Тем не менее, я просто не могу найти, где определен этот макрос или переменная:
$ grep -ri brkval /c/arduino-1.8.8/ --include='*.c' --include='*.h'
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h: extern int* __brkval;
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h: if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h: - reinterpret_cast<int>(__brkval);
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h: extern int* __brkval;
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h: if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h: - reinterpret_cast<int>(__brkval);
$ grep -ri brkval /c/avr-gcc-8.2.0-x64-mingw/ --include='*.c' --include='*.h'
# nothing
$ grep -ri brkval /c/Program\ Files\ \(x86\)/Atmel/Studio/ --include='*.c' --include='*.h'
# nothing
$ grep -ri brkval /c/cvavr/ --include='*.c'
# nothing
То есть, только Arduino IDE имеет некоторые ссылки на него, но только как extern int*
ссылка, у него нет определения.
Ближайшее подробное объяснение пришло от https://github.com/greiman/SdFat/blob/master/src/FreeStack.h:
/** boundary between stack and heap. */
extern char *__brkval;
... но, опять же, без определения.
Итакгде определена эта переменная или макрос?
РЕДАКТИРОВАТЬ: согласно комментариям, поиск по всем файлам:
$ grep -ri brkval /c/cvavr/
# nothing
$ grep -ri brkval /c/Program\ Files\ \(x86\)/Atmel/Studio/
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr25/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr25/tiny-stack/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr3/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr31/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr35/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr4/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr5/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr51/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avr6/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrtiny/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega2/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega3/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega3/short-calls/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega4/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega5/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega6/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/avrxmega7/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/libc.a matches
Binary file /c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/lib/tiny-stack/libc.a matches
/c/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/doc/avr-libc/avr-libc-user-manual/stdlib__private_8h_source.html:<a name="l00045"></a>00045 <span class="keyword">extern</span> <span class="keywordtype">char</span> *__brkval; <span class="comment">/* first location not yet allocated */</span>
$ grep -ri brkval /c/avr-gcc-8.2.0-x64-mingw/
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr25/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr25/tiny-stack/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr3/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr31/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr35/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr4/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr5/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr51/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avr6/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrtiny/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega2/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega4/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega5/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega6/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/avrxmega7/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/libc.a matches
Binary file /c/avr-gcc-8.2.0-x64-mingw/avr/lib/tiny-stack/libc.a matches
$ grep -ri brkval /c/arduino-1.8.8/
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr25/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr25/tiny-stack/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr3/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr31/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr35/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr4/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr5/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr51/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avr6/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrtiny/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega2/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega3/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega3/short-calls/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega4/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega5/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega6/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/avrxmega7/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/libc.a matches
Binary file /c/arduino-1.8.8/hardware/tools/avr/avr/lib/tiny-stack/libc.a matches
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h: extern int* __brkval;
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h: if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/Robot_Control/src/Fat16util.h: - reinterpret_cast<int>(__brkval);
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h: extern int* __brkval;
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h: if (reinterpret_cast<int>(__brkval) == 0) {
/c/arduino-1.8.8/libraries/SD/src/utility/SdFatUtil.h: - reinterpret_cast<int>(__brkval);