Document setup_common_bufsiz() and common_bufsiz.h

Explorer explorer09 at gmail.com
Thu Jun 23 14:24:00 UTC 2016


Since busybox-1.25.0, using bb_common_bufsiz1 now requires a setup and
inclusion of a generated header. It's better to document such things for
people who write new applet code. Otherwise, it will make a compile error.
("error: ‘bb_common_bufsiz1’ undeclared")

In fact it broke my build because I added an applet [1] that is not in the
main development tree, and I would need to hack it in order to make it
work in the new version.

[1] 'acpi' applet by Issac Dunham
(http://lists.busybox.net/pipermail/busybox/2014-December/082065.html)
---
 docs/keep_data_small.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/docs/keep_data_small.txt b/docs/keep_data_small.txt
index 3ced1a6..a7cfcfb 100644
--- a/docs/keep_data_small.txt
+++ b/docs/keep_data_small.txt
@@ -126,6 +126,17 @@ its needs. Library functions are prohibited from using it.

 #define G (*(struct globals*)&bb_common_bufsiz1)

+If you use bb_common_bufsiz1, you will need to #include "common_bufsiz.h"
+in you applet source code, and initialize the buffer by calling
+setup_common_bufsiz(). It is recommended that you put it into a macro:
+
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
+
+And then call INIT_G() somewhere in your applet's main() function.
+
+[ The #include "common_bufsiz.h" and setup_common_bufsiz() requirements are
+added since busybox-1.25.0. ]
+
 Be careful, though, and use it only if globals fit into bb_common_bufsiz1.
 Since bb_common_bufsiz1 is BUFSIZ + 1 bytes long and BUFSIZ can change
 from one libc to another, you have to add compile-time check for it:
-- 
2.9.0


More information about the busybox mailing list