summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-04-28 20:56:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-04-28 20:56:55 (GMT)
commit83175cb19103db8186cf7ad65bbbea1ef88e0366 (patch)
tree6acbc46a7fdf33afead2582fe11b59a5a04b761f /src
parent2bf52ee03ef0a1f8663d40b1ac0f8fe2d4934720 (diff)
downloadhdf5-83175cb19103db8186cf7ad65bbbea1ef88e0366.zip
hdf5-83175cb19103db8186cf7ad65bbbea1ef88e0366.tar.gz
hdf5-83175cb19103db8186cf7ad65bbbea1ef88e0366.tar.bz2
[svn-r18660] Description:
Tweak H5detect to be even more careful about its actions, to allow gcc 4.5 to use '-O3'. Also, minor code cleanups in H5Tfloat.c Tested on: FreeBSD/64 6.3 (liberty) w/gcc 4.5 & production mode (h5committest not necessary/appropriate)
Diffstat (limited to 'src')
-rw-r--r--src/H5Tfloat.c195
-rw-r--r--src/H5detect.c32
2 files changed, 105 insertions, 122 deletions
diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c
index 73ccf30..88d13fd 100644
--- a/src/H5Tfloat.c
+++ b/src/H5Tfloat.c
@@ -70,40 +70,41 @@ H5T_init_float_interface(void)
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works with derived datatypes.
*-------------------------------------------------------------------------
*/
herr_t
-H5Tget_fields(hid_t type_id, size_t *spos/*out*/,
- size_t *epos/*out*/, size_t *esize/*out*/,
- size_t *mpos/*out*/, size_t *msize/*out*/)
+H5Tget_fields(hid_t type_id, size_t *spos/*out*/, size_t *epos/*out*/,
+size_t *esize/*out*/, size_t *mpos/*out*/, size_t *msize/*out*/)
{
- H5T_t *dt = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tget_fields, FAIL)
H5TRACE6("e", "ixxxxx", type_id, spos, epos, esize, mpos, msize);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- while (dt->shared->parent)
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class")
/* Get values */
- if (spos) *spos = dt->shared->u.atomic.u.f.sign;
- if (epos) *epos = dt->shared->u.atomic.u.f.epos;
- if (esize) *esize = dt->shared->u.atomic.u.f.esize;
- if (mpos) *mpos = dt->shared->u.atomic.u.f.mpos;
- if (msize) *msize = dt->shared->u.atomic.u.f.msize;
+ if(spos)
+ *spos = dt->shared->u.atomic.u.f.sign;
+ if(epos)
+ *epos = dt->shared->u.atomic.u.f.epos;
+ if(esize)
+ *esize = dt->shared->u.atomic.u.f.esize;
+ if(mpos)
+ *mpos = dt->shared->u.atomic.u.f.mpos;
+ if(msize)
+ *msize = dt->shared->u.atomic.u.f.msize;
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tget_fields() */
/*-------------------------------------------------------------------------
@@ -122,45 +123,40 @@ done:
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works for derived datatypes.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
- size_t mpos, size_t msize)
+ size_t mpos, size_t msize)
{
- H5T_t *dt = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_fields, FAIL)
H5TRACE6("e", "izzzzz", type_id, spos, epos, esize, mpos, msize);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if (H5T_STATE_TRANSIENT!=dt->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only")
- while (dt->shared->parent)
+ if(H5T_STATE_TRANSIENT != dt->shared->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only")
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class")
- if (epos + esize > dt->shared->u.atomic.prec)
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class")
+ if(epos + esize > dt->shared->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid")
- if (mpos + msize > dt->shared->u.atomic.prec)
+ if(mpos + msize > dt->shared->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid")
- if (spos >= dt->shared->u.atomic.prec)
+ if(spos >= dt->shared->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid")
/* Check for overlap */
- if (spos >= epos && spos < epos + esize)
+ if(spos >= epos && spos < epos + esize)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field")
- if (spos >= mpos && spos < mpos + msize)
+ if(spos >= mpos && spos < mpos + msize)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field")
- if ((mpos < epos && mpos + msize > epos) ||
- (epos < mpos && epos + esize > mpos))
+ if((mpos < epos && mpos + msize > epos) || (epos < mpos && epos + esize > mpos))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap")
/* Commit */
@@ -172,7 +168,7 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tset_fields() */
/*-------------------------------------------------------------------------
@@ -187,34 +183,31 @@ done:
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works with derived datatypes.
*-------------------------------------------------------------------------
*/
size_t
H5Tget_ebias(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t ret_value;
+ H5T_t *dt; /* Datatype */
+ size_t ret_value; /* Return value */
FUNC_ENTER_API(H5Tget_ebias, 0)
H5TRACE1("z", "i", type_id);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype")
- while (dt->shared->parent)
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, 0, "operation not defined for datatype class")
/* bias */
- H5_ASSIGN_OVERFLOW(ret_value,dt->shared->u.atomic.u.f.ebias,uint64_t,size_t);
+ H5_ASSIGN_OVERFLOW(ret_value, dt->shared->u.atomic.u.f.ebias, uint64_t, size_t);
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tget_ebias() */
/*-------------------------------------------------------------------------
@@ -236,28 +229,28 @@ done:
herr_t
H5Tset_ebias(hid_t type_id, size_t ebias)
{
- H5T_t *dt = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_ebias, FAIL)
H5TRACE2("e", "iz", type_id, ebias);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if (H5T_STATE_TRANSIENT!=dt->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only")
- while (dt->shared->parent)
+ if(H5T_STATE_TRANSIENT != dt->shared->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only")
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class")
/* Commit */
dt->shared->u.atomic.u.f.ebias = ebias;
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tset_ebias() */
/*-------------------------------------------------------------------------
@@ -273,35 +266,31 @@ done:
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works with derived datatypes.
- *
*-------------------------------------------------------------------------
*/
H5T_norm_t
H5Tget_norm(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_norm_t ret_value;
+ H5T_t *dt; /* Datatype */
+ H5T_norm_t ret_value; /* Return value */
FUNC_ENTER_API(H5Tget_norm, H5T_NORM_ERROR)
H5TRACE1("Tn", "i", type_id);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a datatype")
- while (dt->shared->parent)
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_NORM_ERROR, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_NORM_ERROR, "operation not defined for datatype class")
/* norm */
ret_value = dt->shared->u.atomic.u.f.norm;
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tget_norm() */
/*-------------------------------------------------------------------------
@@ -315,39 +304,35 @@ done:
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works for derived datatypes.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_norm(hid_t type_id, H5T_norm_t norm)
{
- H5T_t *dt = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_norm, FAIL)
H5TRACE2("e", "iTn", type_id, norm);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if (H5T_STATE_TRANSIENT!=dt->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only")
- if (norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE)
+ if(H5T_STATE_TRANSIENT != dt->shared->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only")
+ if(norm < H5T_NORM_IMPLIED || norm > H5T_NORM_NONE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization")
- while (dt->shared->parent)
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class")
/* Commit */
dt->shared->u.atomic.u.f.norm = norm;
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tset_norm() */
/*-------------------------------------------------------------------------
@@ -365,35 +350,31 @@ done:
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works for derived datatypes.
- *
*-------------------------------------------------------------------------
*/
H5T_pad_t
H5Tget_inpad(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_pad_t ret_value;
+ H5T_t *dt; /* Datatype */
+ H5T_pad_t ret_value; /* Return value */
FUNC_ENTER_API(H5Tget_inpad, H5T_PAD_ERROR)
H5TRACE1("Tp", "i", type_id);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a datatype")
- while (dt->shared->parent)
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_PAD_ERROR, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_PAD_ERROR, "operation not defined for datatype class")
/* pad */
ret_value = dt->shared->u.atomic.u.f.pad;
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tget_inpad() */
/*-------------------------------------------------------------------------
@@ -409,37 +390,33 @@ done:
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
- * Modifications:
- * Robb Matzke, 22 Dec 1998
- * Also works for derived datatypes.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
{
- H5T_t *dt = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_inpad, FAIL)
H5TRACE2("e", "iTp", type_id, pad);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if (H5T_STATE_TRANSIENT!=dt->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "datatype is read-only")
- if (pad < H5T_PAD_ZERO || pad >= H5T_NPAD)
+ if(H5T_STATE_TRANSIENT != dt->shared->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only")
+ if(pad < H5T_PAD_ZERO || pad >= H5T_NPAD)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type")
- while (dt->shared->parent)
+ while(dt->shared->parent)
dt = dt->shared->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->shared->type)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for datatype class")
+ if(H5T_FLOAT != dt->shared->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "operation not defined for datatype class")
/* Commit */
dt->shared->u.atomic.u.f.pad = pad;
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Tset_inpad() */
diff --git a/src/H5detect.c b/src/H5detect.c
index 1cfce96..5bae2bb 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -288,33 +288,39 @@ precision (detected_t *d)
*-------------------------------------------------------------------------
*/
#define DETECT_F(TYPE,VAR,INFO) { \
- volatile TYPE _v1, _v2, _v3; \
- int _i, _j, _first=(-1), _last=(-1); \
+ volatile TYPE _v1, _v2, _v3; \
+ unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \
+ int _i, _j, _first = (-1), _last = (-1); \
char *_mesg; \
\
- memset (&INFO, 0, sizeof(INFO)); \
+ memset(&INFO, 0, sizeof(INFO)); \
INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
\
/* Completely initialize temporary variables, in case the bits used in */ \
/* the type take less space than the number of bits used to store the type */ \
- memset(&_v3,0,sizeof(TYPE)); \
- memset(&_v2,0,sizeof(TYPE)); \
- memset(&_v1,0,sizeof(TYPE)); \
+ memset(&_v3, 0, sizeof(TYPE)); \
+ memset(&_v2, 0, sizeof(TYPE)); \
+ memset(&_v1, 0, sizeof(TYPE)); \
\
/* Byte Order */ \
- for (_i=0,_v1=0.0,_v2=1.0; _i<(signed)sizeof(TYPE); _i++) { \
- _v3 = _v1; _v1 += _v2; _v2 /= 256.0; \
- _j=byte_cmp(sizeof(TYPE), &_v3, &_v1); \
- if(_j>=0) { \
- if (0==_i || INFO.perm[_i-1]!=_j) { \
+ for(_i = 0, _v1 = 0.0, _v2 = 1.0; _i < (int)sizeof(TYPE); _i++) { \
+ _v3 = _v1; \
+ _v1 += _v2; \
+ _v2 /= 256.0; \
+ memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
+ memcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \
+ _j = byte_cmp(sizeof(TYPE), &_buf3, &_buf1); \
+ if(_j >= 0) { \
+ if(0 == _i || INFO.perm[_i - 1] != _j) { \
INFO.perm[_i] = _j; \
_last = _i; \
- if (_first<0) _first = _i; \
+ if(_first < 0) \
+ _first = _i; \
} \
} \
} \
- fix_order (sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \
+ fix_order(sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \
\
if(!strcmp(_mesg, "VAX")) \
INFO.is_vax = TRUE; \