diff options
| author | Jiaqing Zhao <jiaqing.zhao@linux.intel.com> | 2022-05-23 10:20:13 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-05-23 21:31:31 +0100 |
| commit | c2dc736f15b6bd02d1a1e779bdb097e99367ada7 (patch) | |
| tree | 363ea058c0979929ff3de04ac522356b05a76a6b | |
| parent | e50acb6e49ade1294429d3c3edf040e11fe28488 (diff) | |
| download | poky-c2dc736f15b6bd02d1a1e779bdb097e99367ada7.tar.gz | |
systemd: Drop 0002-don-t-use-glibc-specific-qsort_r.patch
musl 1.2.3 implements qsort_r function.
(From OE-Core rev: 0c2bbf66c7a00268457ac10fed4bef3714da8651)
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch | 163 | ||||
| -rw-r--r-- | meta/recipes-core/systemd/systemd_250.5.bb | 1 |
2 files changed, 0 insertions, 164 deletions
diff --git a/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch b/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch deleted file mode 100644 index d109860e1a..0000000000 --- a/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch +++ /dev/null | |||
| @@ -1,163 +0,0 @@ | |||
| 1 | From c542d2d93cf536e91d4edb8791fdc0de732b0a52 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Chen Qi <Qi.Chen@windriver.com> | ||
| 3 | Date: Mon, 25 Feb 2019 13:41:41 +0800 | ||
| 4 | Subject: [PATCH] don't use glibc-specific qsort_r | ||
| 5 | |||
| 6 | Upstream-Status: Inappropriate [musl specific] | ||
| 7 | |||
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 9 | [Rebased for v241] | ||
| 10 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
| 11 | [Rebased for v242] | ||
| 12 | Signed-off-by: Andrej Valek <andrej.valek@siemens.com> | ||
| 13 | [Rebased for v247] | ||
| 14 | Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> | ||
| 15 | |||
| 16 | --- | ||
| 17 | src/basic/sort-util.h | 14 -------------- | ||
| 18 | src/shared/format-table.c | 36 ++++++++++++++++++++++++------------ | ||
| 19 | src/shared/hwdb-util.c | 19 ++++++++++++++----- | ||
| 20 | 3 files changed, 38 insertions(+), 31 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h | ||
| 23 | index 02a6784d99..cb448df109 100644 | ||
| 24 | --- a/src/basic/sort-util.h | ||
| 25 | +++ b/src/basic/sort-util.h | ||
| 26 | @@ -61,18 +61,4 @@ static inline void _qsort_safe(void *base, size_t nmemb, size_t size, comparison | ||
| 27 | _qsort_safe((p), (n), sizeof((p)[0]), (comparison_fn_t) _func_); \ | ||
| 28 | }) | ||
| 29 | |||
| 30 | -static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, comparison_userdata_fn_t compar, void *userdata) { | ||
| 31 | - if (nmemb <= 1) | ||
| 32 | - return; | ||
| 33 | - | ||
| 34 | - assert(base); | ||
| 35 | - qsort_r(base, nmemb, size, compar, userdata); | ||
| 36 | -} | ||
| 37 | - | ||
| 38 | -#define typesafe_qsort_r(p, n, func, userdata) \ | ||
| 39 | - ({ \ | ||
| 40 | - int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \ | ||
| 41 | - qsort_r_safe((p), (n), sizeof((p)[0]), (comparison_userdata_fn_t) _func_, userdata); \ | ||
| 42 | - }) | ||
| 43 | - | ||
| 44 | int cmp_int(const int *a, const int *b); | ||
| 45 | diff --git a/src/shared/format-table.c b/src/shared/format-table.c | ||
| 46 | index b95680b365..5ffa208615 100644 | ||
| 47 | --- a/src/shared/format-table.c | ||
| 48 | +++ b/src/shared/format-table.c | ||
| 49 | @@ -1324,30 +1324,32 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t | ||
| 50 | return CMP(index_a, index_b); | ||
| 51 | } | ||
| 52 | |||
| 53 | -static int table_data_compare(const size_t *a, const size_t *b, Table *t) { | ||
| 54 | +static Table *user_table; | ||
| 55 | +static int table_data_compare(const void *x, const void *y) { | ||
| 56 | + const size_t *a = x, *b=y; | ||
| 57 | int r; | ||
| 58 | |||
| 59 | - assert(t); | ||
| 60 | - assert(t->sort_map); | ||
| 61 | + assert(user_table); | ||
| 62 | + assert(user_table->sort_map); | ||
| 63 | |||
| 64 | /* Make sure the header stays at the beginning */ | ||
| 65 | - if (*a < t->n_columns && *b < t->n_columns) | ||
| 66 | + if (*a < user_table->n_columns && *b < user_table->n_columns) | ||
| 67 | return 0; | ||
| 68 | - if (*a < t->n_columns) | ||
| 69 | + if (*a < user_table->n_columns) | ||
| 70 | return -1; | ||
| 71 | - if (*b < t->n_columns) | ||
| 72 | + if (*b < user_table->n_columns) | ||
| 73 | return 1; | ||
| 74 | |||
| 75 | /* Order other lines by the sorting map */ | ||
| 76 | - for (size_t i = 0; i < t->n_sort_map; i++) { | ||
| 77 | + for (size_t i = 0; i < user_table->n_sort_map; i++) { | ||
| 78 | TableData *d, *dd; | ||
| 79 | |||
| 80 | - d = t->data[*a + t->sort_map[i]]; | ||
| 81 | - dd = t->data[*b + t->sort_map[i]]; | ||
| 82 | + d = user_table->data[*a + user_table->sort_map[i]]; | ||
| 83 | + dd = user_table->data[*b + user_table->sort_map[i]]; | ||
| 84 | |||
| 85 | r = cell_data_compare(d, *a, dd, *b); | ||
| 86 | if (r != 0) | ||
| 87 | - return t->reverse_map && t->reverse_map[t->sort_map[i]] ? -r : r; | ||
| 88 | + return user_table->reverse_map && user_table->reverse_map[user_table->sort_map[i]] ? -r : r; | ||
| 89 | } | ||
| 90 | |||
| 91 | /* Order identical lines by the order there were originally added in */ | ||
| 92 | @@ -2009,7 +2011,12 @@ int table_print(Table *t, FILE *f) { | ||
| 93 | for (size_t i = 0; i < n_rows; i++) | ||
| 94 | sorted[i] = i * t->n_columns; | ||
| 95 | |||
| 96 | - typesafe_qsort_r(sorted, n_rows, table_data_compare, t); | ||
| 97 | + if (n_rows <= 1) | ||
| 98 | + return 0; | ||
| 99 | + assert(sorted); | ||
| 100 | + user_table = t; | ||
| 101 | + qsort(sorted, n_rows, sizeof(size_t), table_data_compare); | ||
| 102 | + user_table = NULL; | ||
| 103 | } | ||
| 104 | |||
| 105 | if (t->display_map) | ||
| 106 | @@ -2647,7 +2654,12 @@ int table_to_json(Table *t, JsonVariant **ret) { | ||
| 107 | for (size_t i = 0; i < n_rows; i++) | ||
| 108 | sorted[i] = i * t->n_columns; | ||
| 109 | |||
| 110 | - typesafe_qsort_r(sorted, n_rows, table_data_compare, t); | ||
| 111 | + if (n_rows <= 1) | ||
| 112 | + return 0; | ||
| 113 | + assert(sorted); | ||
| 114 | + user_table = t; | ||
| 115 | + qsort(sorted, n_rows, sizeof(size_t), table_data_compare); | ||
| 116 | + user_table = NULL; | ||
| 117 | } | ||
| 118 | |||
| 119 | if (t->display_map) | ||
| 120 | diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c | ||
| 121 | index fe4785f3e5..827e1639c3 100644 | ||
| 122 | --- a/src/shared/hwdb-util.c | ||
| 123 | +++ b/src/shared/hwdb-util.c | ||
| 124 | @@ -127,9 +127,13 @@ static struct trie* trie_free(struct trie *trie) { | ||
| 125 | |||
| 126 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free); | ||
| 127 | |||
| 128 | -static int trie_values_cmp(const struct trie_value_entry *a, const struct trie_value_entry *b, struct trie *trie) { | ||
| 129 | - return strcmp(trie->strings->buf + a->key_off, | ||
| 130 | - trie->strings->buf + b->key_off); | ||
| 131 | +static struct trie *trie_node_add_value_trie; | ||
| 132 | +static int trie_values_cmp(const void *v1, const void *v2) { | ||
| 133 | + const struct trie_value_entry *a = v1; | ||
| 134 | + const struct trie_value_entry *b = v2; | ||
| 135 | + | ||
| 136 | + return strcmp(trie_node_add_value_trie->strings->buf + a->key_off, | ||
| 137 | + trie_node_add_value_trie->strings->buf + b->key_off); | ||
| 138 | } | ||
| 139 | |||
| 140 | static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
| 141 | @@ -157,7 +161,10 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
| 142 | .value_off = v, | ||
| 143 | }; | ||
| 144 | |||
| 145 | - val = typesafe_bsearch_r(&search, node->values, node->values_count, trie_values_cmp, trie); | ||
| 146 | + trie_node_add_value_trie = trie; | ||
| 147 | + val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
| 148 | + trie_node_add_value_trie = NULL; | ||
| 149 | + | ||
| 150 | if (val) { | ||
| 151 | /* At this point we have 2 identical properties on the same match-string. | ||
| 152 | * Since we process files in order, we just replace the previous value. */ | ||
| 153 | @@ -183,7 +190,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
| 154 | .line_number = line_number, | ||
| 155 | }; | ||
| 156 | node->values_count++; | ||
| 157 | - typesafe_qsort_r(node->values, node->values_count, trie_values_cmp, trie); | ||
| 158 | + trie_node_add_value_trie = trie; | ||
| 159 | + qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
| 160 | + trie_node_add_value_trie = NULL; | ||
| 161 | return 0; | ||
| 162 | } | ||
| 163 | |||
diff --git a/meta/recipes-core/systemd/systemd_250.5.bb b/meta/recipes-core/systemd/systemd_250.5.bb index 6d6b3f2ded..81fe0c88e0 100644 --- a/meta/recipes-core/systemd/systemd_250.5.bb +++ b/meta/recipes-core/systemd/systemd_250.5.bb | |||
| @@ -30,7 +30,6 @@ SRC_URI += "file://touchscreen.rules \ | |||
| 30 | # patches needed by musl | 30 | # patches needed by musl |
| 31 | SRC_URI:append:libc-musl = " ${SRC_URI_MUSL}" | 31 | SRC_URI:append:libc-musl = " ${SRC_URI_MUSL}" |
| 32 | SRC_URI_MUSL = "\ | 32 | SRC_URI_MUSL = "\ |
| 33 | file://0002-don-t-use-glibc-specific-qsort_r.patch \ | ||
| 34 | file://0003-missing_type.h-add-comparison_fn_t.patch \ | 33 | file://0003-missing_type.h-add-comparison_fn_t.patch \ |
| 35 | file://0004-add-fallback-parse_printf_format-implementation.patch \ | 34 | file://0004-add-fallback-parse_printf_format-implementation.patch \ |
| 36 | file://0005-src-basic-missing.h-check-for-missing-strndupa.patch \ | 35 | file://0005-src-basic-missing.h-check-for-missing-strndupa.patch \ |
