summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-01-31 15:28:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-01-31 15:28:40 (GMT)
commit6cf56ca817ccba7b8c956cffee208ec624921b12 (patch)
treee30ab953bdfc4d332ea6c0af192f8ae4893931b3 /src/H5detect.c
parenteb4cc0556c390deaa9f21710d95f5690932221d9 (diff)
downloadhdf5-6cf56ca817ccba7b8c956cffee208ec624921b12.zip
hdf5-6cf56ca817ccba7b8c956cffee208ec624921b12.tar.gz
hdf5-6cf56ca817ccba7b8c956cffee208ec624921b12.tar.bz2
[svn-r8136] Purpose:
Optimization Description: Speed up various parts of the library by setting a global variable for the endianness of the machine at library startup and use that variable instead of repeatedly querying the endianness of the native int datatype. Platforms tested: IBM p690 (copper) too minor to require h5committest
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index 670aed1..f3a5588 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -479,7 +479,7 @@ sigbus_handler(int UNUSED signo)
static void
print_results(int nd, detected_t *d, int na, malign_t *misc_align)
{
-
+ int byte_order;
int i, j;
/* Include files */
@@ -523,6 +523,18 @@ H5TN_init_interface(void)\n\
\n\
FUNC_ENTER_NOAPI(H5TN_init_interface, FAIL);\n");
+ /* The native endianess of this machine */
+ /* (Use the byte-order of a reasonably large type) */
+ for (i = 0; i < nd; i++)
+ if(d[i].size>1) {
+ byte_order=d[i].perm[0];
+ break;
+ } /* end if */
+ printf("\n\
+ /* Set the native order for this machine */\n\
+ H5T_native_order_g = H5T_ORDER_%s;\n",
+ byte_order ? "BE" : "LE"); /*byte order */
+
for (i = 0; i < nd; i++) {
/* Print a comment to describe this section of definitions. */
@@ -548,6 +560,7 @@ H5TN_init_interface(void)\n\
d[i].perm[0] ? "BE" : "LE", /*byte order */
d[i].offset, /*offset */
d[i].precision); /*precision */
+ assert(d[i].size<2 || (d[i].perm[0]>0)==(byte_order>0)); /* Double-check that byte-order doesn't change */
if (0 == d[i].msize) {
/* The part unique to fixed point types */