bitmap_rb.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright Institute of Communication and Computer Systems (ICCS)
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /**
  18. * @file bitmap_rb.h
  19. * @author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * @date September 2012
  21. * @brief Bitmap-organized raw block structure and creation function.
  22. */
  23. #ifndef BITMAP_RB_H
  24. #define BITMAP_RB_H
  25. #include <dmmlib/config.h>
  26. #include <inttypes.h>
  27. #include <limits.h>
  28. #include <stddef.h> /* for size_t */
  29. /** The data type of the bitmap array element */
  30. #define BMAP_EL_TYPE uint64_t
  31. /** The size of bitmap array element */
  32. #define BMAP_EL_SIZE sizeof(BMAP_EL_TYPE)
  33. /** The size of bitmap array element in bits */
  34. #define BMAP_EL_SIZE_BITS (BMAP_EL_SIZE * CHAR_BIT)
  35. /** Bitmap's initial value */
  36. #define BMAP_EL_INIT_VAL ~((BMAP_EL_TYPE) 0)
  37. /** Bitmap-organized raw block header data structure */
  38. typedef struct bitmap_rb_s {
  39. size_t bytes_per_cell; /**< The raw block's resolution */
  40. size_t elements; /**< The necessary amount of bitmap elements */
  41. } bitmap_rb_t;
  42. /** Chunk header data structure */
  43. typedef struct chunk_header_s {
  44. size_t num_of_cells; /**< The number of occupied cells. */
  45. #ifdef REQUEST_SIZE_INFO
  46. size_t requested_size; /**< The requested size. */
  47. #endif /* REQUEST_SIZE_INFO */
  48. } chunk_header_t;
  49. /** The size of the chunk header in bitmap-organised raw blocks */
  50. #define CHUNK_HDR_SIZE sizeof(chunk_header_t)
  51. #endif /* BITMAP_RB_H */