Merge pull request #10801 from gschorcht/esp32_fix_memset_opt

cpu/esp32: fixes the memset optimization problem in esp_wifi/wpa_supplicant
This commit is contained in:
Martine Lenders 2019-01-18 22:31:42 +01:00 committed by GitHub
commit f91f62155d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include "esp_common.h" #include "esp_common.h"
@ -61,6 +62,9 @@ void system_wdt_stop (void);
/** reset the system watchdog timer */ /** reset the system watchdog timer */
void system_wdt_feed (void); void system_wdt_feed (void);
/** memset version that the compiler should not be allowed to optimize this */
void *system_secure_memset(void *s, int c, size_t n);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -595,3 +595,18 @@ void system_wdt_start (void)
TIMERG0.wdt_wprotect = 0; /* enable write protection */ TIMERG0.wdt_wprotect = 0; /* enable write protection */
xt_ints_on(BIT(CPU_INUM_WDT)); xt_ints_on(BIT(CPU_INUM_WDT));
} }
__attribute__((weak)) void
_system_prevent_memset_lto(void *const s, int c, const size_t n)
{
(void) s;
(void) c;
(void) n;
}
void *system_secure_memset(void *s, int c, size_t n)
{
memset(s, c, n);
_system_prevent_memset_lto(s, c, n);
return s;
}

View File

@ -19,6 +19,11 @@
extern "C" { extern "C" {
#endif #endif
#ifdef RIOT_VERSION
#include "syscalls.h"
#define os_memset system_secure_memset
#endif
#include "esp_types.h" #include "esp_types.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>