[PATCH] More portability fixes
Dan Fandrich
dan at coneharvesters.com
Mon Sep 14 04:21:54 UTC 2009
On Sun, Sep 13, 2009 at 02:41:43PM +0200, Denys Vlasenko wrote:
> I propose to solve it by adding a new option, USE_PORTABLE_CODE,
> in top-level Config.in, and conditionalze on it:
>
> #if ENABLE_USE_PORTABLE_CODE
> char **argv = alloca(sizeof(char*) * (ap->exec_argc + 1));
> #else /* gcc 4.3.1 generates smaller code: */
> char *argv[ap->exec_argc + 1];
> #endif
I'm not positive alloca() is actually more portable. The variable length
array style it replaces is at least part of C99, so it will become more
and more supported in toolchains as time goes on. The code readability
with the macros suffers, too, but that's the perennial tossup when trying
to write portable code, especial when binary size is an issue. Some
projects I'm involved with solve the portability problem with #ifdefs
absolutely everywhere in the code, so it's ugly to read but runs
absolutely everywhere, but binary size isn't of significance.
I can't say what the sweet spot is for BusyBox. If someone can codify it,
it would be nice to have a paragraph added to the portability section
of the README regarding the preferential use of proprietary compiler
features and APIs vs C99, POSIX and SuS and which wins when it comes
to code size.
>>> Dan
--
http://www.MoveAnnouncer.com The web change of address service
Let webmasters know that your web site has moved
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 288 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090913/3289ff4d/attachment.pgp>
More information about the busybox
mailing list