aboutsummaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-03-09 08:33:57 -0600
committerRob Landley <rob@landley.net>2012-03-09 08:33:57 -0600
commit137bf3449a7bd235ecdce3c9c2fb4f03b84d2d83 (patch)
tree6887f5f216ca794ba505a389c66589a5a9856c76 /www
parentb7529b608ea3e56784c7682b382f285008a2fc90 (diff)
downloadtoybox-137bf3449a7bd235ecdce3c9c2fb4f03b84d2d83.tar.gz
Add lib/portability.h description with explanation of SWAP() macros.
Diffstat (limited to 'www')
-rw-r--r--www/code.html21
1 files changed, 21 insertions, 0 deletions
diff --git a/www/code.html b/www/code.html
index ac577f66..0b8ba92b 100644
--- a/www/code.html
+++ b/www/code.html
@@ -466,12 +466,33 @@ modify Config.in, then you'll need python installed to rebuild it.)</p>
configuration, but only the currently enabled ones are entered into help_data[]
in toys/help.c.</p>
+<a name="lib">
<h2>Directory lib/</h2>
+<p>TODO: document lots more here.</p>
+
<p>lib: llist, getmountlist(), error_msg/error_exit, xmalloc(),
strlcpy(), xexec(), xopen()/xread(), xgetcwd(), xabspath(), find_in_path(),
itoa().</p>
+<h3>lib/portability.h</h3>
+
+<p>This file is automatically included from the top of toys.h, and smooths
+over differences between platforms (hardware targets, compilers, C libraries,
+operating systems, etc).</p>
+
+<p>This file provides SWAP macros (SWAP_BE16(x) and SWAP_LE32(x) and so on).</p>
+
+<p>A macro like SWAP_LE32(x) means "The value in x is stored as a little
+endian 32 bit value, so perform the translation to/from whatever the native
+32-bit format is". You do the swap once on the way in, and once on the way
+out. If your target is already little endian, the macro is a NOP.</p>
+
+<p>The SWAP macros come in BE and LE each with 16, 32, and 64 bit versions.
+In each case, the name of the macro refers to the _external_ representation,
+and converts to/from whatever your native representation happens to be (which
+can vary depending on what you're currently compiling for).</p>
+
<a name="lib_args"><h3>lib/args.c</h3>
<p>Toybox's main.c automatically parses command line options before calling the