raw_block.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 raw_block.h
  19. * @author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * @date September 2012
  21. * @brief Raw block structure and functions.
  22. */
  23. #ifndef RAW_BLOCK_H
  24. #define RAW_BLOCK_H
  25. #include "dmm_config.h"
  26. #include <stddef.h>
  27. #ifdef HAVE_LOCKS
  28. #include <pthread.h> /* FIXME To be removed once mutex is removed. */
  29. #endif /* HAVE_LOCKS */
  30. #include <dmmlib/lists.h>
  31. #ifdef WITH_RAWBLOCK_STATS
  32. #include <dmmlib/dmmstats.h>
  33. #endif /* WITH_RAWBLOCK_STATS */
  34. /** Enumeration of raw block's different types */
  35. typedef enum rb_type_en {
  36. #ifdef FL_RB_ONLY
  37. FREELIST,
  38. #endif /* FL_RB_ONLY */
  39. #ifdef BITMAP_RB_ONLY
  40. BITMAP,
  41. #endif /* BITMAP_RB_ONLY */
  42. BIGBLOCK
  43. } rb_type;
  44. /** The header structure of every raw block inside a heap. */
  45. typedef struct raw_block_header_s {
  46. rb_type type; /**< The type of the raw block. */
  47. size_t size; /**< Total size of the raw block. */
  48. SLIST_ENTRY(raw_block_header_s) pointers; /**< Pointer to the next raw
  49. block. */
  50. #ifdef HAVE_LOCKS
  51. pthread_mutex_t mutex;/**< Mutex. */
  52. #endif /* HAVE_LOCKS */
  53. } raw_block_header_t;
  54. /** The head element of a singly-linked list of raw_block_header_t records */
  55. SLIST_HEAD(rb_head_s, raw_block_header_s);
  56. /** Create a new raw block. */
  57. raw_block_header_t *create_raw_block(size_t raw_block_size, rb_type type);
  58. #endif /* RAW_BLOCK_H */