00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef H5O_PACKAGE
00017 #error "Do not include this file outside the H5O package!"
00018 #endif
00019
00020 #ifndef _H5Opkg_H
00021 #define _H5Opkg_H
00022
00023
00024 #include "H5Oprivate.h"
00025
00026
00027 #include "H5ACprivate.h"
00028
00029
00030 #define H5O_NMESGS 8
00031 #define H5O_NCHUNKS 2
00032 #define H5O_MIN_SIZE 22
00033 #define H5O_MSG_TYPES 24
00034 #define H5O_MAX_CRT_ORDER_IDX 65535
00035
00036
00037
00038
00039 #define H5O_VERSION_1 1
00040
00041
00042
00043
00044 #define H5O_VERSION_2 2
00045
00046
00047
00048 #define H5O_VERSION_LATEST H5O_VERSION_2
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #define H5O_ALIGN_OLD(X) (8 * (((X) + 7) / 8))
00059 #define H5O_ALIGN_VERS(V, X) \
00060 (((V) == H5O_VERSION_1) ? \
00061 H5O_ALIGN_OLD(X) \
00062 : \
00063 (X) \
00064 )
00065 #define H5O_ALIGN_OH(O, X) \
00066 H5O_ALIGN_VERS((O)->version, X)
00067 #define H5O_ALIGN_F(F, X) \
00068 H5O_ALIGN_VERS((H5F_USE_LATEST_FORMAT(F) ? H5O_VERSION_LATEST : H5O_VERSION_1), X)
00069
00070
00071 #define H5O_SIZEOF_CHKSUM 4
00072
00073
00074
00075
00076
00077
00078
00079
00080 #define H5O_CRT_ATTR_MAX_COMPACT_DEF 8
00081 #define H5O_CRT_ATTR_MIN_DENSE_DEF 6
00082 #define H5O_CRT_OHDR_FLAGS_DEF H5O_HDR_STORE_TIMES
00083
00084
00085 #define H5O_HDR_CHUNK0_1 0x00
00086 #define H5O_HDR_CHUNK0_2 0x01
00087 #define H5O_HDR_CHUNK0_4 0x02
00088 #define H5O_HDR_CHUNK0_8 0x03
00089
00090
00091
00092
00093 #define H5O_SIZEOF_HDR(O) \
00094 (((O)->version == H5O_VERSION_1) \
00095 ? \
00096 H5O_ALIGN_OLD(1 + \
00097 1 + \
00098 2 + \
00099 4 + \
00100 4) \
00101 : \
00102 (H5_SIZEOF_MAGIC + \
00103 1 + \
00104 1 + \
00105 (((O)->flags & H5O_HDR_STORE_TIMES) ? ( \
00106 4 + \
00107 4 + \
00108 4 + \
00109 4 \
00110 ) : 0) + \
00111 (((O)->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) ? ( \
00112 2 + \
00113 2 \
00114 ) : 0) + \
00115 (1 << ((O)->flags & H5O_HDR_CHUNK0_SIZE)) + \
00116 H5O_SIZEOF_CHKSUM) \
00117 )
00118
00119
00120
00121
00122 #define H5O_SIZEOF_MSGHDR_VERS(V,C) \
00123 (((V) == H5O_VERSION_1) \
00124 ? \
00125 H5O_ALIGN_OLD(2 + \
00126 2 + \
00127 1 + \
00128 3) \
00129 : \
00130 (1 + \
00131 2 + \
00132 1 + \
00133 ((C) ? ( \
00134 2 \
00135 ) : 0)) \
00136 )
00137 #define H5O_SIZEOF_MSGHDR_OH(O) \
00138 H5O_SIZEOF_MSGHDR_VERS((O)->version, (O)->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)
00139 #define H5O_SIZEOF_MSGHDR_F(F, C) \
00140 H5O_SIZEOF_MSGHDR_VERS((H5F_USE_LATEST_FORMAT(F) || H5F_STORE_MSG_CRT_IDX(F)) ? H5O_VERSION_LATEST : H5O_VERSION_1, (C))
00141
00142
00143
00144
00145 #define H5O_SIZEOF_CHKHDR_VERS(V) \
00146 (((V) == H5O_VERSION_1) \
00147 ? \
00148 0 + \
00149 0 \
00150 : \
00151 H5_SIZEOF_MAGIC + \
00152 H5O_SIZEOF_CHKSUM \
00153 )
00154 #define H5O_SIZEOF_CHKHDR_OH(O) \
00155 H5O_SIZEOF_CHKHDR_VERS((O)->version)
00156
00157
00158
00159
00160 #define H5O_SIZEOF_CHKSUM_VERS(V) \
00161 (((V) == H5O_VERSION_1) \
00162 ? \
00163 0 \
00164 : \
00165 H5O_SIZEOF_CHKSUM \
00166 )
00167 #define H5O_SIZEOF_CHKSUM_OH(O) \
00168 H5O_SIZEOF_CHKSUM_VERS((O)->version)
00169
00170
00171 #define H5O_DECODEIO_NOCHANGE 0x01u
00172 #define H5O_DECODEIO_DIRTY 0x02u
00173
00174
00175 #ifndef NDEBUG
00176 #define INCR_NDECODE_DIRTIED(OH) (OH)->ndecode_dirtied++;
00177 #else
00178 #define INCR_NDECODE_DIRTIED(OH) ;
00179 #endif
00180
00181
00182
00183 #define H5O_LOAD_NATIVE(F, DXPL, IOF, OH, MSG, ERR) \
00184 if(NULL == (MSG)->native) { \
00185 const H5O_msg_class_t *msg_type = (MSG)->type; \
00186 unsigned ioflags = (IOF); \
00187 \
00188 \
00189 HDassert(msg_type->decode); \
00190 if(NULL == ((MSG)->native = (msg_type->decode)((F), (DXPL), (OH), (MSG)->flags, &ioflags, (MSG)->raw))) \
00191 HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
00192 \
00193 \
00194 if((ioflags & H5O_DECODEIO_DIRTY) && (H5F_get_intent((F)) & H5F_ACC_RDWR)) { \
00195 (MSG)->dirty = TRUE; \
00196 \
00197 \
00198 INCR_NDECODE_DIRTIED(OH) \
00199 } \
00200 \
00201 \
00202 if((MSG)->flags & H5O_MSG_FLAG_SHAREABLE) { \
00203 H5O_UPDATE_SHARED((H5O_shared_t *)(MSG)->native, H5O_SHARE_TYPE_HERE, (F), msg_type->id, (MSG)->crt_idx, (OH)->chunk[0].addr) \
00204 } \
00205 \
00206 \
00207 if(msg_type->set_crt_index) { \
00208 \
00209 if((msg_type->set_crt_index)((MSG)->native, (MSG)->crt_idx) < 0) \
00210 HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, ERR, "unable to set creation index") \
00211 } \
00212 }
00213
00214
00215 #define H5O_SHARE_IS_SHARABLE 0x01
00216 #define H5O_SHARE_IN_OHDR 0x02
00217
00218
00219
00220 struct H5O_msg_class_t {
00221 unsigned id;
00222 const char *name;
00223 size_t native_size;
00224 unsigned share_flags;
00225 void *(*decode)(H5F_t*, hid_t, H5O_t *, unsigned, unsigned *, const uint8_t *);
00226 herr_t (*encode)(H5F_t*, hbool_t, uint8_t*, const void *);
00227 void *(*copy)(const void *, void *);
00228 size_t (*raw_size)(const H5F_t *, hbool_t, const void *);
00229 herr_t (*reset)(void *);
00230 herr_t (*free)(void *);
00231 herr_t (*del)(H5F_t *, hid_t, H5O_t *, void *);
00232 herr_t (*link)(H5F_t *, hid_t, H5O_t *, void *);
00233 herr_t (*set_share)(void*, const H5O_shared_t*);
00234 htri_t (*can_share)(const void *);
00235 herr_t (*pre_copy_file)(H5F_t *, const void *, hbool_t *, const H5O_copy_t *, void *);
00236 void *(*copy_file)(H5F_t *, void *, H5F_t *, hbool_t *, H5O_copy_t *, void *, hid_t);
00237 herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, hid_t, H5O_copy_t *);
00238 herr_t (*get_crt_index)(const void *, H5O_msg_crt_idx_t *);
00239 herr_t (*set_crt_index)(void *, H5O_msg_crt_idx_t);
00240 herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int);
00241 };
00242
00243 struct H5O_mesg_t {
00244 const H5O_msg_class_t *type;
00245 hbool_t dirty;
00246 uint8_t flags;
00247 H5O_msg_crt_idx_t crt_idx;
00248 unsigned chunkno;
00249 void *native;
00250 uint8_t *raw;
00251 size_t raw_size;
00252 };
00253
00254 typedef struct H5O_chunk_t {
00255 hbool_t dirty;
00256 haddr_t addr;
00257 size_t size;
00258 size_t gap;
00259 uint8_t *image;
00260 } H5O_chunk_t;
00261
00262 struct H5O_t {
00263 H5AC_info_t cache_info;
00264
00265
00266
00267 size_t sizeof_size;
00268 size_t sizeof_addr;
00269 #ifdef H5O_ENABLE_BAD_MESG_COUNT
00270 hbool_t store_bad_mesg_count;
00271
00272
00273
00274 #endif
00275 #ifndef NDEBUG
00276 size_t ndecode_dirtied;
00277 #endif
00278
00279
00280 hbool_t has_refcount_msg;
00281 unsigned nlink;
00282 uint8_t version;
00283 uint8_t flags;
00284
00285
00286 time_t atime;
00287 time_t mtime;
00288 time_t ctime;
00289 time_t btime;
00290
00291
00292 unsigned max_compact;
00293 unsigned min_dense;
00294
00295
00296 size_t nmesgs;
00297 size_t alloc_nmesgs;
00298 H5O_mesg_t *mesg;
00299 size_t link_msgs_seen;
00300 size_t attr_msgs_seen;
00301
00302
00303 size_t nchunks;
00304 size_t alloc_nchunks;
00305 H5O_chunk_t *chunk;
00306 };
00307
00308
00309 typedef struct H5D_copy_file_ud_t {
00310 struct H5S_extent_t *src_space_extent;
00311 H5T_t *src_dtype;
00312 H5O_pline_t *src_pline;
00313 } H5D_copy_file_ud_t;
00314
00315
00316 typedef struct H5O_obj_class_t {
00317 H5O_type_t type;
00318 const char *name;
00319 void *(*get_copy_file_udata)(void);
00320 void (*free_copy_file_udata)(void *);
00321 htri_t (*isa)(H5O_t *);
00322 hid_t (*open)(const H5G_loc_t *, hid_t, hid_t, hbool_t );
00323 void *(*create)(H5F_t *, void *, H5G_loc_t *, hid_t );
00324 H5O_loc_t *(*get_oloc)(hid_t );
00325 } H5O_obj_class_t;
00326
00327
00328 typedef struct H5O_addr_map_t {
00329 haddr_t src_addr;
00330 haddr_t dst_addr;
00331 hbool_t is_locked;
00332 hsize_t inc_ref_count;
00333 } H5O_addr_map_t;
00334
00335
00336
00337 H5_DLLVAR const H5AC_class_t H5AC_OHDR[1];
00338
00339
00340 H5_DLLVAR const H5O_msg_class_t *const H5O_msg_class_g[H5O_MSG_TYPES];
00341
00342
00343 H5_DLLVAR const H5O_obj_class_t *const H5O_obj_class_g[3];
00344
00345
00346 H5FL_EXTERN(H5O_t);
00347
00348
00349 H5FL_SEQ_EXTERN(H5O_mesg_t);
00350
00351
00352 H5FL_SEQ_EXTERN(H5O_chunk_t);
00353
00354
00355 H5FL_BLK_EXTERN(chunk_image);
00356
00357
00358
00359
00360
00361
00362 H5_DLLVAR const H5O_msg_class_t H5O_MSG_NULL[1];
00363
00364
00365 H5_DLLVAR const H5O_msg_class_t H5O_MSG_SDSPACE[1];
00366
00367
00368 H5_DLLVAR const H5O_msg_class_t H5O_MSG_LINFO[1];
00369
00370
00371 H5_DLLVAR const H5O_msg_class_t H5O_MSG_DTYPE[1];
00372
00373
00374 H5_DLLVAR const H5O_msg_class_t H5O_MSG_FILL[1];
00375
00376
00377
00378
00379
00380
00381
00382 H5_DLLVAR const H5O_msg_class_t H5O_MSG_FILL_NEW[1];
00383
00384
00385 H5_DLLVAR const H5O_msg_class_t H5O_MSG_LINK[1];
00386
00387
00388 H5_DLLVAR const H5O_msg_class_t H5O_MSG_EFL[1];
00389
00390
00391 H5_DLLVAR const H5O_msg_class_t H5O_MSG_LAYOUT[1];
00392
00393 #ifdef H5O_ENABLE_BOGUS
00394
00395
00396
00397
00398 H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS[1];
00399 #endif
00400
00401
00402 H5_DLLVAR const H5O_msg_class_t H5O_MSG_GINFO[1];
00403
00404
00405 H5_DLLVAR const H5O_msg_class_t H5O_MSG_PLINE[1];
00406
00407
00408 H5_DLLVAR const H5O_msg_class_t H5O_MSG_ATTR[1];
00409
00410
00411 H5_DLLVAR const H5O_msg_class_t H5O_MSG_NAME[1];
00412
00413
00414
00415
00416
00417
00418 H5_DLLVAR const H5O_msg_class_t H5O_MSG_MTIME[1];
00419
00420
00421
00422
00423
00424 H5_DLLVAR const H5O_msg_class_t H5O_MSG_SHMESG[1];
00425
00426
00427 H5_DLLVAR const H5O_msg_class_t H5O_MSG_CONT[1];
00428
00429
00430 H5_DLLVAR const H5O_msg_class_t H5O_MSG_STAB[1];
00431
00432
00433
00434
00435
00436 H5_DLLVAR const H5O_msg_class_t H5O_MSG_MTIME_NEW[1];
00437
00438
00439
00440
00441
00442 H5_DLLVAR const H5O_msg_class_t H5O_MSG_BTREEK[1];
00443
00444
00445
00446
00447
00448 H5_DLLVAR const H5O_msg_class_t H5O_MSG_DRVINFO[1];
00449
00450
00451 H5_DLLVAR const H5O_msg_class_t H5O_MSG_AINFO[1];
00452
00453
00454 H5_DLLVAR const H5O_msg_class_t H5O_MSG_REFCOUNT[1];
00455
00456
00457 H5_DLLVAR const H5O_msg_class_t H5O_MSG_UNKNOWN[1];
00458
00459
00460
00461
00462
00463
00464
00465 H5_DLLVAR const H5O_obj_class_t H5O_OBJ_GROUP[1];
00466
00467
00468 H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATASET[1];
00469
00470
00471 H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1];
00472
00473
00474
00475 H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg);
00476 H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh);
00477 H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref);
00478 H5_DLL herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, H5O_mesg_t *mesg);
00479 H5_DLL const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh);
00480
00481
00482 H5_DLL unsigned H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00483 const H5O_msg_class_t *type, unsigned *mesg_flags, void *mesg);
00484 H5_DLL herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00485 const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags,
00486 void *mesg);
00487 H5_DLL herr_t H5O_msg_write_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00488 const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags,
00489 void *mesg);
00490 H5_DLL void *H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg);
00491 H5_DLL herr_t H5O_msg_free_mesg(H5O_mesg_t *mesg);
00492 H5_DLL unsigned H5O_msg_count_real(const H5O_t *oh, const H5O_msg_class_t *type);
00493 H5_DLL herr_t H5O_msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
00494 int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id);
00495 H5_DLL void *H5O_msg_copy_file(const H5O_msg_class_t *type, H5F_t *file_src,
00496 void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size,
00497 H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id);
00498 H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
00499 const H5O_mesg_operator_t *op, void *op_data, hid_t dxpl_id);
00500
00501
00502 H5_DLL herr_t H5O_group_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00503 H5_ih_info_t *bh_info);
00504 H5_DLL herr_t H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00505 H5_ih_info_t *bh_info);
00506 H5_DLL herr_t H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00507 H5_ih_info_t *bh_info);
00508
00509
00510 H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc);
00511 H5_DLL unsigned H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00512 const H5O_msg_class_t *type, const void *mesg);
00513 H5_DLL herr_t H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id);
00514 H5_DLL herr_t H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00515 H5O_mesg_t *mesg, hbool_t adj_link);
00516
00517
00518 H5_DLL void * H5O_shared_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
00519 unsigned *ioflags, const uint8_t *buf, const H5O_msg_class_t *type);
00520 H5_DLL herr_t H5O_shared_encode(const H5F_t *f, uint8_t *buf, const H5O_shared_t *sh_mesg);
00521 H5_DLL size_t H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg);
00522 H5_DLL herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
00523 const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg);
00524 H5_DLL herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
00525 const H5O_msg_class_t *mesg_type, H5O_shared_t *sh_mesg);
00526 H5_DLL herr_t H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst,
00527 const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst,
00528 hbool_t *recompute_size, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id);
00529 H5_DLL herr_t H5O_shared_post_copy_file (H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *mesg);
00530 H5_DLL herr_t H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream,
00531 int indent, int fwidth);
00532
00533
00534 H5_DLL herr_t H5O_attr_reset(void *_mesg);
00535 H5_DLL herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg);
00536 H5_DLL herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg);
00537 H5_DLL herr_t H5O_attr_count_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
00538 hsize_t *nattrs);
00539
00540
00541
00542 H5_DLL H5O_loc_t *H5O_get_loc(hid_t id);
00543
00544
00545 H5_DLL herr_t H5O_dest(H5F_t *f, H5O_t *oh);
00546
00547
00548 #ifdef H5O_TESTING
00549 H5_DLL htri_t H5O_is_attr_empty_test(hid_t oid);
00550 H5_DLL htri_t H5O_is_attr_dense_test(hid_t oid);
00551 H5_DLL herr_t H5O_num_attrs_test(hid_t oid, hsize_t *nattrs);
00552 H5_DLL herr_t H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count);
00553 H5_DLL herr_t H5O_check_msg_marked_test(hid_t oid, hbool_t flag_val);
00554 #endif
00555
00556
00557 #ifdef H5O_DEBUG
00558 H5_DLL herr_t H5O_assert(const H5O_t *oh);
00559 #endif
00560 H5_DLL herr_t H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth);
00561
00562 #endif
00563