/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Module Info: This module contains most of the "core" functionality of
* the H5T interface, including the API initialization code, etc.
* Many routines that are infrequently used, or are specialized for
* one particular datatype class are in another module.
*/
/****************/
/* Module Setup */
/****************/
#include "H5Tmodule.h" /* This source code file is part of the H5T module */
/***********/
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free Lists */
#include "H5FOprivate.h" /* File objects */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
#include "H5Tpkg.h" /* Datatypes */
/* Check for header needed for SGI floating-point code */
#ifdef H5_HAVE_SYS_FPU_H
#include <sys/fpu.h>
#endif /* H5_HAVE_SYS_FPU_H */
/****************/
/* Local Macros */
/****************/
#define H5T_ENCODE_VERSION 0
/*
* Type initialization macros
*
* These use the "template macro" technique to reduce the amount of gratuitous
* duplicated code when initializing the datatypes for the library. The main
* template macro is the H5T_INIT_TYPE() macro below.
*
*/
/* Define the code template for bitfields for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_BITFIELD_CORE { \
dt->shared->type = H5T_BITFIELD; \
}
/* Define the code template for times for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_TIME_CORE { \
dt->shared->type = H5T_TIME; \
}
/* Define the code template for types which reset the offset for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_OFFSET_CORE { \
dt->shared->u.atomic.offset = 0; \
}
/* Define common code for all numeric types (floating-point & int, signed & unsigned) */
#define H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) { \
dt->shared->u.atomic.order = ENDIANNESS; \
dt->shared->u.atomic.offset = 0; \
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; \
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \
}
/* Define the code templates for standard floats for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) { \
H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \
dt->shared->u.atomic.u.f.sign = 31; \
dt->shared->u.atomic.u.f.epos = 23; \
dt->shared->u.atomic.u.f.esize = 8; \
dt->shared->u.atomic.u.f.ebias = 0x7f; \
dt->shared->u.atomic.u.f.mpos = 0; \
dt->shared->u.atomic.u.f.msize = 23; \
dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \
}
#define H5T_INIT_TYPE_FLOATLE_CORE { \
H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_LE) \
}
#define H5T_INIT_TYPE_FLOATBE_CORE { \
H5T_INIT_TYPE_FLOAT_COMMON(H5T_ORDER_BE) \
}
/* Define the code templates for standard doubles for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_DOUBLE_COMMON(ENDIANNESS) { \
H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \
dt->shared->u.atomic.u.f.sign = 63; \
dt->shared->u.atomic.u.f.epos = 52; \
dt->shared->u.atomic.u.f.esize = 11; \
dt->shared->u.atomic.u.f.ebias = 0x03ff; \
dt->shared->u.atomic.u.f.mpos = 0; \
dt->shared->u.atomic.u.f.msize = 52; \
dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \
}
#define H5T_INIT_TYPE_DOUBLELE_CORE { \
H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_LE) \
}
#define H5T_INIT_TYPE_DOUBLEBE_CORE { \
H5T_INIT_TYPE_DOUBLE_COMMON(H5T_ORDER_BE) \
}
/* Define the code templates for VAX float for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_FLOATVAX_CORE { \
H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \
dt->shared->u.atomic.u.f.sign = 31; \
dt->shared->u.atomic.u.f.epos = 23; \
dt->shared->u.atomic.u.f.esize = 8; \
dt->shared->u.atomic.u.f.ebias = 0x81; \
dt->shared->u.atomic.u.f.mpos = 0; \
dt->shared->u.atomic.u.f.msize = 23; \
dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \
dt->shared->version = H5O_DTYPE_VERSION_3; \
}
/* Define the code templates for VAX double for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_DOUBLEVAX_CORE { \
H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_VAX) \
dt->shared->u.atomic.u.f.sign = 63; \
dt->shared->u.atomic.u.f.epos = 52; \
dt->shared->u.atomic.u.f.esize = 11; \
dt->shared->u.atomic.u.f.ebias = 0x0401; \
dt->shared->u.atomic.u.f.mpos = 0; \
dt->shared->u.atomic.u.f.msize = 52; \
dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \
dt->shared->version = H5O_DTYPE_VERSION_3; \
}
/* Define the code templates for standard signed integers for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_SINT_COMMON(ENDIANNESS) { \
H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \
dt->shared->u.atomic.u.i.sign = H5T_SGN_2; \
}
#define H5T_INIT_TYPE_SINTLE_CORE { \
H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_LE) \
}
#define H5T_INIT_TYPE_SINTBE_CORE { \
H5T_INIT_TYPE_SINT_COMMON(H5T_ORDER_BE) \
}
/* Define the code templates for standard unsigned integers for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_UINT_COMMON(ENDIANNESS) { \
H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \
dt->shared->u.atomic.u.i.sign = H5T_SGN_NONE; \
}
#define H5T_INIT_TYPE_UINTLE_CORE { \
H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_LE) \
}
#define H5T_INIT_TYPE_UINTBE_CORE { \
H5T_INIT_TYPE_UINT_COMMON(H5T_ORDER_BE) \
}
/* Define a macro for common code for all newly allocate datatypes */
#define H5T_INIT_TYPE_ALLOC_COMMON(TYPE) { \
dt->sh_loc.type = H5O_SHARE_TYPE_UNSHARED; \
dt->shared->type = TYPE; \
}
/* Define the code templates for opaque for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_OPAQ_CORE { \
H5T_INIT_TYPE_ALLOC_COMMON(H5T_OPAQUE) \
dt->shared->u.opaque.tag = H5MM_xstrdup(""); \
}
/* Define the code templates for strings for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_STRING_COMMON { \
H5T_INIT_TYPE_ALLOC_COMMON(H5T_STRING) \
H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \
dt->shared->u.atomic.u.s.cset = H5F_DEFAULT_CSET; \
}
#define H5T_INIT_TYPE_CSTRING_CORE { \
H5T_INIT_TYPE_STRING_COMMON \
dt->shared->u.atomic.u.s.pad = H5T_STR_NULLTERM; \
}
#define H5T_INIT_TYPE_FORSTRING_CORE { \
H5T_INIT_TYPE_STRING_COMMON \
dt->shared->u.atomic.u.s.pad = H5T_STR_SPACEPAD; \
}
/* Define the code templates for references for the "GUTS" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_REF_COMMON { \
H5T_INIT_TYPE_ALLOC_COMMON(H5T_REFERENCE) \
H5T_INIT_TYPE_NUM_COMMON(H5T_ORDER_NONE) \
}
#define H5T_INIT_TYPE_OBJREF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
dt->shared->force_conv = TRUE; \
dt->shared->u.atomic.u.r.rtype = H5R_OBJECT; \
dt->shared->u.atomic.u.r.loc = H5T_LOC_MEMORY; \
}
#define H5T_INIT_TYPE_REGREF_CORE { \
H5T_INIT_TYPE_REF_COMMON \
dt->shared->u.atomic.u.r.rtype = H5R_DATASET_REGION; \
}
/* Define the code templates for the "SIZE_TMPL" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_SET_SIZE(SIZE) { \
dt->shared->size = SIZE; \
dt->shared->u.atomic.prec = 8 * SIZE; \
}
#define H5T_INIT_TYPE_NOSET_SIZE(SIZE) { \
}
/* Define the code templates for the "CRT_TMPL" in the H5T_INIT_TYPE macro */
#define H5T_INIT_TYPE_COPY_CREATE(BASE) { \
/* Base off of existing datatype */ \
if(NULL == (dt = H5T_copy(BASE, H5T_COPY_TRANSIENT))) \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "duplicating base type failed") \
}
#define H5T_INIT_TYPE_ALLOC_CREATE(BASE) { \
/* Allocate new datatype info */ \
if(NULL == (dt = H5T__alloc())) \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") \
}
#define H5T_INIT_TYPE(GUTS,GLOBAL,CRT_TMPL,BASE,SIZE_TMPL,SIZE) { \
/* Get new datatype struct */ \
H5_GLUE3(H5T_INIT_TYPE_,CRT_TMPL,_CREATE)(BASE) \
\
/* Adjust information for all types */ \
dt->shared->state = H5T_STATE_IMMUTABLE; \
H5_GLUE3(H5T_INIT_TYPE_,SIZE_TMPL,_SIZE)(SIZE) \
\
/* Adjust information for this type */ \
H5_GLUE3(H5T_INIT_TYPE_, GUTS, _CORE) \
\
/* Atomize result */ \
if((GLOBAL = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0) \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") \
}
/******************/
/* Local Typedefs */
/******************/
/********************/
/* Local Prototypes */
/********************/
static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
H5T_t *dst, H5T_conv_t func, hid_t dxpl_id);
static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src,
H5T_t *dst, H5T_conv_t func, hid_t dxpl_id, hbool_t api_call);
static htri_t H5T_compiler_conv(H5T_t *src, H5T_t *dst);
static herr_t H5T_set_size(H5T_t *dt, size_t size);
/*****************************/
/* Library Private Variables */
/*****************************/
/* The native endianess of the platform */
H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR;
/*********************/
/* Package Variables */
/*********************/
/* Package initialization variable */
hbool_t H5_PKG_INIT_VAR = FALSE;
/*
* Predefined data types. These are initialized at runtime in H5Tinit.c and
* by H5T__init_package() in this source file.
*
* If more of these are added, the new ones must be added to the list of
* types to reset in H5T_term_package().
*/
hid_t H5T_IEEE_F32BE_g = FAIL;
hid_t H5T_IEEE_F32LE_g = FAIL;
hid_t H5T_IEEE_F64BE_g = FAIL;
hid_t H5T_IEEE_F64LE_g = FAIL;
hid_t H5T_VAX_F32_g = FAIL;
hid_t H5T_VAX_F64_g = FAIL;
hid_t H5T_STD_I8BE_g = FAIL;
hid_t H5T_STD_I8LE_g = FAIL;
hid_t H5T_STD_I16BE_g = FAIL;
hid_t H5T_STD_I16LE_g = FAIL;
hid_t H5T_STD_I32BE_g = FAIL;
hid_t H5T_STD_I32LE_g = FAIL;
hid_t H5T_STD_I64BE_g = FAIL;
hid_t H5T_STD_I64LE_g = FAIL;
hid_t H5T_STD_U8BE_g = FAIL;
hid_t H5T_STD_U8LE_g = FAIL;
hid_t H5T_STD_U16BE_g = FAIL;
hid_t H5T_STD_U16LE_g = FAIL;
hid_t H5T_STD_U32BE_g = FAIL;
hid_t H5T_STD_U32LE_g = FAIL;
hid_t H5T_STD_U64BE_g = FAIL;
hid_t H5T_STD_U64LE_g = FAIL;
hid_t H5T_STD_B8BE_g = FAIL;
hid_t H5T_STD_B8LE_g = FAIL;
hid_t H5T_STD_B16BE_g = FAIL;
hid_t H5T_STD_B16LE_g = FAIL;
hid_t H5T_STD_B32BE_g = FAIL;
hid_t H5T_STD_B32LE_g = FAIL;
hid_t H5T_STD_B64BE_g = FAIL;
hid_t H5T_STD_B64LE_g = FAIL;
hid_t H5T_STD_REF_OBJ_g = FAIL;
hid_t H5T_STD_REF_DSETREG_g = FAIL;
hid_t H5T_UNIX_D32BE_g = FAIL;
hid_t H5T_UNIX_D32LE_g = FAIL;
hid_t H5T_UNIX_D64BE_g = FAIL;
hid_t H5T_UNIX_D64LE_g = FAIL;
hid_t H5T_C_S1_g = FAIL;
hid_t H5T_FORTRAN_S1_g = FAIL;
hid_t H5T_NATIVE_SCHAR_g = FAIL;
hid_t H5T_NATIVE_UCHAR_g = FAIL;
hid_t H5T_NATIVE_SHORT_g = FAIL;
hid_t H5T_NATIVE_USHORT_g = FAIL;
hid_t H5T_NATIVE_INT_g = FAIL;
hid_t H5T_NATIVE_UINT_g = FAIL;
hid_t H5T_NATIVE_LONG_g = FAIL;
hid_t H5T_NATIVE_ULONG_g = FAIL;
hid_t H5T_NATIVE_LLONG_g = FAIL;
hid_t H5T_NATIVE_ULLONG_g = FAIL;
hid_t H5T_NATIVE_FLOAT_g = FAIL;
hid_t H5T_NATIVE_DOUBLE_g = FAIL;
#if H5_SIZEOF_LONG_DOUBLE !=0
hid_t H5T_NATIVE_LDOUBLE_g = FAIL;
#endif
hid_t H5T_NATIVE_B8_g = FAIL;
hid_t H5T_NATIVE_B16_g = FAIL;
hid_t H5T_NATIVE_B32_g = FAIL;
hid_t H5T_NATIVE_B64_g = FAIL;
hid_t H5T_NATIVE_OPAQUE_g = FAIL;
hid_t H5T_NATIVE_HADDR_g = FAIL;
hid_t H5T_NATIVE_HSIZE_g = FAIL;
hid_t H5T_NATIVE_HSSIZE_g = FAIL;
hid_t H5T_NATIVE_HERR_g = FAIL;
hid_t H5T_NATIVE_HBOOL_g = FAIL;
hid_t H5T_NATIVE_INT8_g = FAIL;
hid_t H5T_NATIVE_UINT8_g = FAIL;
hid_t H5T_NATIVE_INT_LEAST8_g = FAIL;
hid_t H5T_NATIVE_UINT_LEAST8_g = FAIL;
hid_t H5T_NATIVE_INT_FAST8_g = FAIL;
hid_t H5T_NATIVE_UINT_FAST8_g = FAIL;
hid_t H5T_NATIVE_INT16_g = FAIL;
hid_t H5T_NATIVE_UINT16_g = FAIL;
hid_t H5T_NATIVE_INT_LEAST16_g = FAIL;
hid_t H5T_NATIVE_UINT_LEAST16_g = FAIL;
hid_t H5T_NATIVE_INT_FAST16_g = FAIL;
hid_t H5T_NATIVE_UINT_FAST16_g = FAIL;
hid_t H5T_NATIVE_INT32_g = FAIL;
hid_t H5T_NATIVE_UINT32_g = FAIL;
hid_t H5T_NATIVE_INT_LEAST32_g = FAIL;
hid_t H5T_NATIVE_UINT_LEAST32_g = FAIL;
hid_t H5T_NATIVE_INT_FAST32_g = FAIL;
hid_t H5T_NATIVE_UINT_FAST32_g = FAIL;
hid_t H5T_NATIVE_INT64_g = FAIL;
hid_t H5T_NATIVE_UINT64_g = FAIL;
hid_t H5T_NATIVE_INT_LEAST64_g = FAIL;
hid_t H5T_NATIVE_UINT_LEAST64_g = FAIL;
hid_t H5T_NATIVE_INT_FAST64_g = FAIL;
hid_t H5T_NATIVE_UINT_FAST64_g = FAIL;
/*
* Alignment constraints for native types. These are initialized at run time
* in H5Tinit.c. These alignments are mainly for offsets in HDF5 compound
* datatype or C structures, which are different from the alignments for memory
* address below this group of variables.
*/
size_t H5T_NATIVE_SCHAR_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_UCHAR_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_SHORT_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_USHORT_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_INT_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_LONG_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_ULONG_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_LLONG_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_ULLONG_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_FLOAT_COMP_ALIGN_g = 0;
size_t H5T_NATIVE_DOUBLE_COMP_ALIGN_g = 0;
#if H5_SIZEOF_LONG_DOUBLE !=0
size_t H5T_NATIVE_LDOUBLE_COMP_ALIGN_g = 0;
#endif
size_t H5T_POINTER_COMP_ALIGN_g = 0;
size_t H5T_HVL_COMP_ALIGN_g = 0;
size_t H5T_HOBJREF_COMP_ALIGN_g = 0;
size_t H5T_HDSETREGREF_COMP_ALIGN_g = 0;
/*
* Alignment constraints for native types. These are initialized at run time
* in H5Tinit.c
*/
size_t H5T_NATIVE_SCHAR_ALIGN_g = 0;
size_t H5T_NATIVE_UCHAR_ALIGN_g = 0;
size_t H5T_NATIVE_SHORT_ALIGN_g = 0;
size_t H5T_NATIVE_USHORT_ALIGN_g = 0;
size_t H5T_NATIVE_INT_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_ALIGN_g = 0;
size_t H5T_NATIVE_LONG_ALIGN_g = 0;
size_t H5T_NATIVE_ULONG_ALIGN_g = 0;
size_t H5T_NATIVE_LLONG_ALIGN_g = 0;
size_t H5T_NATIVE_ULLONG_ALIGN_g = 0;
size_t H5T_NATIVE_FLOAT_ALIGN_g = 0;
size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0;
#if H5_SIZEOF_LONG_DOUBLE !=0
size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0;
#endif
/*
* Alignment constraints for C9x types. These are initialized at run time in
* H5Tinit.c if the types are provided by the system. Otherwise we set their
* values to 0 here (no alignment calculated).
*/
size_t H5T_NATIVE_INT8_ALIGN_g = 0;
size_t H5T_NATIVE_UINT8_ALIGN_g = 0;
size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_LEAST8_ALIGN_g = 0;
size_t H5T_NATIVE_INT_FAST8_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_FAST8_ALIGN_g = 0;
size_t H5T_NATIVE_INT16_ALIGN_g = 0;
size_t H5T_NATIVE_UINT16_ALIGN_g = 0;
size_t H5T_NATIVE_INT_LEAST16_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_LEAST16_ALIGN_g = 0;
size_t H5T_NATIVE_INT_FAST16_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_FAST16_ALIGN_g = 0;
size_t H5T_NATIVE_INT32_ALIGN_g = 0;
size_t H5T_NATIVE_UINT32_ALIGN_g = 0;
size_t H5T_NATIVE_INT_LEAST32_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_LEAST32_ALIGN_g = 0;
size_t H5T_NATIVE_INT_FAST32_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_FAST32_ALIGN_g = 0;
size_t H5T_NATIVE_INT64_ALIGN_g = 0;
size_t H5T_NATIVE_UINT64_ALIGN_g = 0;
size_t H5T_NATIVE_INT_LEAST64_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g = 0;
size_t H5T_NATIVE_INT_FAST64_ALIGN_g = 0;
size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0;
/* Useful floating-point values for conversion routines */
/* (+/- Inf for all floating-point types) */
float H5T_NATIVE_FLOAT_POS_INF_g = 0.0f;
float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0f;
double H5T_NATIVE_DOUBLE_POS_INF_g = (double)0.0f;
double H5T_NATIVE_DOUBLE_NEG_INF_g = (double)0.0f;
/* Declare the free list for H5T_t's and H5T_shared_t's */
H5FL_DEFINE(H5T_t);
H5FL_DEFINE(H5T_shared_t);
/*******************/
/* Local Variables */
/*******************/
/*
* The path database. Each path has a source and destination data type pair
* which is used as the key by which the `entries' array is sorted.
*/
static struct {
int npaths; /*number of paths defined */
size_t apaths; /*number of paths allocated */
H5T_path_t **path; /*sorted array of path pointers */
int nsoft; /*number of soft conversions defined */
size_t asoft; /*number of soft conversions allocated */
H5T_soft_t *soft; /*unsorted array of soft conversions */
} H5T_g;
/* Declare the free list for H5T_path_t's */
H5FL_DEFINE_STATIC(H5T_path_t);
/* Datatype ID class */
static const H5I_class_t H5I_DATATYPE_CLS[1] = {{
H5I_DATATYPE, /* ID class value */
0, /* Class flags */
8, /* # of reserved IDs for class */
(H5I_free_t)H5T_close /* Callback routine for closing objects of this class */
}};
/* Flag indicating "top" of interface has been initialized */
static hbool_t H5T_top_package_initialize_s = FALSE;
/*-------------------------------------------------------------------------
* Function: H5T_init
*
* Purpose: Initialize the interface from some other package.
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Robb Matzke
* Wednesday, December 16, 1998
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_init(void)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* FUNC_ENTER() does all the work */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_init() */
/*-------------------------------------------------------------------------
* Function: H5T__init_inf
*
* Purpose: Initialize the +/- Infinity floating-poing values for type
* conversion.
*
* Return: Success: non-negative
* Failure: negative
*
* Programmer: Quincey Koziol
* Saturday, November 22, 2003
*
*-------------------------------------------------------------------------
*/
static herr_t
H5T__init_inf(void)
{
H5T_t *dst_p; /* Datatype type operate on */
H5T_atomic_t *dst; /* Datatype's atomic info */
uint8_t *d; /* Pointer to value to set */
size_t half_size; /* Half the type size */
size_t u; /* Local index value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Get the float datatype */
if(NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
dst = &dst_p->shared->u.atomic;
/* Check that we can re-order the bytes correctly */
if(H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g)
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order")
/* +Inf */
d = (uint8_t *)&H5T_NATIVE_FLOAT_POS_INF_g;
H5T__bit_set(d, dst->u.f.sign, (size_t)1, FALSE);
H5T__bit_set(d, dst->u.f.epos, dst->u.f.esize, TRUE);
H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, FALSE);
/* Swap the bytes if the machine architecture is big-endian */
if (H5T_ORDER_BE == H5T_native_order_g) {
half_size = dst_p->shared->size / 2;
for(u = 0; u < half_size; u++) {
uint8_t tmp = d[dst_p->shared->size - (u + 1)];
d[dst_p->shared->size - (u + 1)] = d[u];
d[u] = tmp;
} /* end for */
} /* end if */
/* -Inf */
|