diff options
Diffstat (limited to 'poky/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch')
-rw-r--r-- | poky/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch | 231 |
1 files changed, 106 insertions, 125 deletions
diff --git a/poky/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch b/poky/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch index 8e0d669e8..36e0699da 100644 --- a/poky/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch +++ b/poky/meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch @@ -1,31 +1,100 @@ -From d74a4de6daea5a511c2b5636bbb552c15b3a4ad9 Mon Sep 17 00:00:00 2001 -From: Emil Renner Berthing <systemd@esmil.dk> -Date: Thu, 18 Sep 2014 15:24:56 +0200 -Subject: [PATCH] don't use glibc-specific qsort_r +From 1eb84534dea05d41afed1d898cba212ad7d310dd Mon Sep 17 00:00:00 2001 +From: Chen Qi <Qi.Chen@windriver.com> +Date: Mon, 25 Feb 2019 13:41:41 +0800 +Subject: [PATCH 02/24] don't use glibc-specific qsort_r Upstream-Status: Inappropriate [musl specific] Signed-off-by: Khem Raj <raj.khem@gmail.com> +[Rebased for v241] +Signed-off-by: Chen Qi <Qi.Chen@windriver.com> --- - src/basic/format-table.c | 27 ++++++++++++++++----------- - src/basic/util.h | 7 ------- - src/hwdb/hwdb.c | 18 +++++++++++------- - src/udev/udevadm-hwdb.c | 16 ++++++++++------ - 4 files changed, 37 insertions(+), 31 deletions(-) + src/basic/util.h | 14 -------------- + src/libsystemd/sd-hwdb/hwdb-util.c | 19 ++++++++++++++----- + src/shared/format-table.c | 36 ++++++++++++++++++++++++------------ + 3 files changed, 38 insertions(+), 31 deletions(-) -diff --git a/src/basic/format-table.c b/src/basic/format-table.c -index 94e796d1ca..9b3f35c29a 100644 ---- a/src/basic/format-table.c -+++ b/src/basic/format-table.c -@@ -745,29 +745,29 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t +diff --git a/src/basic/util.h b/src/basic/util.h +index dc33d66..9f6a6ce 100644 +--- a/src/basic/util.h ++++ b/src/basic/util.h +@@ -116,20 +116,6 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, __compar_fn + qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \ + }) + +-static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_d_fn_t compar, void *userdata) { +- if (nmemb <= 1) +- return; +- +- assert(base); +- qsort_r(base, nmemb, size, compar, userdata); +-} +- +-#define typesafe_qsort_r(p, n, func, userdata) \ +- ({ \ +- int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \ +- qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \ +- }) +- + /* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */ + static inline void memcpy_safe(void *dst, const void *src, size_t n) { + if (n == 0) +diff --git a/src/libsystemd/sd-hwdb/hwdb-util.c b/src/libsystemd/sd-hwdb/hwdb-util.c +index f852967..b570ce1 100644 +--- a/src/libsystemd/sd-hwdb/hwdb-util.c ++++ b/src/libsystemd/sd-hwdb/hwdb-util.c +@@ -126,9 +126,13 @@ static void trie_free(struct trie *trie) { + + DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free); + +-static int trie_values_cmp(const struct trie_value_entry *a, const struct trie_value_entry *b, struct trie *trie) { +- return strcmp(trie->strings->buf + a->key_off, +- trie->strings->buf + b->key_off); ++static struct trie *trie_node_add_value_trie; ++static int trie_values_cmp(const void *v1, const void *v2) { ++ const struct trie_value_entry *a = v1; ++ const struct trie_value_entry *b = v2; ++ ++ return strcmp(trie_node_add_value_trie->strings->buf + a->key_off, ++ trie_node_add_value_trie->strings->buf + b->key_off); + } + + static int trie_node_add_value(struct trie *trie, struct trie_node *node, +@@ -156,7 +160,10 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, + .value_off = v, + }; + +- val = typesafe_bsearch_r(&search, node->values, node->values_count, trie_values_cmp, trie); ++ trie_node_add_value_trie = trie; ++ val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); ++ trie_node_add_value_trie = NULL; ++ + if (val) { + /* At this point we have 2 identical properties on the same match-string. + * Since we process files in order, we just replace the previous value. */ +@@ -182,7 +189,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, + .line_number = line_number, + }; + node->values_count++; +- typesafe_qsort_r(node->values, node->values_count, trie_values_cmp, trie); ++ trie_node_add_value_trie = trie; ++ qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); ++ trie_node_add_value_trie = NULL; return 0; } --static int table_data_compare(const void *x, const void *y, void *userdata) { +diff --git a/src/shared/format-table.c b/src/shared/format-table.c +index 7d52980..75dbfe1 100644 +--- a/src/shared/format-table.c ++++ b/src/shared/format-table.c +@@ -848,31 +848,33 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t + return CMP(index_a, index_b); + } + +-static int table_data_compare(const size_t *a, const size_t *b, Table *t) { +static Table *user_table; +static int table_data_compare(const void *x, const void *y) { - const size_t *a = x, *b = y; -- Table *t = userdata; ++ const size_t *a = x, *b=y; size_t i; int r; @@ -57,11 +126,16 @@ index 94e796d1ca..9b3f35c29a 100644 r = cell_data_compare(d, *a, dd, *b); if (r != 0) -@@ -960,7 +960,12 @@ int table_print(Table *t, FILE *f) { +- return t->reverse_map && t->reverse_map[t->sort_map[i]] ? -r : r; ++ return user_table->reverse_map && user_table->reverse_map[user_table->sort_map[i]] ? -r : r; + } + + /* Order identical lines by the order there were originally added in */ +@@ -1105,7 +1107,12 @@ int table_print(Table *t, FILE *f) { for (i = 0; i < n_rows; i++) sorted[i] = i * t->n_columns; -- qsort_r_safe(sorted, n_rows, sizeof(size_t), table_data_compare, t); +- typesafe_qsort_r(sorted, n_rows, table_data_compare, t); + if (n_rows <= 1) + return 0; + assert(sorted); @@ -71,113 +145,20 @@ index 94e796d1ca..9b3f35c29a 100644 } if (t->display_map) -diff --git a/src/basic/util.h b/src/basic/util.h -index 9699d228f9..40eaf518cb 100644 ---- a/src/basic/util.h -+++ b/src/basic/util.h -@@ -105,13 +105,6 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_ - qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \ - }) - --static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void *userdata) { -- if (nmemb <= 1) -- return; -- -- assert(base); -- qsort_r(base, nmemb, size, compar, userdata); --} - - /** - * Normal memcpy requires src to be nonnull. We do nothing if n is 0. -diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c -index 317cad8a67..701d59a1eb 100644 ---- a/src/hwdb/hwdb.c -+++ b/src/hwdb/hwdb.c -@@ -135,13 +135,12 @@ static void trie_free(struct trie *trie) { - - DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free); - --static int trie_values_cmp(const void *v1, const void *v2, void *arg) { -+static struct trie *trie_node_add_value_trie; -+static int trie_values_cmp(const void *v1, const void *v2) { - const struct trie_value_entry *val1 = v1; - const struct trie_value_entry *val2 = v2; -- struct trie *trie = arg; -- -- return strcmp(trie->strings->buf + val1->key_off, -- trie->strings->buf + val2->key_off); -+ return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off, -+ trie_node_add_value_trie->strings->buf + val2->key_off); - } - - static int trie_node_add_value(struct trie *trie, struct trie_node *node, -@@ -166,7 +165,10 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, - .value_off = v, - }; - -- val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); -+ trie_node_add_value_trie = trie; -+ val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); -+ trie_node_add_value_trie = NULL; -+ - if (val) { - /* At this point we have 2 identical properties on the same match-string. - * Since we process files in order, we just replace the previous value. -@@ -191,7 +193,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, - node->values[node->values_count].file_priority = file_priority; - node->values[node->values_count].line_number = line_number; - node->values_count++; -- qsort_r(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); -+ trie_node_add_value_trie = trie; -+ qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); -+ trie_node_add_value_trie = NULL; - return 0; - } - -diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c -index 02408a4285..491d367d12 100644 ---- a/src/udev/udevadm-hwdb.c -+++ b/src/udev/udevadm-hwdb.c -@@ -114,13 +114,13 @@ static void trie_node_cleanup(struct trie_node *node) { - free(node); - } - --static int trie_values_cmp(const void *v1, const void *v2, void *arg) { -+static struct trie *trie_node_add_value_trie; -+static int trie_values_cmp(const void *v1, const void *v2) { - const struct trie_value_entry *val1 = v1; - const struct trie_value_entry *val2 = v2; -- struct trie *trie = arg; - -- return strcmp(trie->strings->buf + val1->key_off, -- trie->strings->buf + val2->key_off); -+ return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off, -+ trie_node_add_value_trie->strings->buf + val2->key_off); - } - - static int trie_node_add_value(struct trie *trie, struct trie_node *node, -@@ -141,7 +141,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, - .value_off = v, - }; +@@ -1532,7 +1539,12 @@ int table_to_json(Table *t, JsonVariant **ret) { + for (i = 0; i < n_rows; i++) + sorted[i] = i * t->n_columns; -- val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); -+ trie_node_add_value_trie = trie; -+ val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); -+ trie_node_add_value_trie = NULL; - if (val) { - /* replace existing earlier key with new value */ - val->value_off = v; -@@ -158,7 +160,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, - node->values[node->values_count].key_off = k; - node->values[node->values_count].value_off = v; - node->values_count++; -- qsort_r(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); -+ trie_node_add_value_trie = trie; -+ qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); -+ trie_node_add_value_trie = NULL; - return 0; - } +- typesafe_qsort_r(sorted, n_rows, table_data_compare, t); ++ if (n_rows <= 1) ++ return 0; ++ assert(sorted); ++ user_table = t; ++ qsort(sorted, n_rows, sizeof(size_t), table_data_compare); ++ user_table = NULL; + } + if (t->display_map) -- -2.18.0 +2.7.4 |