bitmap_rb.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2012 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 "dmm_config.h"
  26. #include <inttypes.h>
  27. #include <stddef.h> /* for size_t */
  28. /** The data type of the bitmap array element */
  29. #define BMAP_EL_TYPE uint64_t
  30. /** The size of bitmap array element */
  31. #define BMAP_EL_SIZE sizeof(BMAP_EL_TYPE)
  32. /** The size of bitmap array element in bits */
  33. #define BMAP_EL_SIZE_BITS (BMAP_EL_SIZE * 8)
  34. /** Bitmap's initial value */
  35. #define BMAP_EL_INIT_VAL ~((BMAP_EL_TYPE) 0))
  36. /** How many bytes per cell should be used */
  37. #define BITMAP_RESOLUTION 256
  38. /** Bitmap-organized raw block header data structure */
  39. typedef struct bitmap_rb_s {
  40. size_t bytes_per_cell; /**< The raw block's resolution */
  41. size_t elements; /**< The necessary amount of bitmap elements */
  42. /* FIXME - As long as the bitmap arrays are fixed-sized,
  43. * this is also fixed */
  44. BMAP_EL_TYPE bmap; /**< The bitmap vector */
  45. } bitmap_rb_t;
  46. /** Chunk header data structure */
  47. typedef struct chunk_header_s {
  48. size_t num_of_cells; /**< The number of occupied cells. */
  49. size_t requested_size; /**< The requested size. */
  50. } chunk_header_t;
  51. /** The size of the chunk header in bitmap-organised raw blocks */
  52. #define CHUNK_HDR_SIZE sizeof(chunk_header_t)
  53. #endif /* BITMAP_RB_H */