H5FDdevelop.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * All rights reserved. *
  4. * *
  5. * This file is part of HDF5. The full HDF5 copyright notice, including *
  6. * terms governing use, modification, and redistribution, is contained in *
  7. * the COPYING file, which can be found at the root of the source code *
  8. * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
  9. * If you do not have access to either file, you may request a copy from *
  10. * help@hdfgroup.org. *
  11. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  12. /*
  13. * This file contains public declarations for the H5FD (file drivers) developer
  14. * support routines.
  15. */
  16. #ifndef _H5FDdevelop_H
  17. #define _H5FDdevelop_H
  18. /* Include package's public header */
  19. #include "H5FDpublic.h"
  20. /*****************/
  21. /* Public Macros */
  22. /*****************/
  23. /* Map "fractal heap" header blocks to 'ohdr' type file memory, since its
  24. * a fair amount of work to add a new kind of file memory and they are similar
  25. * enough to object headers and probably too minor to deserve their own type.
  26. *
  27. * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they
  28. * are similar to fractal heap header blocks.
  29. *
  30. * Map "fractal heap" direct blocks to 'lheap' type file memory, since they
  31. * will be replacing local heaps.
  32. *
  33. * Map "fractal heap" 'huge' objects to 'draw' type file memory, since they
  34. * represent large objects that are directly stored in the file.
  35. *
  36. * -QAK
  37. */
  38. #define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR
  39. #define H5FD_MEM_FHEAP_IBLOCK H5FD_MEM_OHDR
  40. #define H5FD_MEM_FHEAP_DBLOCK H5FD_MEM_LHEAP
  41. #define H5FD_MEM_FHEAP_HUGE_OBJ H5FD_MEM_DRAW
  42. /* Map "free space" header blocks to 'ohdr' type file memory, since its
  43. * a fair amount of work to add a new kind of file memory and they are similar
  44. * enough to object headers and probably too minor to deserve their own type.
  45. *
  46. * Map "free space" serialized sections to 'lheap' type file memory, since they
  47. * are similar enough to local heap info.
  48. *
  49. * -QAK
  50. */
  51. #define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR
  52. #define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP
  53. /* Map "shared object header message" master table to 'ohdr' type file memory,
  54. * since its a fair amount of work to add a new kind of file memory and they are
  55. * similar enough to object headers and probably too minor to deserve their own
  56. * type.
  57. *
  58. * Map "shared object header message" indices to 'btree' type file memory,
  59. * since they are similar enough to B-tree nodes.
  60. *
  61. * -QAK
  62. */
  63. #define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR
  64. #define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE
  65. /* Map "extensible array" header blocks to 'ohdr' type file memory, since its
  66. * a fair amount of work to add a new kind of file memory and they are similar
  67. * enough to object headers and probably too minor to deserve their own type.
  68. *
  69. * Map "extensible array" index blocks to 'ohdr' type file memory, since they
  70. * are similar to extensible array header blocks.
  71. *
  72. * Map "extensible array" super blocks to 'btree' type file memory, since they
  73. * are similar enough to B-tree nodes.
  74. *
  75. * Map "extensible array" data blocks & pages to 'lheap' type file memory, since
  76. * they are similar enough to local heap info.
  77. *
  78. * -QAK
  79. */
  80. #define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR
  81. #define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR
  82. #define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE
  83. #define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP
  84. #define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP
  85. /* Map "fixed array" header blocks to 'ohdr' type file memory, since its
  86. * a fair amount of work to add a new kind of file memory and they are similar
  87. * enough to object headers and probably too minor to deserve their own type.
  88. *
  89. * Map "fixed array" data blocks & pages to 'lheap' type file memory, since
  90. * they are similar enough to local heap info.
  91. *
  92. */
  93. #define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR
  94. #define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP
  95. #define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP
  96. /*
  97. * A free-list map which maps all types of allocation requests to a single
  98. * free list. This is useful for drivers that don't really care about
  99. * keeping different requests segregated in the underlying file and which
  100. * want to make most efficient reuse of freed memory. The use of the
  101. * H5FD_MEM_SUPER free list is arbitrary.
  102. */
  103. #define H5FD_FLMAP_SINGLE \
  104. { \
  105. H5FD_MEM_SUPER, /*default*/ \
  106. H5FD_MEM_SUPER, /*super*/ \
  107. H5FD_MEM_SUPER, /*btree*/ \
  108. H5FD_MEM_SUPER, /*draw*/ \
  109. H5FD_MEM_SUPER, /*gheap*/ \
  110. H5FD_MEM_SUPER, /*lheap*/ \
  111. H5FD_MEM_SUPER /*ohdr*/ \
  112. }
  113. /*
  114. * A free-list map which segregates requests into `raw' or `meta' data
  115. * pools.
  116. */
  117. #define H5FD_FLMAP_DICHOTOMY \
  118. { \
  119. H5FD_MEM_SUPER, /*default*/ \
  120. H5FD_MEM_SUPER, /*super*/ \
  121. H5FD_MEM_SUPER, /*btree*/ \
  122. H5FD_MEM_DRAW, /*draw*/ \
  123. H5FD_MEM_DRAW, /*gheap*/ \
  124. H5FD_MEM_SUPER, /*lheap*/ \
  125. H5FD_MEM_SUPER /*ohdr*/ \
  126. }
  127. /*
  128. * The default free list map which causes each request type to use it's own
  129. * free-list.
  130. */
  131. #define H5FD_FLMAP_DEFAULT \
  132. { \
  133. H5FD_MEM_DEFAULT, /*default*/ \
  134. H5FD_MEM_DEFAULT, /*super*/ \
  135. H5FD_MEM_DEFAULT, /*btree*/ \
  136. H5FD_MEM_DEFAULT, /*draw*/ \
  137. H5FD_MEM_DEFAULT, /*gheap*/ \
  138. H5FD_MEM_DEFAULT, /*lheap*/ \
  139. H5FD_MEM_DEFAULT /*ohdr*/ \
  140. }
  141. /*******************/
  142. /* Public Typedefs */
  143. /*******************/
  144. /* Forward declaration */
  145. typedef struct H5FD_t H5FD_t;
  146. /* Class information for each file driver */
  147. typedef struct H5FD_class_t {
  148. H5FD_class_value_t value;
  149. const char * name;
  150. haddr_t maxaddr;
  151. H5F_close_degree_t fc_degree;
  152. herr_t (*terminate)(void);
  153. hsize_t (*sb_size)(H5FD_t *file);
  154. herr_t (*sb_encode)(H5FD_t *file, char *name /*out*/, unsigned char *p /*out*/);
  155. herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p);
  156. size_t fapl_size;
  157. void *(*fapl_get)(H5FD_t *file);
  158. void *(*fapl_copy)(const void *fapl);
  159. herr_t (*fapl_free)(void *fapl);
  160. size_t dxpl_size;
  161. void *(*dxpl_copy)(const void *dxpl);
  162. herr_t (*dxpl_free)(void *dxpl);
  163. H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr);
  164. herr_t (*close)(H5FD_t *file);
  165. int (*cmp)(const H5FD_t *f1, const H5FD_t *f2);
  166. herr_t (*query)(const H5FD_t *f1, unsigned long *flags);
  167. herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map);
  168. haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
  169. herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size);
  170. haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type);
  171. herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr);
  172. haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type);
  173. herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void **file_handle);
  174. herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer);
  175. herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer);
  176. herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
  177. herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
  178. herr_t (*lock)(H5FD_t *file, hbool_t rw);
  179. herr_t (*unlock)(H5FD_t *file);
  180. herr_t (*del)(const char *name, hid_t fapl);
  181. herr_t (*ctl)(H5FD_t *file, uint64_t op_code, uint64_t flags, const void *input, void **output);
  182. H5FD_mem_t fl_map[H5FD_MEM_NTYPES];
  183. } H5FD_class_t;
  184. /* A free list is a singly-linked list of address/size pairs. */
  185. typedef struct H5FD_free_t {
  186. haddr_t addr;
  187. hsize_t size;
  188. struct H5FD_free_t *next;
  189. } H5FD_free_t;
  190. /*
  191. * The main datatype for each driver. Public fields common to all drivers
  192. * are declared here and the driver appends private fields in memory.
  193. */
  194. struct H5FD_t {
  195. hid_t driver_id; /*driver ID for this file */
  196. const H5FD_class_t *cls; /*constant class info */
  197. unsigned long fileno; /* File 'serial' number */
  198. unsigned access_flags; /* File access flags (from create or open) */
  199. unsigned long feature_flags; /* VFL Driver feature Flags */
  200. haddr_t maxaddr; /* For this file, overrides class */
  201. haddr_t base_addr; /* Base address for HDF5 data w/in file */
  202. /* Space allocation management fields */
  203. hsize_t threshold; /* Threshold for alignment */
  204. hsize_t alignment; /* Allocation alignment */
  205. hbool_t paged_aggr; /* Paged aggregation for file space is enabled or not */
  206. };
  207. /********************/
  208. /* Public Variables */
  209. /********************/
  210. /*********************/
  211. /* Public Prototypes */
  212. /*********************/
  213. #ifdef __cplusplus
  214. extern "C" {
  215. #endif
  216. H5_DLL hid_t H5FDperform_init(hid_t (*)(void));
  217. H5_DLL hid_t H5FDregister(const H5FD_class_t *cls);
  218. H5_DLL htri_t H5FDis_driver_registered_by_name(const char *driver_name);
  219. H5_DLL htri_t H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value);
  220. H5_DLL herr_t H5FDunregister(hid_t driver_id);
  221. H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr);
  222. H5_DLL herr_t H5FDclose(H5FD_t *file);
  223. H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2);
  224. H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags);
  225. H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
  226. H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size);
  227. H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type);
  228. H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa);
  229. H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type);
  230. H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle);
  231. H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
  232. void *buf /*out*/);
  233. H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
  234. const void *buf);
  235. H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
  236. H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
  237. H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw);
  238. H5_DLL herr_t H5FDunlock(H5FD_t *file);
  239. H5_DLL herr_t H5FDdelete(const char *name, hid_t fapl_id);
  240. H5_DLL herr_t H5FDctl(H5FD_t *file, uint64_t op_code, uint64_t flags, const void *input, void **output);
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244. #endif /* _H5FDdevelop_H */