summaryrefslogtreecommitdiff
path: root/lib/bitops.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-06-04 18:34:39 +0000
committerMartin Mares <mj@ucw.cz>2000-06-04 18:34:39 +0000
commit7722938d63d206ebc0e1da732009e1e9f2cd9d72 (patch)
tree41073dbf2866687d85476982ffa1c0288a878da0 /lib/bitops.c
parent102e3e0e0277e7b123c7c1ae3635c4a8fb55c900 (diff)
Added library progdocs.
Diffstat (limited to 'lib/bitops.c')
-rw-r--r--lib/bitops.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/bitops.c b/lib/bitops.c
index 10bca047..6ca05050 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)
{