From 1bbcb2f9d44b536e3db7de6b0d938371c1228fd7 Mon Sep 17 00:00:00 2001 From: Christopher Andrews Date: Mon, 4 Aug 2014 21:03:32 +1000 Subject: [PATCH] Added replacement stub for cstdlib atexit() funciton. This is an empty stub to simply allow use of complex types with a non global static lifetime. For more complex handling the function 'atexit' can be redefined in user code. For more information see: https://github.com/arduino/Arduino/pull/2229 https://github.com/arduino/Arduino/issues/1919 --- build/shared/revisions.txt | 1 + hardware/arduino/cores/arduino/Arduino.h | 2 ++ hardware/arduino/cores/arduino/main.cpp | 3 +++ 3 files changed, 6 insertions(+) diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index a78397c5f..086fc67d0 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -5,6 +5,7 @@ ARDUINO 1.0.6 - not yet released * avr: Improved USB-CDC write speed (Justin Rajewski) * avr: Improved USB-CDC read code (Paul Brook) * avr: Fixed race condition in USB-CDC transmit (Paul Brook) +* avr: Added replacement stub for cstdlib atexit() funciton (Christopher Andrews) * Fixed wrong NULL pointer handling in Stream class (Amulya Kumar Sahoo) * Backported String class from IDE 1.5.x (Matt Jenkins) * Backported Print class from IDE 1.5.x diff --git a/hardware/arduino/cores/arduino/Arduino.h b/hardware/arduino/cores/arduino/Arduino.h index 425dfcb8d..8673ab8ab 100755 --- a/hardware/arduino/cores/arduino/Arduino.h +++ b/hardware/arduino/cores/arduino/Arduino.h @@ -115,6 +115,8 @@ typedef uint8_t byte; void init(void); void initVariant(void); +int atexit(void (*func)()) __attribute__((weak)); + void pinMode(uint8_t, uint8_t); void digitalWrite(uint8_t, uint8_t); int digitalRead(uint8_t); diff --git a/hardware/arduino/cores/arduino/main.cpp b/hardware/arduino/cores/arduino/main.cpp index 091c365fc..a60980da5 100644 --- a/hardware/arduino/cores/arduino/main.cpp +++ b/hardware/arduino/cores/arduino/main.cpp @@ -19,6 +19,9 @@ #include +//Declared weak in Arduino.h to allow user redefinitions. +int atexit(void (*func)()) { return 0; } + // Weak empty variant initialization function. // May be redefined by variant files. void initVariant() __attribute__((weak));