1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-21 21:22:31 +03:00
Files
esp8266/cores/esp8266/core_esp8266_version.h
Earle F. Philhower, III 8e46a3371d Increase free IRAM (#5499)
* Move functions out of IRAM when possible

umm_init() is called in OS startup after flash is enabled, and never
again.

cont_get_free_stack() shouldn't be called from IRQ.

Don't inline _iram_read_byte() function.

* Move system fault handler to flash, use new printf

The __wrap_system_restart call has been in flash for quite a while and
seems to be working fine.  There were some support routines that were
placed in IRAM (mistakenly thinking the wrap_restart caller was also in
IRAM) which are now moved to flash.

Clean up the printf code to use the new stdlib which handles PGM_P
strings as format and arguments without any difficulty.

* Make STR macro more unique

Add double-underscores to some string assistance macros to avoid
conflicts with user applications.

* Use function, not macro, to save code space

Save ~2KB final bin size by using a ets_printf_P function and not
an inline macro.  IRAM and HEAP unaffected.

* Don't actually touch the SP in the dump

Store a copy of the incoming stack pointer in the postmortem in order
to avoid actually changing the SP when a crash happend in BearSSL.

* Make C++ uncaught exceptions explicit

Use the term "Unhandled C++ exception" instead of just "Unhandled
exception" to make it clear such crashes are caused by a C++ throw
and now a system exception.
2018-12-15 10:14:30 -08:00

166 lines
4.2 KiB
C++

/*
core_esp8266_version.h - parse "git describe" at compile time
Copyright (c) 2018 david gauchard. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __CORE_ESP8266_VERSION_H
#define __CORE_ESP8266_VERSION_H
#include <core_version.h>
#define __STRHELPER(x) #x
#define __STR(x) __STRHELPER(x)
#ifdef __cplusplus
extern "C++"
{
// Following constexpr functions are compiled and executed
// *after* pre-processing and *during* compilation
//
// Their result is treated like a numeric constant in final binary code.
// git tags must be in the form:
// - <major>.<minor>.<revision> (2.4.2) (2.5.0)
// - <major>.<minor>.<revision>-rc<rc> (2.5.0-rc1) (2.5.0-rc2)
//
// "git describe" = ARDUINO_ESP8266_GIT_DESC will thus be in the form:
// - <tag> (2.4.2) (2.5.0)
// - <tag>-<numberOfCommits>-g<git-hash> (2.4.2-91-gcb05b86d) (2.5.0-rc3-1-gcb05b86d)
//
// Examples:
// case 2.4.2 (fresh version/tag)
// esp8266CoreVersionSubRevision() is 0 Numeric is: 20402000
// case 2.4.2-91-gcb05b86d:
// esp8266CoreVersionSubRevision() is -91 Numeric is: 20402091
// case 2.5.0-rc3-1-gcb05b86d:
// esp8266CoreVersionSubRevision() is 3 Numeric is: 20499903
// case 2.5.0:
// esp8266CoreVersionSubRevision() is 0 Numeric is: 20500000
namespace conststr {
constexpr
bool isDecimal (const char c)
{
return c >= '0' && c <= '9';
}
template<unsigned N> constexpr
bool isMinus (const char (&arr) [N], unsigned i)
{
return arr[i] == '-' && isDecimal(arr[i+1]);
}
template<unsigned N> constexpr
int atoi (const char (&arr) [N], unsigned i)
{
return ({ // <= c++11 requires a "return statement"
int ret = 0;
int sign = 1;
if (arr[i] == '-')
{
sign = -1;
i++;
}
while (isDecimal(arr[i]))
ret = 10*ret + arr[i++] - '0';
ret * sign;
});
}
template<unsigned N> constexpr
int parseNthInteger (const char (&arr) [N], unsigned f)
{
return ({ // <= c++11 requires a "return statement"
unsigned i = 0;
while (f && arr[i])
{
if (isMinus(arr, i))
i++;
for (; isDecimal(arr[i]); i++);
f--;
for (; arr[i] && !isMinus(arr, i) && !isDecimal(arr[i]); i++);
}
atoi(arr, i);
});
}
}; // namespace conststr
namespace esp8266 {
/*
* version major
*/
constexpr
int coreVersionMajor ()
{
return conststr::parseNthInteger(__STR(ARDUINO_ESP8266_GIT_DESC), 0);
}
/*
* version minor
*/
constexpr
int coreVersionMinor ()
{
return conststr::parseNthInteger(__STR(ARDUINO_ESP8266_GIT_DESC), 1);
}
/*
* version revision
*/
constexpr
int coreVersionRevision ()
{
return conststr::parseNthInteger(__STR(ARDUINO_ESP8266_GIT_DESC), 2);
}
/*
* git commit number since last tag (negative)
* or RC-number (positive)
*/
constexpr
int coreVersionSubRevision ()
{
return conststr::parseNthInteger(__STR(ARDUINO_ESP8266_GIT_DESC), 3);
}
/*
* unique revision indentifier (never decreases)
*/
constexpr
int coreVersionNumeric ()
{
return coreVersionMajor() * 10000000
+ coreVersionMinor() * 100000
+ coreVersionRevision() * 1000
+ (coreVersionSubRevision() < 0 ?
-coreVersionSubRevision() :
coreVersionSubRevision() ?
coreVersionSubRevision() - 100 :
0);
}
}; // namespace esp8266
} // extern "C++"
#endif // __cplusplus
#endif // __CORE_ESP8266_ESP8266_VERSION_H