[ccan] [PATCH v2 2/2] maskn & bitops: add new modules

David Gibson david at gibson.dropbear.id.au
Sat Jul 12 18:10:47 EST 2014


On Thu, Jul 10, 2014 at 08:29:32PM -0400, Cody P Schafer wrote:
> On Thu, Jul 10, 2014 at 7:08 AM, David Gibson
> <david at gibson.dropbear.id.au> wrote:
> > On Wed, Jul 09, 2014 at 09:49:44PM -0400, Cody P Schafer wrote:
> >> 'maskn' provides generation of n-bit masks from a given range.
> >> 'bitops' provides some generic bit operations that maskn needs.
> [...]
> >> diff --git a/ccan/bitops/bitops.c b/ccan/bitops/bitops.c
> >> new file mode 100644
> >> index 0000000..a9c233b
> >> --- /dev/null
> >> +++ b/ccan/bitops/bitops.c
> >> @@ -0,0 +1,10 @@
> >> +/* CC0 (Public Domain) - see LICENSE file for details */
> >> +#include <ccan/bitops/bitops.h>
> >> +
> >> +extern inline uintmax_t bit_mask_nz(unsigned bits);
> >> +extern inline uintmax_t bit_mask(unsigned bits);
> >
> > Hrm.. does "extern inline" actually have a well-defined portable
> > meeting?
> 
> In c99 and later, yes. The c99 rationale (
> http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf ) has
> some details, which this stack overflow post (
> http://stackoverflow.com/a/6312854 ) has a textual copy of.
> 
> c89, on the other hand, lacks inline and gnu89 reverses the meaning of
> "extern inline" and "inline".
> 
> > I still think these functions are so simple they should be static
> > inlines, at least the builtin versions.  Not everyone has LTO.
> 
> Well, I don't want these to be unconditionally inlined. I'd very much
> rather have the compiler decide than increase code size even when it
> isn't a great idea.

But won't the builtin versions be an instruction or two?  I would have
thought making function call would actually be as much or more code
once you do the necessary argument marshalling.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20140712/6789971a/attachment.sig>


More information about the ccan mailing list