1 #ifndef ACL_BITS_MAP_INCLUDE_H 2 #define ACL_BITS_MAP_INCLUDE_H 21 #define ACL_BITS_MASK_NBBY (8) 22 #define ACL_BITS_MASK_FD_BYTE(number, mask) \ 23 (((unsigned char *) (mask)->data)[(number) / ACL_BITS_MASK_NBBY]) 24 #define ACL_BITS_MASK_FD_BIT(number) (1 << ((number) % ACL_BITS_MASK_NBBY)) 25 #define ACL_BITS_MASK_BYTES_NEEDED(len) \ 26 (size_t) (((acl_int64) (len) + (ACL_BITS_MASK_NBBY - 1)) / ACL_BITS_MASK_NBBY) 27 #define ACL_BITS_MASK_BYTE_COUNT(mask) ((mask)->data_len) 38 #define ACL_BITS_MASK_ALLOC(mask, nmax) do { \ 39 size_t _byte_len = ACL_BITS_MASK_BYTES_NEEDED(nmax); \ 40 (mask)->data = (char*) acl_mymalloc(_byte_len); \ 41 memset((mask)->data, 0, _byte_len); \ 42 (mask)->data_len = _byte_len; \ 53 #define ACL_BITS_MASK_REALLOC(mask, nmax) do { \ 54 size_t _byte_len = ACL_BITS_MASK_BYTES_NEEDED(nmax); \ 55 size_t _old_len = (mask)->data_len; \ 56 (mask)->data = (char*) acl_myrealloc((mask)->data, _byte_len); \ 57 memset((mask)->data + _old_len, 0, _byte_len - _old_len); \ 58 (mask)->data_len = _byte_len; \ 65 #define ACL_BITS_MASK_FREE(mask) acl_myfree((mask)->data) 73 #define ACL_BITS_MASK_ZERO(mask) \ 74 memset((mask)->data, 0, (mask)->data_len); 81 #define ACL_BITS_MASK_SET(number, mask) \ 82 (ACL_BITS_MASK_FD_BYTE((number), (mask)) |= ACL_BITS_MASK_FD_BIT(number)) 90 #define ACL_BITS_MASK_ISSET(number, mask) \ 91 (ACL_BITS_MASK_FD_BYTE((number), (mask)) & ACL_BITS_MASK_FD_BIT(number)) 98 #define ACL_BITS_MASK_CLR(number, mask) \ 99 (ACL_BITS_MASK_FD_BYTE((number), (mask)) &= ~ACL_BITS_MASK_FD_BIT(number)) struct ACL_BITS_MASK ACL_BITS_MASK