Merge branch 'bugfix/clang_compatibility' into 'master'
clang compatibility fixes See merge request idf/esp-idf!3912
This commit is contained in:
@@ -31,6 +31,13 @@ typedef enum {
|
||||
SS_QUOTED_ARG_ESCAPED = SS_QUOTED_ARG | SS_FLAG_ESCAPE,
|
||||
} split_state_t;
|
||||
|
||||
/* helper macro, called when done with an argument */
|
||||
#define END_ARG() do { \
|
||||
char_out = 0; \
|
||||
argv[argc++] = next_arg_start; \
|
||||
state = SS_SPACE; \
|
||||
} while(0)
|
||||
|
||||
size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
||||
{
|
||||
const int QUOTE = '"';
|
||||
@@ -47,13 +54,6 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
||||
}
|
||||
int char_out = -1;
|
||||
|
||||
/* helper function, called when done with an argument */
|
||||
void end_arg() {
|
||||
char_out = 0;
|
||||
argv[argc++] = next_arg_start;
|
||||
state = SS_SPACE;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case SS_SPACE:
|
||||
if (char_in == SPACE) {
|
||||
@@ -73,7 +73,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
||||
|
||||
case SS_QUOTED_ARG:
|
||||
if (char_in == QUOTE) {
|
||||
end_arg();
|
||||
END_ARG();
|
||||
} else if (char_in == ESCAPE) {
|
||||
state = SS_QUOTED_ARG_ESCAPED;
|
||||
} else {
|
||||
@@ -93,7 +93,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
||||
|
||||
case SS_ARG:
|
||||
if (char_in == SPACE) {
|
||||
end_arg();
|
||||
END_ARG();
|
||||
} else if (char_in == ESCAPE) {
|
||||
state = SS_ARG_ESCAPED;
|
||||
} else {
|
||||
|
||||
@@ -271,11 +271,14 @@ inline static uint32_t get_ccount(void)
|
||||
return ccount;
|
||||
}
|
||||
|
||||
// Caller is 2 stack frames deeper than we care about
|
||||
#define STACK_OFFSET 2
|
||||
|
||||
#define TEST_STACK(N) do { \
|
||||
if (STACK_DEPTH == N) { \
|
||||
return; \
|
||||
} \
|
||||
callers[N] = __builtin_return_address(N+offset); \
|
||||
callers[N] = __builtin_return_address(N+STACK_OFFSET); \
|
||||
if (!esp_ptr_executable(callers[N])) { \
|
||||
return; \
|
||||
} \
|
||||
@@ -288,7 +291,6 @@ inline static uint32_t get_ccount(void)
|
||||
*/
|
||||
static IRAM_ATTR __attribute__((noinline)) void get_call_stack(void **callers)
|
||||
{
|
||||
const int offset = 2; // Caller is 2 stack frames deeper than we care about
|
||||
bzero(callers, sizeof(void *) * STACK_DEPTH);
|
||||
TEST_STACK(0);
|
||||
TEST_STACK(1);
|
||||
|
||||
@@ -58,6 +58,27 @@ typedef struct {
|
||||
.unused = 0, \
|
||||
.type = RELOC_TYPE_BRANCH }
|
||||
|
||||
/* Comparison function used to sort the relocations array */
|
||||
static int reloc_sort_func(const void* p_lhs, const void* p_rhs)
|
||||
{
|
||||
const reloc_info_t lhs = *(const reloc_info_t*) p_lhs;
|
||||
const reloc_info_t rhs = *(const reloc_info_t*) p_rhs;
|
||||
if (lhs.label < rhs.label) {
|
||||
return -1;
|
||||
} else if (lhs.label > rhs.label) {
|
||||
return 1;
|
||||
}
|
||||
// label numbers are equal
|
||||
if (lhs.type < rhs.type) {
|
||||
return -1;
|
||||
} else if (lhs.type > rhs.type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// both label number and type are equal
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Processing branch and label macros involves four steps:
|
||||
*
|
||||
@@ -203,24 +224,6 @@ esp_err_t ulp_process_macros_and_load(uint32_t load_addr, const ulp_insn_t* prog
|
||||
}
|
||||
|
||||
// step 3: sort relocations array
|
||||
int reloc_sort_func(const void* p_lhs, const void* p_rhs) {
|
||||
const reloc_info_t lhs = *(const reloc_info_t*) p_lhs;
|
||||
const reloc_info_t rhs = *(const reloc_info_t*) p_rhs;
|
||||
if (lhs.label < rhs.label) {
|
||||
return -1;
|
||||
} else if (lhs.label > rhs.label) {
|
||||
return 1;
|
||||
}
|
||||
// label numbers are equal
|
||||
if (lhs.type < rhs.type) {
|
||||
return -1;
|
||||
} else if (lhs.type > rhs.type) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// both label number and type are equal
|
||||
return 0;
|
||||
}
|
||||
qsort(reloc_info, macro_count, sizeof(reloc_info_t),
|
||||
reloc_sort_func);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user