Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-18 09:16:02

0001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
0002  * Copyright by The HDF Group.                                               *
0003  * All rights reserved.                                                      *
0004  *                                                                           *
0005  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
0006  * terms governing use, modification, and redistribution, is contained in    *
0007  * the COPYING file, which can be found at the root of the source code       *
0008  * distribution tree, or in https://www.hdfgroup.org/licenses.               *
0009  * If you do not have access to either file, you may request a copy from     *
0010  * help@hdfgroup.org.                                                        *
0011  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0012 
0013 /*
0014  * This file contains public declarations for the H5FD (file drivers) developer
0015  *      support routines.
0016  */
0017 
0018 #ifndef H5FDdevelop_H
0019 #define H5FDdevelop_H
0020 
0021 /* Include package's public header */
0022 #include "H5FDpublic.h"
0023 
0024 /*****************/
0025 /* Public Macros */
0026 /*****************/
0027 
0028 /**
0029  * Version of the file driver struct, H5FD_class_t
0030  */
0031 #define H5FD_CLASS_VERSION 0x01 /* File driver struct version */
0032 
0033 /* Map "fractal heap" header blocks to 'ohdr' type file memory, since its
0034  * a fair amount of work to add a new kind of file memory and they are similar
0035  * enough to object headers and probably too minor to deserve their own type.
0036  *
0037  * Map "fractal heap" indirect blocks to 'ohdr' type file memory, since they
0038  * are similar to fractal heap header blocks.
0039  *
0040  * Map "fractal heap" direct blocks to 'lheap' type file memory, since they
0041  * will be replacing local heaps.
0042  *
0043  * Map "fractal heap" 'huge' objects to 'draw' type file memory, since they
0044  * represent large objects that are directly stored in the file.
0045  *
0046  *      -QAK
0047  */
0048 
0049 /**
0050  * Fractal heap header block; it is mapped to 'ohdr' type file memory to
0051  * benefit from their similarity.
0052  */
0053 #define H5FD_MEM_FHEAP_HDR H5FD_MEM_OHDR
0054 /**
0055  * Fractal heap indirect block; it is mapped to 'ohdr' type file memory
0056  * because the indirect blocks are similar to fractal heap header blocks.
0057  */
0058 #define H5FD_MEM_FHEAP_IBLOCK H5FD_MEM_OHDR
0059 /**
0060  * Fractal heap direct block; it is mapped to 'lheap' type file memory,
0061  * because the fractal heap direct blocks will be replacing local heaps.
0062  */
0063 #define H5FD_MEM_FHEAP_DBLOCK H5FD_MEM_LHEAP
0064 /**
0065  * Fractal heap 'huge' object; it is mapped to 'draw' type file memory because
0066  * the fractal heap 'huge' objects represent large objects that are directly
0067  * stored in the file.
0068  */
0069 #define H5FD_MEM_FHEAP_HUGE_OBJ H5FD_MEM_DRAW
0070 
0071 /**
0072  * Free space header blocks; it is mapped to 'ohdr' type file memory to
0073  * benefit from their similarity.
0074  */
0075 #define H5FD_MEM_FSPACE_HDR H5FD_MEM_OHDR
0076 /**
0077  * Free space serialized section; it is mapped to 'lheap' type file memory
0078  * because it is similar enough to local heap info.
0079  */
0080 #define H5FD_MEM_FSPACE_SINFO H5FD_MEM_LHEAP
0081 
0082 /**
0083  * Shared object header message master table; it is mapped to 'ohdr' type file
0084  * memory to benefit from their similarity.
0085  */
0086 #define H5FD_MEM_SOHM_TABLE H5FD_MEM_OHDR
0087 /**
0088  * Shared object header message index; it is mapped to 'btree' type file memory
0089  * because the indices are similar enough to B-tree nodes.
0090  */
0091 #define H5FD_MEM_SOHM_INDEX H5FD_MEM_BTREE
0092 /**
0093  * Extensible array header block; it is mapped to 'ohdr' type file memory to
0094  * benefit from their similarity.
0095  */
0096 #define H5FD_MEM_EARRAY_HDR H5FD_MEM_OHDR
0097 /**
0098  * Extensible array index block; it is mapped to 'ohdr' type file memory because
0099  * these index blocks are similar to extensible array header blocks.
0100  */
0101 #define H5FD_MEM_EARRAY_IBLOCK H5FD_MEM_OHDR
0102 /**
0103  * Extensible array super block; it is mappend to 'btree' type file memory
0104  * because the indices are similar enough to B-tree nodes.
0105  */
0106 #define H5FD_MEM_EARRAY_SBLOCK H5FD_MEM_BTREE
0107 /**
0108  * Extensible array data block; it is mapped to 'lheap' type file memory
0109  * because it is similar enough to local heap info.
0110  */
0111 #define H5FD_MEM_EARRAY_DBLOCK H5FD_MEM_LHEAP
0112 /**
0113  * Extensible array data block & page; it is mapped to 'lheap' type file memory
0114  * because it is similar enough to local heap info.
0115  */
0116 #define H5FD_MEM_EARRAY_DBLK_PAGE H5FD_MEM_LHEAP
0117 /**
0118  * Fixed array header block; it is mapped to 'ohdr' type file memory to
0119  * benefit their similarity.
0120  */
0121 #define H5FD_MEM_FARRAY_HDR H5FD_MEM_OHDR
0122 /**
0123  * Fixed array data block; it is mapped to 'lheap' type file memory
0124  * because it is similar enough to local heap info.
0125  */
0126 #define H5FD_MEM_FARRAY_DBLOCK H5FD_MEM_LHEAP
0127 /**
0128  * Fixed array data block & page; it is mapped to 'lheap' type file memory
0129  * because it is similar enough to local heap info.
0130  */
0131 #define H5FD_MEM_FARRAY_DBLK_PAGE H5FD_MEM_LHEAP
0132 
0133 /**
0134  * A free-list map which maps all types of allocation requests to a single
0135  * free list.  This is useful for drivers that don't really care about
0136  * keeping different requests segregated in the underlying file and which
0137  * want to make most efficient reuse of freed memory.  The use of the
0138  * H5FD_MEM_SUPER free list is arbitrary.
0139  */
0140 #define H5FD_FLMAP_SINGLE                                                                                    \
0141     {                                                                                                        \
0142         H5FD_MEM_SUPER,     /*default*/                                                                      \
0143             H5FD_MEM_SUPER, /*super*/                                                                        \
0144             H5FD_MEM_SUPER, /*btree*/                                                                        \
0145             H5FD_MEM_SUPER, /*draw*/                                                                         \
0146             H5FD_MEM_SUPER, /*gheap*/                                                                        \
0147             H5FD_MEM_SUPER, /*lheap*/                                                                        \
0148             H5FD_MEM_SUPER  /*ohdr*/                                                                         \
0149     }
0150 
0151 /**
0152  * A free-list map which segregates requests into `raw' or `meta' data
0153  * pools.
0154  */
0155 #define H5FD_FLMAP_DICHOTOMY                                                                                 \
0156     {                                                                                                        \
0157         H5FD_MEM_SUPER,     /*default*/                                                                      \
0158             H5FD_MEM_SUPER, /*super*/                                                                        \
0159             H5FD_MEM_SUPER, /*btree*/                                                                        \
0160             H5FD_MEM_DRAW,  /*draw*/                                                                         \
0161             H5FD_MEM_DRAW,  /*gheap*/                                                                        \
0162             H5FD_MEM_SUPER, /*lheap*/                                                                        \
0163             H5FD_MEM_SUPER  /*ohdr*/                                                                         \
0164     }
0165 
0166 /**
0167  * The default free list map which causes each request type to use it's own
0168  * free-list.
0169  */
0170 #define H5FD_FLMAP_DEFAULT                                                                                   \
0171     {                                                                                                        \
0172         H5FD_MEM_DEFAULT,     /*default*/                                                                    \
0173             H5FD_MEM_DEFAULT, /*super*/                                                                      \
0174             H5FD_MEM_DEFAULT, /*btree*/                                                                      \
0175             H5FD_MEM_DEFAULT, /*draw*/                                                                       \
0176             H5FD_MEM_DEFAULT, /*gheap*/                                                                      \
0177             H5FD_MEM_DEFAULT, /*lheap*/                                                                      \
0178             H5FD_MEM_DEFAULT  /*ohdr*/                                                                       \
0179     }
0180 
0181 /*******************/
0182 /* Public Typedefs */
0183 /*******************/
0184 
0185 /* Forward declaration */
0186 typedef struct H5FD_t H5FD_t;
0187 
0188 /**
0189  * Class information for each file driver
0190  */
0191 typedef struct H5FD_class_t {
0192     unsigned version;
0193     /**< File driver class struct version number */
0194 
0195     H5FD_class_value_t value;
0196     /**< File driver identifier */
0197 
0198     const char *name;
0199     /**< File driver name, must be unique */
0200 
0201     haddr_t maxaddr;
0202     /**< Maximum address for file */
0203 
0204     H5F_close_degree_t fc_degree;
0205     /**< File close behavior degree */
0206 
0207     herr_t (*terminate)(void);
0208     /**< Shutdowns this driver */
0209 
0210     hsize_t (*sb_size)(H5FD_t *file);
0211     /**< Gets the size of the private information to be stored in the superblock */
0212 
0213     herr_t (*sb_encode)(H5FD_t *file, char *name /*out*/, unsigned char *p /*out*/);
0214     /**< Encodes driver information from the superblock */
0215 
0216     herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p);
0217     /**< Decodes the superblock information for this driver */
0218 
0219     size_t fapl_size; /**< Size of driver-specific file access properties */
0220     void *(*fapl_get)(H5FD_t *file);
0221     /**< Returns the file access property list */
0222 
0223     void *(*fapl_copy)(const void *fapl);
0224     /**< Copies the file access property list */
0225 
0226     herr_t (*fapl_free)(void *fapl);
0227     /**< Frees the driver-specific file access property list */
0228 
0229     size_t dxpl_size;
0230     /**< Size of the transfer property list */
0231 
0232     void *(*dxpl_copy)(const void *dxpl);
0233     /**< Copies the transfer property list */
0234 
0235     herr_t (*dxpl_free)(void *dxpl);
0236     /**< Frees the transfer property list */
0237 
0238     H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl, haddr_t maxaddr);
0239     /**< Create or open an HDF5 file of this driver */
0240 
0241     herr_t (*close)(H5FD_t *file);
0242     /**< Close an HDF5 file of this driver */
0243 
0244     int (*cmp)(const H5FD_t *f1, const H5FD_t *f2);
0245     /**< Compares two files belonging to this driver */
0246 
0247     herr_t (*query)(const H5FD_t *f1, unsigned long *flags);
0248     /**< Sets the flags that this driver is capable of supporting */
0249 
0250     herr_t (*get_type_map)(const H5FD_t *file, H5FD_mem_t *type_map);
0251     /**< Retrieves the memory type mapping for this file */
0252 
0253     haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
0254     /**< Allocates file memory */
0255 
0256     herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size);
0257     /**< Frees the resources for this driver */
0258 
0259     haddr_t (*get_eoa)(const H5FD_t *file, H5FD_mem_t type);
0260     /**< Gets the address of first byte past the addressed space */
0261 
0262     herr_t (*set_eoa)(H5FD_t *file, H5FD_mem_t type, haddr_t addr);
0263     /**< Sets the end-of-address marker for the file */
0264 
0265     haddr_t (*get_eof)(const H5FD_t *file, H5FD_mem_t type);
0266     /**< Gets the address of first byte past the file-end */
0267 
0268     herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void **file_handle);
0269     /**< Returns the file handle of this file driver */
0270 
0271     herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, void *buffer);
0272     /**< Reads the specified number of bytes of data from the file beginning at the specified
0273      * address into the provided buffer, according to the specified data transfer properties  */
0274 
0275     herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl, haddr_t addr, size_t size, const void *buffer);
0276     /**< Writes the specified number of bytes of data to the file beginning at the specified
0277      * address from the provided buffer, according to the specified data transfer properties  */
0278 
0279     herr_t (*read_vector)(H5FD_t *file, hid_t dxpl, uint32_t count, H5FD_mem_t types[], haddr_t addrs[],
0280                           size_t sizes[], void *bufs[]);
0281     /**< Reads the specified length of data from the file into the provided array */
0282 
0283     herr_t (*write_vector)(H5FD_t *file, hid_t dxpl, uint32_t count, H5FD_mem_t types[], haddr_t addrs[],
0284                            size_t sizes[], const void *bufs[]);
0285     /**< Writes the specified length of data in the provided array to the file at the specified offsets */
0286 
0287     herr_t (*read_selection)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, size_t count, hid_t mem_spaces[],
0288                              hid_t file_spaces[], haddr_t offsets[], size_t element_sizes[],
0289                              void *bufs[] /*out*/);
0290     /**< */
0291 
0292     herr_t (*write_selection)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, size_t count, hid_t mem_spaces[],
0293                               hid_t file_spaces[], haddr_t offsets[], size_t element_sizes[],
0294                               const void *bufs[] /*in*/);
0295     /**< */
0296 
0297     herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
0298     /**< Flushes all data to disk */
0299 
0300     herr_t (*truncate)(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
0301     /**< Truncates a file */
0302 
0303     herr_t (*lock)(H5FD_t *file, hbool_t rw);
0304     /**< Places an advisory lock on a file */
0305 
0306     herr_t (*unlock)(H5FD_t *file);
0307     /**< Removes the existing lock on a file */
0308 
0309     herr_t (*del)(const char *name, hid_t fapl);
0310     /**< Deletes a file */
0311 
0312     herr_t (*ctl)(H5FD_t *file, uint64_t op_code, uint64_t flags, const void *input, void **output);
0313     /**< Performs a CTL operation */
0314 
0315     H5FD_mem_t fl_map[H5FD_MEM_NTYPES];
0316     /**< Free-list map */
0317 } H5FD_class_t;
0318 
0319 /**
0320  * A free list is a singly-linked list of address/size pairs.
0321  */
0322 typedef struct H5FD_free_t {
0323     haddr_t             addr;
0324     hsize_t             size;
0325     struct H5FD_free_t *next;
0326 } H5FD_free_t;
0327 
0328 /**
0329  * The main datatype for each driver. Public fields common to all drivers
0330  * are declared here and the driver appends private fields in memory.
0331  */
0332 struct H5FD_t {
0333     hid_t               driver_id;     /**< Driver ID for this file   */
0334     const H5FD_class_t *cls;           /**< Constant class info       */
0335     unsigned long       fileno;        /**< File 'serial' number     */
0336     unsigned            access_flags;  /**< File access flags (from create or open) */
0337     unsigned long       feature_flags; /**< VFL Driver feature Flags */
0338     haddr_t             maxaddr;       /**< For this file, overrides class */
0339     haddr_t             base_addr;     /**< Base address for HDF5 data w/in file */
0340 
0341     /* Space allocation management fields */
0342     hsize_t threshold;  /**< Threshold for alignment  */
0343     hsize_t alignment;  /**< Allocation alignment     */
0344     hbool_t paged_aggr; /**< Paged aggregation for file space is enabled or not */
0345 };
0346 
0347 /* VFD initialization function */
0348 typedef hid_t (*H5FD_init_t)(void);
0349 
0350 /********************/
0351 /* Public Variables */
0352 /********************/
0353 
0354 /*********************/
0355 /* Public Prototypes */
0356 /*********************/
0357 
0358 #ifdef __cplusplus
0359 extern "C" {
0360 #endif
0361 
0362 H5_DLL hid_t   H5FDperform_init(H5FD_init_t op);
0363 H5_DLL hid_t   H5FDregister(const H5FD_class_t *cls);
0364 H5_DLL htri_t  H5FDis_driver_registered_by_name(const char *driver_name);
0365 H5_DLL htri_t  H5FDis_driver_registered_by_value(H5FD_class_value_t driver_value);
0366 H5_DLL herr_t  H5FDunregister(hid_t driver_id);
0367 H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr);
0368 H5_DLL herr_t  H5FDclose(H5FD_t *file);
0369 H5_DLL int     H5FDcmp(const H5FD_t *f1, const H5FD_t *f2);
0370 H5_DLL herr_t  H5FDquery(const H5FD_t *f, unsigned long *flags);
0371 H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
0372 H5_DLL herr_t  H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size);
0373 H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type);
0374 H5_DLL herr_t  H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa);
0375 H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type);
0376 H5_DLL herr_t  H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle);
0377 H5_DLL herr_t  H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
0378                         void *buf /*out*/);
0379 H5_DLL herr_t  H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
0380                          const void *buf);
0381 H5_DLL herr_t  H5FDread_vector(H5FD_t *file, hid_t dxpl_id, uint32_t count, H5FD_mem_t types[],
0382                                haddr_t addrs[], size_t sizes[], void *bufs[] /* out */);
0383 H5_DLL herr_t  H5FDwrite_vector(H5FD_t *file, hid_t dxpl_id, uint32_t count, H5FD_mem_t types[],
0384                                 haddr_t addrs[], size_t sizes[], const void *bufs[] /* in */);
0385 H5_DLL herr_t  H5FDread_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
0386                                   hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
0387                                   size_t element_sizes[], void *bufs[] /* out */);
0388 H5_DLL herr_t  H5FDwrite_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
0389                                    hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
0390                                    size_t element_sizes[], const void *bufs[]);
0391 H5_DLL herr_t  H5FDread_vector_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
0392                                               hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
0393                                               size_t element_sizes[], void *bufs[] /* out */);
0394 H5_DLL herr_t  H5FDwrite_vector_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
0395                                                hid_t mem_spaces[], hid_t file_spaces[], haddr_t offsets[],
0396                                                size_t element_sizes[], const void *bufs[] /* in */);
0397 H5_DLL herr_t  H5FDread_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
0398                                        hid_t mem_space_ids[], hid_t file_space_ids[], haddr_t offsets[],
0399                                        size_t element_sizes[], void *bufs[] /* out */);
0400 H5_DLL herr_t  H5FDwrite_from_selection(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, uint32_t count,
0401                                         hid_t mem_space_ids[], hid_t file_space_ids[], haddr_t offsets[],
0402                                         size_t element_sizes[], const void *bufs[] /* in */);
0403 H5_DLL herr_t  H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
0404 H5_DLL herr_t  H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing);
0405 H5_DLL herr_t  H5FDlock(H5FD_t *file, hbool_t rw);
0406 H5_DLL herr_t  H5FDunlock(H5FD_t *file);
0407 H5_DLL herr_t  H5FDdelete(const char *name, hid_t fapl_id);
0408 H5_DLL herr_t  H5FDctl(H5FD_t *file, uint64_t op_code, uint64_t flags, const void *input, void **output);
0409 
0410 #ifdef __cplusplus
0411 }
0412 #endif
0413 
0414 #endif /* H5FDdevelop_H */