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