diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch b/meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch new file mode 100644 index 0000000000..7cfe829e85 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch | |||
@@ -0,0 +1,105 @@ | |||
1 | From 2eb45f5a0a8bfb8bdca084587ad28e5001f3cc4b Mon Sep 17 00:00:00 2001 | ||
2 | From: Emil Renner Berthing <systemd@esmil.dk> | ||
3 | Date: Thu, 18 Sep 2014 15:24:56 +0200 | ||
4 | Subject: [PATCH 11/12] don't use glibc-specific qsort_r | ||
5 | |||
6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
7 | --- | ||
8 | Upstream-Status: Pending | ||
9 | |||
10 | src/hwdb/hwdb.c | 18 +++++++++++------- | ||
11 | src/udev/udevadm-hwdb.c | 16 ++++++++++------ | ||
12 | 2 files changed, 21 insertions(+), 13 deletions(-) | ||
13 | |||
14 | diff --git a/src/hwdb/hwdb.c b/src/hwdb/hwdb.c | ||
15 | index 793398ca6..669b00818 100644 | ||
16 | --- a/src/hwdb/hwdb.c | ||
17 | +++ b/src/hwdb/hwdb.c | ||
18 | @@ -151,13 +151,12 @@ static void trie_free(struct trie *trie) { | ||
19 | |||
20 | DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free); | ||
21 | |||
22 | -static int trie_values_cmp(const void *v1, const void *v2, void *arg) { | ||
23 | +static struct trie *trie_node_add_value_trie; | ||
24 | +static int trie_values_cmp(const void *v1, const void *v2) { | ||
25 | const struct trie_value_entry *val1 = v1; | ||
26 | const struct trie_value_entry *val2 = v2; | ||
27 | - struct trie *trie = arg; | ||
28 | - | ||
29 | - return strcmp(trie->strings->buf + val1->key_off, | ||
30 | - trie->strings->buf + val2->key_off); | ||
31 | + return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off, | ||
32 | + trie_node_add_value_trie->strings->buf + val2->key_off); | ||
33 | } | ||
34 | |||
35 | static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
36 | @@ -182,7 +181,10 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
37 | .value_off = v, | ||
38 | }; | ||
39 | |||
40 | - val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); | ||
41 | + trie_node_add_value_trie = trie; | ||
42 | + val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
43 | + trie_node_add_value_trie = NULL; | ||
44 | + | ||
45 | if (val) { | ||
46 | /* At this point we have 2 identical properties on the same match-string. | ||
47 | * Since we process files in order, we just replace the previous value. | ||
48 | @@ -207,7 +209,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
49 | node->values[node->values_count].file_priority = file_priority; | ||
50 | node->values[node->values_count].line_number = line_number; | ||
51 | node->values_count++; | ||
52 | - qsort_r(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); | ||
53 | + trie_node_add_value_trie = trie; | ||
54 | + qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
55 | + trie_node_add_value_trie = NULL; | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c | ||
60 | index 69b0b9025..fbd213300 100644 | ||
61 | --- a/src/udev/udevadm-hwdb.c | ||
62 | +++ b/src/udev/udevadm-hwdb.c | ||
63 | @@ -128,13 +128,13 @@ static void trie_node_cleanup(struct trie_node *node) { | ||
64 | free(node); | ||
65 | } | ||
66 | |||
67 | -static int trie_values_cmp(const void *v1, const void *v2, void *arg) { | ||
68 | +static struct trie *trie_node_add_value_trie; | ||
69 | +static int trie_values_cmp(const void *v1, const void *v2) { | ||
70 | const struct trie_value_entry *val1 = v1; | ||
71 | const struct trie_value_entry *val2 = v2; | ||
72 | - struct trie *trie = arg; | ||
73 | |||
74 | - return strcmp(trie->strings->buf + val1->key_off, | ||
75 | - trie->strings->buf + val2->key_off); | ||
76 | + return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off, | ||
77 | + trie_node_add_value_trie->strings->buf + val2->key_off); | ||
78 | } | ||
79 | |||
80 | static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
81 | @@ -155,7 +155,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
82 | .value_off = v, | ||
83 | }; | ||
84 | |||
85 | - val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); | ||
86 | + trie_node_add_value_trie = trie; | ||
87 | + val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
88 | + trie_node_add_value_trie = NULL; | ||
89 | if (val) { | ||
90 | /* replace existing earlier key with new value */ | ||
91 | val->value_off = v; | ||
92 | @@ -172,7 +174,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node, | ||
93 | node->values[node->values_count].key_off = k; | ||
94 | node->values[node->values_count].value_off = v; | ||
95 | node->values_count++; | ||
96 | - qsort_r(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie); | ||
97 | + trie_node_add_value_trie = trie; | ||
98 | + qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp); | ||
99 | + trie_node_add_value_trie = NULL; | ||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | -- | ||
104 | 2.14.2 | ||
105 | |||