From: Rob Landley Date: Fri, 9 Mar 2012 14:33:57 +0000 (-0600) Subject: Add lib/portability.h description with explanation of SWAP() macros. X-Git-Tag: 0.3.0~59 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=137bf3449a7bd235ecdce3c9c2fb4f03b84d2d83;p=platform%2Fupstream%2Ftoybox.git Add lib/portability.h description with explanation of SWAP() macros. --- diff --git a/www/code.html b/www/code.html index ac577f6..0b8ba92 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.)

configuration, but only the currently enabled ones are entered into help_data[] in toys/help.c.

+

Directory lib/

+

TODO: document lots more here.

+

lib: llist, getmountlist(), error_msg/error_exit, xmalloc(), strlcpy(), xexec(), xopen()/xread(), xgetcwd(), xabspath(), find_in_path(), itoa().

+

lib/portability.h

+ +

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).

+ +

This file provides SWAP macros (SWAP_BE16(x) and SWAP_LE32(x) and so on).

+ +

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.

+ +

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).

+

lib/args.c

Toybox's main.c automatically parses command line options before calling the