If the current policy aims to have standard library functions written exclusively in C, then I would consider it not especially useful to have such functions. If a developer is going to use such things, then they're probably going to be doing so in code that needs to be performant (e.g. hashing, CRC, serial I/O, compression/decompression), and pure-C functions may never be as fast as hand-optimised assembly.

As far as interfaces go, perhaps candidates for compatibility could be GlibC or POSIX?

BTW, on the subject of endianness conversion, I don't think the traditional htonl(), htons(), etc. functions won't make much sense with their naming, as often 8-bit embedded systems have no 'network'.

With regard to the last item, I don't recall ever coming across any 'standard' library function for reversing a block of memory. The closest thing is some stdlibs having a strrev().

Regards,
Basil Hussain

Disclaimer: I have written an optimised assembly library for STM8 that covers most of the mentioned functionality: https://github.com/basilhussain/stm8-utils. So my opinions may be slightly biased... :)


On 03/10/2021 08:57, Philipp Klaus Krause wrote:
Dear SDCC users,

would you consider it useful to have more functionality for bit
manipulation exposed as functions in the stadnard library. If yes, any
of the following (and if yes, with which interface?)? Anything else?

* Endiannnes conversion for individual integers (e.g. big-endian to
native, native to little-endian, etc) via functions that convert from a
cahr array to the inetger or vice versa
* Population count (i.e. the number of bits that are 1) of an integer
* Rotation of integer types
* Count leading / trailing zeroes / ones
* Single bit chek (i.e. check if an integer is a power of two, and if
yes, which one)
* Generic byte reverse for a block of memory

Philipp


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to