mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Implement static initialization guards (#500)
This commit is contained in:
parent
b5684b4641
commit
6fc141772c
@ -25,7 +25,10 @@ extern "C" {
|
|||||||
#include "osapi.h"
|
#include "osapi.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
}
|
}
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <cxxabi.h>
|
||||||
|
|
||||||
|
using __cxxabiv1::__guard;
|
||||||
|
|
||||||
void *operator new(size_t size) {
|
void *operator new(size_t size) {
|
||||||
size = ((size + 3) & ~((size_t)0x3));
|
size = ((size + 3) & ~((size_t)0x3));
|
||||||
@ -56,6 +59,34 @@ void __cxa_deleted_virtual(void) {
|
|||||||
panic();
|
panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t guard;
|
||||||
|
uint8_t ps;
|
||||||
|
} guard_t;
|
||||||
|
|
||||||
|
extern "C" int __cxa_guard_acquire(__guard* pg)
|
||||||
|
{
|
||||||
|
uint8_t ps = xt_rsil(15);
|
||||||
|
if (reinterpret_cast<guard_t*>(pg)->guard) {
|
||||||
|
xt_wsr_ps(ps);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
reinterpret_cast<guard_t*>(pg)->ps = ps;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void __cxa_guard_release(__guard* pg)
|
||||||
|
{
|
||||||
|
reinterpret_cast<guard_t*>(pg)->guard = 1;
|
||||||
|
xt_wsr_ps(reinterpret_cast<guard_t*>(pg)->ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void __cxa_guard_abort(__guard* pg)
|
||||||
|
{
|
||||||
|
xt_wsr_ps(reinterpret_cast<guard_t*>(pg)->ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
void __throw_bad_function_call() {
|
void __throw_bad_function_call() {
|
||||||
panic();
|
panic();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user