mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 19:54:32 +02:00
console, ulp: don’t use nested functions
These are not supported by clang Ref LLVM-12
This commit is contained in:
@@ -31,6 +31,13 @@ typedef enum {
|
|||||||
SS_QUOTED_ARG_ESCAPED = SS_QUOTED_ARG | SS_FLAG_ESCAPE,
|
SS_QUOTED_ARG_ESCAPED = SS_QUOTED_ARG | SS_FLAG_ESCAPE,
|
||||||
} split_state_t;
|
} 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)
|
size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
||||||
{
|
{
|
||||||
const int QUOTE = '"';
|
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;
|
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) {
|
switch (state) {
|
||||||
case SS_SPACE:
|
case SS_SPACE:
|
||||||
if (char_in == 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:
|
case SS_QUOTED_ARG:
|
||||||
if (char_in == QUOTE) {
|
if (char_in == QUOTE) {
|
||||||
end_arg();
|
END_ARG();
|
||||||
} else if (char_in == ESCAPE) {
|
} else if (char_in == ESCAPE) {
|
||||||
state = SS_QUOTED_ARG_ESCAPED;
|
state = SS_QUOTED_ARG_ESCAPED;
|
||||||
} else {
|
} else {
|
||||||
@@ -93,7 +93,7 @@ size_t esp_console_split_argv(char *line, char **argv, size_t argv_size)
|
|||||||
|
|
||||||
case SS_ARG:
|
case SS_ARG:
|
||||||
if (char_in == SPACE) {
|
if (char_in == SPACE) {
|
||||||
end_arg();
|
END_ARG();
|
||||||
} else if (char_in == ESCAPE) {
|
} else if (char_in == ESCAPE) {
|
||||||
state = SS_ARG_ESCAPED;
|
state = SS_ARG_ESCAPED;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -58,6 +58,27 @@ typedef struct {
|
|||||||
.unused = 0, \
|
.unused = 0, \
|
||||||
.type = RELOC_TYPE_BRANCH }
|
.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:
|
/* 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
|
// 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),
|
qsort(reloc_info, macro_count, sizeof(reloc_info_t),
|
||||||
reloc_sort_func);
|
reloc_sort_func);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user