mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-06 05:21:22 +03:00
fix bug #343
add __attribute__ to printf functions for better compiler warning handling. remove ICACHE_FLASH_ATTR, all cpp files are automatic in FLASH (ld script)
This commit is contained in:
parent
1d0a923292
commit
f18bb28813
@ -35,7 +35,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "stdlib_noniso.h"
|
#include "stdlib_noniso.h"
|
||||||
#include "binary.h"
|
#include "binary.h"
|
||||||
#include "pgmspace.h"
|
|
||||||
#include "esp8266_peri.h"
|
#include "esp8266_peri.h"
|
||||||
#include "twi.h"
|
#include "twi.h"
|
||||||
|
|
||||||
@ -205,6 +204,8 @@ void loop(void);
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include "pgmspace.h"
|
||||||
|
|
||||||
#include "WCharacter.h"
|
#include "WCharacter.h"
|
||||||
#include "WString.h"
|
#include "WString.h"
|
||||||
|
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
pgmspace.cpp - string functions that support PROGMEM
|
pgmspace.cpp - string functions that support PROGMEM
|
||||||
Copyright (c) 2015 Michael C. Miller. All right reserved.
|
Copyright (c) 2015 Michael C. Miller. All right reserved.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "pgmspace.h"
|
#include "pgmspace.h"
|
||||||
|
|
||||||
size_t ICACHE_FLASH_ATTR strnlen_P(const char* s, size_t size) {
|
size_t strnlen_P(const char* s, size_t size) {
|
||||||
const char* cp;
|
const char* cp;
|
||||||
for (cp = s; size != 0 && pgm_read_byte(cp) != '\0'; cp++, size--);
|
for (cp = s; size != 0 && pgm_read_byte(cp) != '\0'; cp++, size--);
|
||||||
return (size_t)(cp - s);
|
return (size_t) (cp - s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ICACHE_FLASH_ATTR memcpy_P(void* dest, const void* src, size_t count) {
|
void* memcpy_P(void* dest, const void* src, size_t count) {
|
||||||
const uint8_t* read = reinterpret_cast<const uint8_t*>(src);
|
const uint8_t* read = reinterpret_cast<const uint8_t*>(src);
|
||||||
uint8_t* write = reinterpret_cast<uint8_t*>(dest);
|
uint8_t* write = reinterpret_cast<uint8_t*>(dest);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ void* ICACHE_FLASH_ATTR memcpy_P(void* dest, const void* src, size_t count) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ICACHE_FLASH_ATTR strncpy_P(char* dest, const char* src, size_t size) {
|
char* strncpy_P(char* dest, const char* src, size_t size) {
|
||||||
const char* read = src;
|
const char* read = src;
|
||||||
char* write = dest;
|
char* write = dest;
|
||||||
char ch = '.';
|
char ch = '.';
|
||||||
@ -48,19 +48,19 @@ char* ICACHE_FLASH_ATTR strncpy_P(char* dest, const char* src, size_t size) {
|
|||||||
ch = pgm_read_byte(read++);
|
ch = pgm_read_byte(read++);
|
||||||
*write++ = ch;
|
*write++ = ch;
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ICACHE_FLASH_ATTR strncat_P(char* dest, const char* src, size_t size) {
|
char* strncat_P(char* dest, const char* src, size_t size) {
|
||||||
char* write = dest;
|
char* write = dest;
|
||||||
|
|
||||||
while (*write != '\0')
|
while (*write != '\0')
|
||||||
{
|
{
|
||||||
write++;
|
write++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* read = src;
|
const char* read = src;
|
||||||
char ch = '.';
|
char ch = '.';
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ char* ICACHE_FLASH_ATTR strncat_P(char* dest, const char* src, size_t size) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR strncmp_P(const char* str1, const char* str2P, size_t size) {
|
int strncmp_P(const char* str1, const char* str2P, size_t size) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
@ -99,7 +99,7 @@ int ICACHE_FLASH_ATTR strncmp_P(const char* str1, const char* str2P, size_t size
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR strncasecmp_P(const char* str1, const char* str2P, size_t size) {
|
int strncasecmp_P(const char* str1, const char* str2P, size_t size) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
@ -118,7 +118,7 @@ int ICACHE_FLASH_ATTR strncasecmp_P(const char* str1, const char* str2P, size_t
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR printf_P(const char* formatP, ...) {
|
int printf_P(const char* formatP, ...) {
|
||||||
int ret;
|
int ret;
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
va_start(arglist, formatP);
|
va_start(arglist, formatP);
|
||||||
@ -129,13 +129,13 @@ int ICACHE_FLASH_ATTR printf_P(const char* formatP, ...) {
|
|||||||
|
|
||||||
ret = os_printf(format, arglist);
|
ret = os_printf(format, arglist);
|
||||||
|
|
||||||
delete [] format;
|
delete[] format;
|
||||||
|
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR snprintf_P(char* str, size_t strSize, const char* formatP, ...) {
|
int snprintf_P(char* str, size_t strSize, const char* formatP, ...) {
|
||||||
int ret;
|
int ret;
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
va_start(arglist, formatP);
|
va_start(arglist, formatP);
|
||||||
@ -146,7 +146,7 @@ int ICACHE_FLASH_ATTR snprintf_P(char* str, size_t strSize, const char* formatP,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ICACHE_FLASH_ATTR vsnprintf_P(char* str, size_t strSize, const char* formatP, va_list ap) {
|
int vsnprintf_P(char* str, size_t strSize, const char* formatP, va_list ap) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
size_t fmtLen = strlen_P(formatP);
|
size_t fmtLen = strlen_P(formatP);
|
||||||
@ -155,7 +155,7 @@ int ICACHE_FLASH_ATTR vsnprintf_P(char* str, size_t strSize, const char* formatP
|
|||||||
|
|
||||||
ret = ets_vsnprintf(str, strSize, format, ap);
|
ret = ets_vsnprintf(str, strSize, format, ap);
|
||||||
|
|
||||||
delete [] format;
|
delete[] format;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -32,26 +32,26 @@ typedef uint32_t prog_uint32_t;
|
|||||||
|
|
||||||
#define SIZE_IRRELEVANT 0x7fffffff
|
#define SIZE_IRRELEVANT 0x7fffffff
|
||||||
|
|
||||||
extern void* memcpy_P(void* dest, const void* src, size_t count);
|
void* memcpy_P(void* dest, const void* src, size_t count);
|
||||||
|
|
||||||
extern char* strncpy_P(char* dest, const char* src, size_t size);
|
char* strncpy_P(char* dest, const char* src, size_t size);
|
||||||
#define strcpy_P(dest, src) strncpy_P((dest), (src), SIZE_IRRELEVANT)
|
#define strcpy_P(dest, src) strncpy_P((dest), (src), SIZE_IRRELEVANT)
|
||||||
|
|
||||||
extern char* strncat_P(char* dest, const char* src, size_t size);
|
char* strncat_P(char* dest, const char* src, size_t size);
|
||||||
#define strcat_P(dest, src) strncat_P((dest), (src), SIZE_IRRELEVANT)
|
#define strcat_P(dest, src) strncat_P((dest), (src), SIZE_IRRELEVANT)
|
||||||
|
|
||||||
extern int strncmp_P(const char* str1, const char* str2P, size_t size);
|
int strncmp_P(const char* str1, const char* str2P, size_t size);
|
||||||
#define strcmp_P(str1, str2P) strncmp_P((str1), (str2P), SIZE_IRRELEVANT)
|
#define strcmp_P(str1, str2P) strncmp_P((str1), (str2P), SIZE_IRRELEVANT)
|
||||||
|
|
||||||
extern int strncasecmp_P(const char* str1, const char* str2P, size_t size);
|
int strncasecmp_P(const char* str1, const char* str2P, size_t size);
|
||||||
#define strcasecmp_P(str1, str2P) strncasecmp_P((str1), (str2P), SIZE_IRRELEVANT)
|
#define strcasecmp_P(str1, str2P) strncasecmp_P((str1), (str2P), SIZE_IRRELEVANT)
|
||||||
|
|
||||||
extern size_t strnlen_P(const char *s, size_t size);
|
size_t strnlen_P(const char *s, size_t size);
|
||||||
#define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT)
|
#define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT)
|
||||||
|
|
||||||
extern int printf_P(const char *formatP, ...);
|
int printf_P(const char *formatP, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
extern int snprintf_P(char *str, size_t strSize, const char *formatP, ...);
|
int snprintf_P(char *str, size_t strSize, const char *formatP, ...) __attribute__ ((format (printf, 3, 4)));
|
||||||
extern int vsnprintf_P(char *str, size_t strSize, const char *formatP, va_list ap);
|
int vsnprintf_P(char *str, size_t strSize, const char *formatP, va_list ap) __attribute__ ((format (printf, 3, 0)));
|
||||||
|
|
||||||
// flash memory must be read using 32 bit aligned addresses else a processor
|
// flash memory must be read using 32 bit aligned addresses else a processor
|
||||||
// exception will be triggered
|
// exception will be triggered
|
||||||
|
@ -116,6 +116,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint8_t* softAPmacAddress(uint8_t* mac);
|
uint8_t* softAPmacAddress(uint8_t* mac);
|
||||||
String softAPmacAddress(void);
|
String softAPmacAddress(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the station interface IP address.
|
* Get the station interface IP address.
|
||||||
*
|
*
|
||||||
|
@ -118,7 +118,7 @@ void ets_isr_unmask(int intr);
|
|||||||
void ets_isr_attach(int intr, int_handler_t handler, void *arg);
|
void ets_isr_attach(int intr, int_handler_t handler, void *arg);
|
||||||
void ets_intr_lock();
|
void ets_intr_lock();
|
||||||
void ets_intr_unlock();
|
void ets_intr_unlock();
|
||||||
int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg);
|
int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));
|
||||||
int ets_vprintf(const char * format, va_list arg);
|
int ets_vprintf(const char * format, va_list arg) __attribute__ ((format (printf, 1, 0)));
|
||||||
|
|
||||||
#endif /* _ETS_SYS_H */
|
#endif /* _ETS_SYS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user