Skip to content

Commit b7c3920

Browse files
authored
Align with Arduino Core
Reporting changes from esp8266/Arduino#7275
1 parent 1473135 commit b7c3920

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

newlib/libc/sys/xtensa/sys/pgmspace.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,20 @@ extern "C" {
3737
// Allow users to override the alignment with PSTR_ALIGN
3838
#define PSTR_ALIGN 4
3939
#endif
40-
#ifndef PSTR
40+
#ifndef PSTRN
41+
// Multi-alignment variant of PSTR, n controls the alignment and should typically be 1 or 4
4142
// Adapted from AVR-specific code at https://forum.arduino.cc/index.php?topic=194603.0
4243
// Uses C attribute section instead of ASM block to allow for C language string concatenation ("x" "y" === "xy")
43-
#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];}))
44+
#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];}))
45+
#endif
46+
#ifndef PSTR
47+
// PSTR() uses the default alignment defined by PSTR_ALIGN
48+
#define PSTR(s) PSTRN(s,PSTR_ALIGN)
49+
#endif
50+
#ifndef PSTR4
51+
// PSTR4() enforces 4-bytes alignment whatever the value of PSTR_ALIGN
52+
// as required by functions like ets_strlen() or ets_memcpy()
53+
#define PSTR4(s) PSTRN(s,4)
4454
#endif
4555

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

0 commit comments

Comments
 (0)