Skip to content

Commit

Permalink
Align with Arduino Core
Browse files Browse the repository at this point in the history
Reporting changes from esp8266/Arduino#7275
  • Loading branch information
s-hadinger committed May 19, 2020
1 parent 1473135 commit b7c3920
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions newlib/libc/sys/xtensa/sys/pgmspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ extern "C" {
// Allow users to override the alignment with PSTR_ALIGN
#define PSTR_ALIGN 4
#endif
#ifndef PSTR
#ifndef PSTRN
// Multi-alignment variant of PSTR, n controls the alignment and should typically be 1 or 4
// Adapted from AVR-specific code at https://forum.arduino.cc/index.php?topic=194603.0
// 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 __pstr__[] __attribute__((__aligned__(PSTR_ALIGN))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__pstr__[0];}))
#define PSTRN(s,n) (__extension__({static const char __pstr__[] __attribute__((__aligned__(n))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__pstr__[0];}))
#endif
#ifndef PSTR
// PSTR() uses the default alignment defined by PSTR_ALIGN
#define PSTR(s) PSTRN(s,PSTR_ALIGN)
#endif
#ifndef PSTR4
// PSTR4() enforces 4-bytes alignment whatever the value of PSTR_ALIGN
// as required by functions like ets_strlen() or ets_memcpy()
#define PSTR4(s) PSTRN(s,4)
#endif

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

0 comments on commit b7c3920

Please sign in to comment.