From 60da6359a9d64ed41a9ec7d80b8af0b8ec5000be Mon Sep 17 00:00:00 2001 From: neal Date: Tue, 5 Feb 2008 16:05:18 +0000 Subject: 2008-02-05 Neal H. Walfield * bit-array.h (bit_set_to): New function. --- libbitarray/bit-array.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libbitarray/bit-array.h') diff --git a/libbitarray/bit-array.h b/libbitarray/bit-array.h index 605ffb3..bbf1862 100644 --- a/libbitarray/bit-array.h +++ b/libbitarray/bit-array.h @@ -1,5 +1,5 @@ /* bit-array.h - Bit array manipulation functions. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2008 Free Software Foundation, Inc. Written by Neal H. Walfield . This file is part of the GNU Hurd. @@ -40,6 +40,19 @@ bit_set (unsigned char *array, int size, int bit) return true; } +/* Set bit BIT in array ARRAY (which is SIZE bytes long) to VALUE. */ +static inline void +bit_set_to (unsigned char *array, int size, int bit, int value) +{ + assert (bit >= 0); + assert (bit < size * 8); + + if (value) + array[bit / 8] |= 1 << (bit & 0x7); + else + array[bit / 8] &= ~(1 << (bit & 0x7)); +} + /* Allocate the first free (zero) bit starting at bit START_BIT. SIZE is the size of ARRAY (in bytes). Returns -1 on failure, otherwise the bit allocated. */ -- cgit v1.2.3