Skip to content

Replace ASM block w/C macro for PSTR #6577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cores/esp8266/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ String::~String() {
// /*********************************************/

inline void String::init(void) {
setSSO(false);
setCapacity(0);
setSSO(true);
setLen(0);
setBuffer(nullptr);
wbuffer()[0] = 0;
}

void String::invalidate(void) {
Expand Down
8 changes: 2 additions & 6 deletions tools/sdk/libc/xtensa-lx106-elf/include/sys/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ extern "C" {
// Ref: https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Variable-Attributes.html
// Place each progmem object into its own named section, avoiding conflicts
#define PROGMEM __attribute__((section( "\".irom.text." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\"")))
#define PROGMEM_PSTR "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\""
#endif
#ifndef PGM_P
#define PGM_P const char *
Expand All @@ -36,11 +35,8 @@ extern "C" {
// 1.5 bytes/string, but in return memcpy_P and strcpy_P will work 4~8x faster
#ifndef PSTR
// Adapted from AVR-specific code at https://forum.arduino.cc/index.php?topic=194603.0
#define PSTR(str) (__extension__({ \
PGM_P ptr; \
asm volatile ( ".pushsection " PROGMEM_PSTR ", \"aSM\", @progbits, 1 \n .align 4 \n 0: .string " __STRINGIZE(str) "\n .popsection \n" ); \
asm volatile ( "movi %0, 0b" : "=r" (ptr) ); \
ptr; }))
// Uses C attribute section instead of ASM block to allow for C language string concatenation ("x" "y" === "xy")
#define PSTR(s) (__extension__({static const char __c[] __attribute__((__aligned__(4))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__c[0];}))
#endif

// Flash memory must be read using 32 bit aligned addresses else a processor
Expand Down