From 7722938d63d206ebc0e1da732009e1e9f2cd9d72 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 4 Jun 2000 18:34:39 +0000 Subject: Added library progdocs. --- lib/bitops.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/bitops.c') diff --git a/lib/bitops.c b/lib/bitops.c index 10bca04..6ca0505 100644 --- a/lib/bitops.c +++ b/lib/bitops.c @@ -9,12 +9,27 @@ #include "nest/bird.h" #include "bitops.h" +/** + * u32_mkmask - create a bit mask + * @n: number of bits + * + * u32_mkmask() returns an unsigned 32-bit integer which binary + * representation consists of @n ones followed by zeroes. + */ u32 u32_mkmask(unsigned n) { return n ? ~((1 << (32 - n)) - 1) : 0; } +/** + * u32_masklen - calculate length of a bit mask + * @x: bit mask + * + * This function checks whether the given integer @x represents + * a valid bit mask (binary representation contains first ones, then + * zeroes) and returns the number of ones or -1 if the mask is invalid. + */ int u32_masklen(u32 x) { -- cgit v1.2.3