mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Add a polyfill for pgm_read_dword() (issue #1433)
				
					
				
			This commit is contained in:
		| @@ -31,10 +31,6 @@ inline float pgm_read_float(const void* p) { | ||||
|   return *reinterpret_cast<const float*>(convertFlashToPtr(p)); | ||||
| } | ||||
|  | ||||
| inline uint32_t pgm_read_dword(const void* p) { | ||||
|   return *reinterpret_cast<const uint32_t*>(convertFlashToPtr(p)); | ||||
| } | ||||
|  | ||||
| #define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value)        \ | ||||
|   static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \ | ||||
|   static type const* name = reinterpret_cast<type const*>(         \ | ||||
|   | ||||
| @@ -14,7 +14,7 @@ namespace ARDUINOJSON_NAMESPACE { | ||||
| // Wraps a const char* so that the our functions are picked only if the | ||||
| // originals are missing | ||||
| struct pgm_p { | ||||
|   pgm_p(const char* p) : address(p) {} | ||||
|   pgm_p(const void* p) : address(reinterpret_cast<const char*>(p)) {} | ||||
|   const char* address; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| @@ -95,3 +95,11 @@ inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) { | ||||
|   return dst; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #ifndef pgm_read_dword | ||||
| inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) { | ||||
|   uint32_t result; | ||||
|   memcpy_P(&result, p, 4); | ||||
|   return result; | ||||
| } | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user