<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hello,<br><br>[ Replying to my own post since I'm not subscribed to the mailing list ]<br><br>I understand your objections about the libm patch, I sent it because because I saw you listed these functions on the libpayload page on the coreboot website so I assumed you might have an interest in adding these to libpayload. I guess it's probably not all that useful to have math support for most applications that use libpayload.<br><br>As Patrick pointed out, FPU exceptions are not currently handled, resulting in weird things like log(0) = 0 etc, but at the same time "normal" cases are computed with the same kind of precision one would expect from your everyday libc so if this caveat is documented this code can still be useful for a lot of cases.<br><br>Right now on x86, most of the math functions from this patch are actually from the asm sources in
 libpayload/libm/arch/i387/: they are quite small (1000 loc) and don't depend on other stuff (and except the exp implementation they don't use the 4 clause BSD license). The C source equivalents are there as a fallback for other archs: I kept them because I saw powerpc was also supported. So if it's OK to have x86 only code in libpayload and to drop some C implementations, it's quite easy to only add the x86 asm sources with the caveat of not handling FPU exceptions: if you want some kind of math support in libpayload without adding too much bloat it's probably not a bad deal. Are you interested in having something like that ?<br><br>My answers to specific questions below.<br><br>Regards,<br>Sylvain<br><br>> On 2/7/10 5:29 PM, Patrick Georgi wrote:<br>> > Then, there are design questions: this libm is made for userland, with a<br>> > kernel expected to provide support if anything goes wrong. How does the<br>> > math library cope with
 FPU exceptions? Does it at all?<br>> >   <br>> I have to second that<br><br>Ok but if you were to redo a math library custom made for libpayload that handles <br>FPU exceptions these sources are still a good starting point that will save <br>a lot of work. I doubt a doing non-userland libm would end up with code very much <br>different from what's already in there. <br><br>> It increases code size of libpayload roughly by a factor of five..<br>> That's an incredible amount of code.<br>> <br><br>The source size is big but the resulting compiled code size is reasonable. <br>For example with Tinyscheme, linking in the double version of all the math <br>functions results in a 8kb increase.<br><br>> The code is unfortunately not quite clean and not really adapted to<br>> libpayload either. In fact, it looks like the BSD sources have mostly<br>> been just untarred in the libpayload directory.<br>> <br>> A few checks
 show<br>> <br>> - string.h provides functions like ffs() which is never defined<br>> - string.h provides prototypes for many functions that are still listed<br>> in libpayload.h, like memcpy, memcmp etc<br><br>I kind of saw the fact that it uses pristine BSD sources/headers as a feature :) <br>(easier to maintain in the long run and easier to port an application to a library<br>that's structured in the same way as BSD). It's true there's a bunch of functions<br>in these that are not implemented but this doesn't break anything and<br>should you need to implement them in the future the prototype is already there.<br><br><br>> - lots of odd undocumented functionality like several setjmp implementations<br>These can be removed.<br><br><br>> - patch to readline() breaks existing code out there<br>Sorry, please disregard that. I didn't see it was possible to get the functionality I needed using getline.<br><br>> Roughly I think that this
 approach of adding code to libpayload is not<br>> preferrable. It would be much nicer to see that those functions used by<br>> tinyscheme are chosen carefully, be added to libpayload in minimal<br>> implementations and commented in the same style we commented all the<br>> rest of libpayload.<br>> <br><br>Tinyscheme doesn't actually need that floating point/math stuff to run. It's configurable at compile time.<br><br>> As for tinyscheme, if it is maintained it might be a better idea to try<br>> to get payload-related changes (if any) into upstream, instead of<br>> starting a fork in our repository.<br><br>I'll talk to them but I doubt they want to maintain another bunch of #ifdef. <br>How about I send you a patch against the latest version with build instructions for inclusion here: <a href="http://www.coreboot.org/Payloads">http://www.coreboot.org/Payloads</a> ?<br><br><br></td></tr></table><br>