Skip to content

Commit

Permalink
Support 64-bit build, support apple clang
Browse files Browse the repository at this point in the history
Map and Vector store pointers so require padding in 64-bit mode.
Array and String must work with IMPORT_FSTR so length cannot be redefined as 64-bit value.
  • Loading branch information
mikee47 authored and mikee47 committed Jun 14, 2024
1 parent b19f7d1 commit 08ff138
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/include/FlashString/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
constexpr const struct { \
FSTR::Array<ElementType> object; \
ElementType data[size]; \
} FSTR_PACKED FSTR_ALIGNED name PROGMEM = {{sizeof(ElementType) * size}, {__VA_ARGS__}}; \
} FSTR_PACKED name PROGMEM = {{sizeof(ElementType) * size}, {__VA_ARGS__}}; \
FSTR_CHECK_STRUCT(name);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/include/FlashString/Map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
constexpr const struct { \
FSTR::Map<KeyType, ContentType> object; \
FSTR::MapPair<KeyType, ContentType> data[size]; \
} FSTR_PACKED FSTR_ALIGNED name PROGMEM = {{sizeof(FSTR::MapPair<KeyType, ContentType>) * size}, {__VA_ARGS__}}; \
} FSTR_PACKED name PROGMEM = {{sizeof(FSTR::MapPair<KeyType, ContentType>) * size}, {__VA_ARGS__}}; \
FSTR_CHECK_STRUCT(name);

namespace FSTR
Expand Down
1 change: 0 additions & 1 deletion src/include/FlashString/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ template <class ObjectType, typename ElementType> class Object : public ObjectBa

FSTR_INLINE DataPtrType data() const
{
// NOLINTNEXTLINE
return reinterpret_cast<DataPtrType>(ObjectBase::data());
}

Expand Down
5 changes: 2 additions & 3 deletions src/include/FlashString/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ typedef const __FlashStringHelper* flash_string_t;
constexpr const struct { \
FSTR::String object; \
char data[ALIGNUP4(sizeof(str))]; \
} name PROGMEM = {{sizeof(str) - 1}, str}; \
} FSTR_PACKED name PROGMEM = {{sizeof(str) - 1}, str}; \
FSTR_CHECK_STRUCT(name);

/**
Expand Down Expand Up @@ -187,7 +187,6 @@ class String : public Object<String, char>
*/
flash_string_t data() const
{
// NOLINTNEXTLINE
return reinterpret_cast<flash_string_t>(Object::data());
}

Expand Down Expand Up @@ -274,7 +273,7 @@ class String : public Object<String, char>
{
return printer().printTo(p);
}
};
} FSTR_PACKED;

} // namespace FSTR

Expand Down
8 changes: 8 additions & 0 deletions src/include/FlashString/Utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ template <typename T, typename U> struct argument_type<T(U)> {
".long _" STR(name) "_end - _" STR(name) " - 4\n" \
".incbin \"" file "\"\n" \
"_" STR(name) "_end:\n");
#elif defined(__APPLE__)
#define IMPORT_FSTR_DATA(name, file) \
__asm__(".const_data\n" \
".globl _" STR(name) "\n" \
".align 4\n" "_" STR(name) ":\n" \
".long _" STR(name) "_end - _" STR(name) " - 4\n" \
".incbin \"" file "\"\n" \
"_" STR(name) "_end:\n");
#elif defined(__arm__)
#define IMPORT_FSTR_DATA(name, file) \
__asm__(".section " ICACHE_RODATA_SECTION "." STR(name) "\n" \
Expand Down
2 changes: 1 addition & 1 deletion src/include/FlashString/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
constexpr const struct { \
FSTR::Vector<ObjectType> object; \
const ObjectType* data[size]; \
} name PROGMEM = {{sizeof(ObjectType*) * size}, {__VA_ARGS__}}; \
} FSTR_PACKED name PROGMEM = {{sizeof(ObjectType*) * size}, {__VA_ARGS__}}; \
FSTR_CHECK_STRUCT(name);

namespace FSTR
Expand Down

0 comments on commit 08ff138

Please sign in to comment.