The commit e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a ("libbb: make
bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it")
changes the usage syntax for bb_common_bufsiz1.
Update doc/keep_data_small.txt to reflect the new usage. The change is
probably not perfect, though.

Signed-off-by: Kang-Che Sung <[email protected]>
---
 docs/keep_data_small.txt | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/docs/keep_data_small.txt b/docs/keep_data_small.txt
index 218d4f2..32f57c3 100644
--- a/docs/keep_data_small.txt
+++ b/docs/keep_data_small.txt
@@ -124,11 +124,22 @@ its needs. Library functions are prohibited from using it.

 'G.' trick can be done using bb_common_bufsiz1 instead of malloced buffer:

-#define G (*(struct globals*)&bb_common_bufsiz1)
+#include "common_bufsiz.h"
+#define G (*(struct globals*)bb_common_bufsiz1)
+
+This bb_common_bufsiz1 needs to be initialized before use, by calling
+setup_common_bufsiz(). It is recommended that you define the INIT_G()
+macro:
+
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
+
+And call INIT_G() before you use it (e.g. in <applet>_main() function).

 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:
+bb_common_bufsiz1 is COMMON_BUFSIZE bytes long. (Currently
+COMMON_BUFSIZE=1024 but it may change in future releases. Read
+scripts/generate_BUFSIZ.sh code for definition.) You may need to add
+compile-time check for it:

 if (sizeof(struct globals) > sizeof(bb_common_bufsiz1))
  BUG_<applet>_globals_too_big();
-- 
2.9.0
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to