summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
authorMuhammad Tauqir Ahmad <mian.muhammad.tauqir.ahmad@gmail.com>2013-12-13 14:25:57 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-16 12:13:58 +0000
commit8babb8ff1752a7815ae1780bdd6df4de51fd222b (patch)
treeb3121b40b913e2a6acdde023612593116b30f571 /meta/recipes-core
parente230b4498790a3dfdc36ea5761807459fc96368e (diff)
downloadpoky-8babb8ff1752a7815ae1780bdd6df4de51fd222b.tar.gz
busybox: get rid of nested functions in find
This allows us to compile busybox using clang. Nested functions is a gcc extension not supported by clang. (From OE-Core rev: d2bf599f36ed1a04c661fc0a71e664e219532cbc) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/busybox/busybox/find-get-rid-of-nested-functions.patch117
-rw-r--r--meta/recipes-core/busybox/busybox_1.21.1.bb1
2 files changed, 118 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/find-get-rid-of-nested-functions.patch b/meta/recipes-core/busybox/busybox/find-get-rid-of-nested-functions.patch
new file mode 100644
index 0000000000..d66ef79cf0
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/find-get-rid-of-nested-functions.patch
@@ -0,0 +1,117 @@
1Upstream-Status: Accepted
2
3commit 6db5f679a21342249e6a6eb06ec70a337bf0d0b0
4Author: Denys Vlasenko <vda.linux@googlemail.com>
5Date: Thu May 16 18:36:42 2013 +0200
6
7find:: get rid of nested function (it's a gcc-ism)
8
9function old new delta
10alloc_action - 80 +80
11parse_params 1459 1445 -14
12static.alloc_action 98 - -98
13
14(add/remove: 1/1 grow/shrink: 0/1 up/down: 80/-112) Total: -32 bytes
15
16Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
17
18diff --git a/findutils/find.c b/findutils/find.c
19index d4b7c8e..af913cc 100644
20--- a/findutils/find.c
21+++ b/findutils/find.c
22@@ -815,6 +815,31 @@ static const char* plus_minus_num(const char* str)
23 }
24 #endif
25
26+/* Say no to GCCism */
27+#define USE_NESTED_FUNCTION 0
28+
29+#if !USE_NESTED_FUNCTION
30+struct pp_locals {
31+ action*** appp;
32+ unsigned cur_group;
33+ unsigned cur_action;
34+ IF_FEATURE_FIND_NOT( bool invert_flag; )
35+};
36+static action* alloc_action(struct pp_locals *ppl, int sizeof_struct, action_fp f)
37+{
38+ action *ap = xzalloc(sizeof_struct);
39+ action **app;
40+ action ***group = &ppl->appp[ppl->cur_group];
41+ *group = app = xrealloc(*group, (ppl->cur_action+2) * sizeof(ppl->appp[0][0]));
42+ app[ppl->cur_action++] = ap;
43+ app[ppl->cur_action] = NULL;
44+ ap->f = f;
45+ IF_FEATURE_FIND_NOT( ap->invert = ppl->invert_flag; )
46+ IF_FEATURE_FIND_NOT( ppl->invert_flag = 0; )
47+ return ap;
48+}
49+#endif
50+
51 static action*** parse_params(char **argv)
52 {
53 enum {
54@@ -901,10 +926,18 @@ static action*** parse_params(char **argv)
55 IF_FEATURE_FIND_MAXDEPTH("-mindepth\0""-maxdepth\0")
56 ;
57
58+#if !USE_NESTED_FUNCTION
59+ struct pp_locals ppl;
60+#define appp (ppl.appp )
61+#define cur_group (ppl.cur_group )
62+#define cur_action (ppl.cur_action )
63+#define invert_flag (ppl.invert_flag)
64+#define ALLOC_ACTION(name) (action_##name*)alloc_action(&ppl, sizeof(action_##name), (action_fp) func_##name)
65+#else
66 action*** appp;
67- unsigned cur_group = 0;
68- unsigned cur_action = 0;
69- IF_FEATURE_FIND_NOT( bool invert_flag = 0; )
70+ unsigned cur_group;
71+ unsigned cur_action;
72+ IF_FEATURE_FIND_NOT( bool invert_flag; )
73
74 /* This is the only place in busybox where we use nested function.
75 * So far more standard alternatives were bigger. */
76@@ -913,7 +946,7 @@ static action*** parse_params(char **argv)
77 action* alloc_action(int sizeof_struct, action_fp f)
78 {
79 action *ap;
80- appp[cur_group] = xrealloc(appp[cur_group], (cur_action+2) * sizeof(*appp));
81+ appp[cur_group] = xrealloc(appp[cur_group], (cur_action+2) * sizeof(appp[0][0]));
82 appp[cur_group][cur_action++] = ap = xzalloc(sizeof_struct);
83 appp[cur_group][cur_action] = NULL;
84 ap->f = f;
85@@ -921,9 +954,12 @@ static action*** parse_params(char **argv)
86 IF_FEATURE_FIND_NOT( invert_flag = 0; )
87 return ap;
88 }
89-
90 #define ALLOC_ACTION(name) (action_##name*)alloc_action(sizeof(action_##name), (action_fp) func_##name)
91+#endif
92
93+ cur_group = 0;
94+ cur_action = 0;
95+ IF_FEATURE_FIND_NOT( invert_flag = 0; )
96 appp = xzalloc(2 * sizeof(appp[0])); /* appp[0],[1] == NULL */
97
98 while (*argv) {
99@@ -988,7 +1024,7 @@ static action*** parse_params(char **argv)
100 dbg("%d", __LINE__);
101 /* start new OR group */
102 cur_group++;
103- appp = xrealloc(appp, (cur_group+2) * sizeof(*appp));
104+ appp = xrealloc(appp, (cur_group+2) * sizeof(appp[0]));
105 /*appp[cur_group] = NULL; - already NULL */
106 appp[cur_group+1] = NULL;
107 cur_action = 0;
108@@ -1246,6 +1282,9 @@ static action*** parse_params(char **argv)
109 dbg("exiting %s", __func__);
110 return appp;
111 #undef ALLOC_ACTION
112+#undef appp
113+#undef cur_action
114+#undef invert_flag
115 }
116
117 int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/meta/recipes-core/busybox/busybox_1.21.1.bb b/meta/recipes-core/busybox/busybox_1.21.1.bb
index 8b91e6329d..267604afa3 100644
--- a/meta/recipes-core/busybox/busybox_1.21.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.21.1.bb
@@ -34,6 +34,7 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
34 file://login-utilities.cfg \ 34 file://login-utilities.cfg \
35 file://busybox-list-suid-and-non-suid-app-configs.patch \ 35 file://busybox-list-suid-and-non-suid-app-configs.patch \
36 file://busybox-sed-fix-sed-clusternewline-testcase.patch \ 36 file://busybox-sed-fix-sed-clusternewline-testcase.patch \
37 file://find-get-rid-of-nested-functions.patch \
37" 38"
38 39
39SRC_URI[tarball.md5sum] = "795394f83903b5eec6567d51eebb417e" 40SRC_URI[tarball.md5sum] = "795394f83903b5eec6567d51eebb417e"