diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0002-don-t-use-glibc-specific-qsort_r.patch | 104 |
1 files changed, 55 insertions, 49 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 index 9db22cd9d2..15fa0c4546 100644 --- 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 | |||
@@ -1,4 +1,4 @@ | |||
1 | From 159c53612444ec1df492bae528a5a88a275b93bf Mon Sep 17 00:00:00 2001 | 1 | From 40acdb90031cfeb7140cee5205bce24f8c91d857 Mon Sep 17 00:00:00 2001 |
2 | From: Chen Qi <Qi.Chen@windriver.com> | 2 | From: Chen Qi <Qi.Chen@windriver.com> |
3 | Date: Mon, 25 Feb 2019 13:41:41 +0800 | 3 | Date: Mon, 25 Feb 2019 13:41:41 +0800 |
4 | Subject: [PATCH] don't use glibc-specific qsort_r | 4 | Subject: [PATCH] don't use glibc-specific qsort_r |
@@ -14,14 +14,16 @@ Signed-off-by: Andrej Valek <andrej.valek@siemens.com> | |||
14 | Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> | 14 | Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> |
15 | 15 | ||
16 | --- | 16 | --- |
17 | src/basic/sort-util.h | 14 ------------ | 17 | src/basic/sort-util.h | 14 -------------- |
18 | src/libsystemd/sd-hwdb/hwdb-util.c | 19 +++++++++++----- | 18 | src/shared/format-table.c | 36 ++++++++++++++++++++++++------------ |
19 | src/shared/format-table.c | 36 ++++++++++++++++++++---------- | 19 | src/shared/hwdb-util.c | 19 ++++++++++++++----- |
20 | 3 files changed, 38 insertions(+), 31 deletions(-) | 20 | 3 files changed, 38 insertions(+), 31 deletions(-) |
21 | 21 | ||
22 | diff --git a/src/basic/sort-util.h b/src/basic/sort-util.h | ||
23 | index 49586a4a24..d92a5ab0ed 100644 | ||
22 | --- a/src/basic/sort-util.h | 24 | --- a/src/basic/sort-util.h |
23 | +++ b/src/basic/sort-util.h | 25 | +++ b/src/basic/sort-util.h |
24 | @@ -56,18 +56,4 @@ static inline void _qsort_safe(void *bas | 26 | @@ -55,18 +55,4 @@ static inline void _qsort_safe(void *base, size_t nmemb, size_t size, __compar_f |
25 | _qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \ | 27 | _qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \ |
26 | }) | 28 | }) |
27 | 29 | ||
@@ -40,51 +42,11 @@ Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> | |||
40 | - }) | 42 | - }) |
41 | - | 43 | - |
42 | int cmp_int(const int *a, const int *b); | 44 | int cmp_int(const int *a, const int *b); |
43 | --- a/src/shared/hwdb-util.c | 45 | diff --git a/src/shared/format-table.c b/src/shared/format-table.c |
44 | +++ b/src/shared/hwdb-util.c | 46 | index 4c4e4593d8..17b329f315 100644 |
45 | @@ -127,9 +127,13 @@ static struct trie* trie_free(struct tri | ||
46 | |||
47 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free); | ||
48 | |||
49 | -static int trie_values_cmp(const struct trie_value_entry *a, const struct trie_value_entry *b, struct trie *trie) { | ||
50 | - return strcmp(trie->strings->buf + a->key_off, | ||
51 | - trie->strings->buf + b->key_off); | ||
52 | +static struct trie *trie_node_add_value_trie; | ||
53 | +static int trie_values_cmp(const void *v1, const void *v2) { | ||
54 | + const struct trie_value_entry *a = v1; | ||
55 | + const struct trie_value_entry *b = v2; | ||
56 | + | ||
57 | + return strcmp(trie_node_add_value_trie->strings->buf + a->key_off, | ||
58 | + trie_node_add_value_trie->strings->buf + b->key_off); | ||
59 | } | ||
60 | |||
61 | static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
62 | @@ -157,7 +161,10 @@ static int trie_node_add_value(struct tr | ||
63 | .value_off = v, | ||
64 | }; | ||
65 | |||
66 | - val = typesafe_bsearch_r(&search, node->values, node->values_count, trie_values_cmp, trie); | ||
67 | + trie_node_add_value_trie = trie; | ||
68 | + val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
69 | + trie_node_add_value_trie = NULL; | ||
70 | + | ||
71 | if (val) { | ||
72 | /* At this point we have 2 identical properties on the same match-string. | ||
73 | * Since we process files in order, we just replace the previous value. */ | ||
74 | @@ -183,7 +190,9 @@ static int trie_node_add_value(struct tr | ||
75 | .line_number = line_number, | ||
76 | }; | ||
77 | node->values_count++; | ||
78 | - typesafe_qsort_r(node->values, node->values_count, trie_values_cmp, trie); | ||
79 | + trie_node_add_value_trie = trie; | ||
80 | + qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
81 | + trie_node_add_value_trie = NULL; | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | --- a/src/shared/format-table.c | 47 | --- a/src/shared/format-table.c |
86 | +++ b/src/shared/format-table.c | 48 | +++ b/src/shared/format-table.c |
87 | @@ -1282,30 +1282,32 @@ static int cell_data_compare(TableData * | 49 | @@ -1282,30 +1282,32 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t |
88 | return CMP(index_a, index_b); | 50 | return CMP(index_a, index_b); |
89 | } | 51 | } |
90 | 52 | ||
@@ -141,7 +103,7 @@ Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> | |||
141 | } | 103 | } |
142 | 104 | ||
143 | if (t->display_map) | 105 | if (t->display_map) |
144 | @@ -2572,7 +2579,12 @@ int table_to_json(Table *t, JsonVariant | 106 | @@ -2572,7 +2579,12 @@ int table_to_json(Table *t, JsonVariant **ret) { |
145 | for (size_t i = 0; i < n_rows; i++) | 107 | for (size_t i = 0; i < n_rows; i++) |
146 | sorted[i] = i * t->n_columns; | 108 | sorted[i] = i * t->n_columns; |
147 | 109 | ||
@@ -155,3 +117,47 @@ Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com> | |||
155 | } | 117 | } |
156 | 118 | ||
157 | if (t->display_map) | 119 | if (t->display_map) |
120 | diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c | ||
121 | index d7626aed95..2003fac7c3 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 | |||