mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-24 08:44:08 -04:00
AP_Progmem: identity to use regular strings as PSTRs
This commit is contained in:
parent
e9d41312ca
commit
9f69254c00
@ -6,6 +6,8 @@
|
|||||||
#include "AP_Progmem_AVR.h"
|
#include "AP_Progmem_AVR.h"
|
||||||
#elif defined(DESKTOP_BUILD)
|
#elif defined(DESKTOP_BUILD)
|
||||||
#include "AP_Progmem_DesktopBuild.h"
|
#include "AP_Progmem_DesktopBuild.h"
|
||||||
|
#else
|
||||||
|
#include "AP_Progmem_Identity.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PROGMEM_STRING(_v, _s) static const char _v[] PROGMEM = _s
|
#define PROGMEM_STRING(_v, _s) static const char _v[] PROGMEM = _s
|
||||||
|
49
libraries/AP_Progmem/AP_Progmem_Identity.h
Normal file
49
libraries/AP_Progmem/AP_Progmem_Identity.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
#ifndef __AP_PROGMEM_IDENTITY__
|
||||||
|
#define __AP_PROGMEM_IDENTITY__
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define SITL_debug(fmt, args ...)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char c;
|
||||||
|
} prog_char_t;
|
||||||
|
|
||||||
|
#define PSTR(s) s;
|
||||||
|
|
||||||
|
static inline int strcasecmp_P(const char *str1, const prog_char_t *pstr)
|
||||||
|
{
|
||||||
|
return strcasecmp(str1, pstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int strcmp_P(const char *str1, const prog_char_t *pstr)
|
||||||
|
{
|
||||||
|
return strcmp(str1, pstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline size_t strlen_P(const prog_char_t *pstr)
|
||||||
|
{
|
||||||
|
return strlen(pstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *memcpy_P(void *dest, const prog_char_t *src, size_t n)
|
||||||
|
{
|
||||||
|
return memcpy(dest, src, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline char *strncpy_P(char *buffer, const prog_char_t *pstr, size_t buffer_size)
|
||||||
|
{
|
||||||
|
return strncpy(buffer, pstr, buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// read something the size of a pointer. This makes the menu code more
|
||||||
|
// portable
|
||||||
|
static inline uintptr_t pgm_read_pointer(const void *s) {
|
||||||
|
return &((uintptr_t*)s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __AP_PROGMEM_IDENTITY__
|
||||||
|
|
Loading…
Reference in New Issue
Block a user