summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-09-10 19:10:41 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-09-10 19:10:41 (GMT)
commitc465e18a68f2a77550d93366a5b6c8fac2e24502 (patch)
treebd3649f75f1507040b68d8e15c63333600816360 /src/H5detect.c
parent068620ea815d8590982069cfb6374e07d3c8e1e6 (diff)
downloadhdf5-c465e18a68f2a77550d93366a5b6c8fac2e24502.zip
hdf5-c465e18a68f2a77550d93366a5b6c8fac2e24502.tar.gz
hdf5-c465e18a68f2a77550d93366a5b6c8fac2e24502.tar.bz2
[svn-r15609] Description:
Omnibus compiler warning cleanup & some reformatting also. Tested on: Mac OS X/32 10.5.4 (amazon) Too minor to require h5committest
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c137
1 files changed, 100 insertions, 37 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index 35cca1a..e29157d 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -202,34 +202,36 @@ precision (detected_t *d)
int _i, _j; \
unsigned char *_x; \
\
- memset (&INFO, 0, sizeof(INFO)); \
+ HDmemset(&INFO, 0, sizeof(INFO)); \
INFO.varname = #VAR; \
INFO.size = sizeof(TYPE); \
\
- if(sizeof(TYPE)!=1) { \
- for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
- for (_i=0,_x=(unsigned char *)&_v; _i<(signed)sizeof(TYPE); _i++) { \
- _j = (*_x++)-1; \
- assert (_j<(signed)sizeof(TYPE)); \
+ if(sizeof(TYPE) != 1) { \
+ for(_i = sizeof(TYPE), _v = 0; _i > 0; --_i) \
+ _v = (_v << 8) + _i; \
+ for(_i = 0, _x = (unsigned char *)&_v; _i < (signed)sizeof(TYPE); _i++) { \
+ _j = (*_x++) - 1; \
+ assert(_j < (signed)sizeof(TYPE)); \
INFO.perm[_i] = _j; \
- } \
+ } /* end for */ \
} else { /*Not able to detect order if type size is 1 byte. Use native int \
*instead. No effect on data, just make it look correct. */ \
- for (_i=sizeof(int),_int_v=0; _i>0; --_i) _int_v = (_int_v<<8) + _i; \
- for (_i=0,_x=(unsigned char *)&_int_v; _i<(signed)sizeof(int); _i++) { \
+ for(_i = sizeof(int), _int_v = 0; _i > 0; --_i) \
+ _int_v = (_int_v << 8) + _i; \
+ for(_i = 0, _x = (unsigned char *)&_int_v; _i < (signed)sizeof(int); _i++) { \
_j = (*_x++)-1; \
- assert (_j<(signed)sizeof(int)); \
+ assert(_j < (signed)sizeof(int)); \
INFO.perm[_i] = _j; \
- } \
- } \
+ } /* end for */ \
+ } /* end else */ \
\
- INFO.sign = ('U'!=*(#VAR)); \
+ INFO.sign = ('U' != *(#VAR)); \
precision (&(INFO)); \
ALIGNMENT(TYPE, INFO); \
- if(!strcmp(INFO.varname, "SCHAR") || !strcmp(INFO.varname, "SHORT") || \
- !strcmp(INFO.varname, "INT") || !strcmp(INFO.varname, "LONG") || \
- !strcmp(INFO.varname, "LLONG")) { \
- COMP_ALIGNMENT(TYPE,INFO.comp_align); \
+ if(!HDstrcmp(INFO.varname, "SCHAR") || !HDstrcmp(INFO.varname, "SHORT") || \
+ !HDstrcmp(INFO.varname, "INT") || !HDstrcmp(INFO.varname, "LONG") || \
+ !HDstrcmp(INFO.varname, "LLONG")) { \
+ COMP_ALIGNMENT(TYPE, INFO.comp_align); \
} \
}
@@ -358,16 +360,16 @@ precision (detected_t *d)
#if defined(H5_HAVE_LONGJMP) && defined(H5_HAVE_SIGNAL)
#define ALIGNMENT(TYPE,INFO) { \
- char *volatile _buf=NULL; \
- volatile TYPE _val=1; \
+ char *volatile _buf = NULL; \
+ volatile TYPE _val = 1; \
volatile TYPE _val2; \
- volatile size_t _ano=0; \
+ volatile size_t _ano = 0; \
void (*_handler)(int) = signal(SIGBUS, sigbus_handler); \
void (*_handler2)(int) = signal(SIGSEGV, sigsegv_handler); \
\
- _buf = (char*)malloc(sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \
- if (setjmp(jbuf_g)) _ano++; \
- if (_ano<NELMTS(align_g)) { \
+ _buf = (char*)malloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \
+ if(setjmp(jbuf_g)) _ano++; \
+ if(_ano < NELMTS(align_g)) { \
*((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \
_val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/ \
/* Cray Check: This section helps detect alignment on Cray's */ \
@@ -522,27 +524,88 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/* Include files */
printf("\
+/****************/\n\
+/* Module Setup */\n\
+/****************/\n\
+\n\
#define H5T_PACKAGE /*suppress error about including H5Tpkg.h*/\n\
\n\
-#include \"H5private.h\"\n\
-#include \"H5Iprivate.h\"\n\
-#include \"H5Eprivate.h\"\n\
-#include \"H5FLprivate.h\"\n\
-#include \"H5Tpkg.h\"\n\
\n\
+/***********/\n\
+/* Headers */\n\
+/***********/\n\
+#include \"H5private.h\" /* Generic Functions */\n\
+#include \"H5Eprivate.h\" /* Error handling */\n\
+#include \"H5FLprivate.h\" /* Free Lists */\n\
+#include \"H5Iprivate.h\" /* IDs */\n\
+#include \"H5Tpkg.h\" /* Datatypes */\n\
+\n\
+\n\
+/****************/\n\
+/* Local Macros */\n\
+/****************/\n\
+\n\
+\n\
+/******************/\n\
+/* Local Typedefs */\n\
+/******************/\n\
+\n\
+\n\
+/********************/\n\
+/* Package Typedefs */\n\
+/********************/\n\
+\n\
+\n\
+/********************/\n\
+/* Local Prototypes */\n\
+/********************/\n\
+\n\
+\n\
+/********************/\n\
+/* Public Variables */\n\
+/********************/\n\
+\n\n\
+/*****************************/\n\
+/* Library Private Variables */\n\
+/*****************************/\n\
+\n\n\
+/*********************/\n\
+/* Package Variables */\n\
+/*********************/\n\
+\n\
+\n");
+ printf("\n\
+/*******************/\n\
+/* Local Variables */\n\
+/*******************/\n\
\n");
/* The interface initialization function */
printf("\n\
+ \n\
+/*-------------------------------------------------------------------------\n\
+ * Function: H5TN_init_interface\n\
+ *\n\
+ * Purpose: Initialize pre-defined native datatypes from code generated\n\
+ * during the library configuration by H5detect.\n\
+ *\n\
+ * Return: Success: non-negative\n\
+ * Failure: negative\n\
+ *\n\
+ * Programmer: Robb Matzke\n\
+ * Wednesday, December 16, 1998\n\
+ *\n\
+ *-------------------------------------------------------------------------\n\
+ */\n\
herr_t\n\
H5TN_init_interface(void)\n\
{\n\
H5T_t *dt = NULL;\n\
herr_t ret_value = SUCCEED;\n\
\n\
- FUNC_ENTER_NOAPI(H5TN_init_interface, FAIL);\n");
+ FUNC_ENTER_NOAPI(H5TN_init_interface, FAIL)\n");
- for (i = 0; i < nd; i++) {
+ for(i = 0; i < nd; i++) {
/* The native endianess of this machine */
/* The INFO.perm now contains `-1' for bytes that aren't used and
* are always zero. This happens on the Cray for `short' where
@@ -568,7 +631,7 @@ H5TN_init_interface(void)\n\
/* The part common to fixed and floating types */
printf("\
if(NULL == (dt = H5T_alloc()))\n\
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\"memory allocation failed\")\n\
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\
dt->shared->state = H5T_STATE_IMMUTABLE;\n\
dt->shared->type = H5T_%s;\n\
dt->shared->size = %d;\n",
@@ -621,8 +684,8 @@ H5TN_init_interface(void)\n\
/* Atomize the type */
printf("\
- if ((H5T_NATIVE_%s_g = H5I_register (H5I_DATATYPE, dt, FALSE))<0)\n\
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,\"can't initialize type system (atom registration failure\");\n",
+ if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\")\n",
d[i].varname);
printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n",
d[i].varname, (unsigned long)(d[i].align));
@@ -656,16 +719,16 @@ H5TN_init_interface(void)\n\
printf("\
\n\
done:\n\
- if(ret_value<0) {\n\
+ if(ret_value < 0) {\n\
if(dt != NULL) {\n\
if(dt->shared != NULL)\n\
H5FL_FREE(H5T_shared_t, dt->shared);\n\
H5FL_FREE(H5T_t, dt);\n\
} /* end if */\n\
- }\n\
+ } /* end if */\n\
\n\
- FUNC_LEAVE_NOAPI(ret_value);\n}\n");
-}
+ FUNC_LEAVE_NOAPI(ret_value);\n} /* end H5TN_init_interface() */\n");
+} /* end print_results() */
/*-------------------------------------------------------------------------