summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2019-10-03 22:34:05 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2019-10-03 22:34:05 (GMT)
commit743c9358d146d3d28e6cb023166763f0846442b9 (patch)
tree0c56d6996590ff2c6433b4f36461d8c9641b2f9f
parent82f647534c309ff97e4827fb95949954aeed4a26 (diff)
downloadhdf5-743c9358d146d3d28e6cb023166763f0846442b9.zip
hdf5-743c9358d146d3d28e6cb023166763f0846442b9.tar.gz
hdf5-743c9358d146d3d28e6cb023166763f0846442b9.tar.bz2
Introduce PRI*HADDR and PRI*HSIZE for printing haddr_t and hsize_t.
-rw-r--r--hl/tools/h5watch/h5watch.c2
-rw-r--r--src/H5public.h124
-rw-r--r--tools/lib/h5tools_dump.c6
-rw-r--r--tools/src/h5dump/h5dump_ddl.c6
-rw-r--r--tools/src/h5dump/h5dump_xml.c12
-rw-r--r--tools/src/h5ls/h5ls.c6
6 files changed, 83 insertions, 73 deletions
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index d1f4e32..f02a14a 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -205,7 +205,7 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
info.dset_format = "DSET-%s ";
info.dset_hidefileno = 0;
- info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
+ info.obj_format = "-%lu:%" PRIuHADDR;
info.obj_hidefileno = 0;
info.dset_blockformat_pre = "%sBlk%lu: ";
diff --git a/src/H5public.h b/src/H5public.h
index c247e57..4dc617f 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -174,42 +174,82 @@ typedef long long ssize_t;
#endif
#endif
+/* int64_t type is used for creation order field for links. It may be
+ * defined in Posix.1g, otherwise it is defined here.
+ */
+#if H5_SIZEOF_INT64_T>=8
+#elif H5_SIZEOF_INT>=8
+ typedef int int64_t;
+# undef H5_SIZEOF_INT64_T
+# define H5_SIZEOF_INT64_T H5_SIZEOF_INT
+#elif H5_SIZEOF_LONG>=8
+ typedef long int64_t;
+# undef H5_SIZEOF_INT64_T
+# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG
+#elif H5_SIZEOF_LONG_LONG>=8
+ typedef long long int64_t;
+# undef H5_SIZEOF_INT64_T
+# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG
+#else
+# error "nothing appropriate for int64_t"
+#endif
+
+/* uint64_t type is used for fields for H5O_info_t. It may be
+ * defined in Posix.1g, otherwise it is defined here.
+ */
+#if H5_SIZEOF_UINT64_T>=8
+#elif H5_SIZEOF_INT>=8
+ typedef unsigned uint64_t;
+# undef H5_SIZEOF_UINT64_T
+# define H5_SIZEOF_UINT64_T H5_SIZEOF_INT
+#elif H5_SIZEOF_LONG>=8
+ typedef unsigned long uint64_t;
+# undef H5_SIZEOF_UINT64_T
+# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG
+#elif H5_SIZEOF_LONG_LONG>=8
+ typedef unsigned long long uint64_t;
+# undef H5_SIZEOF_UINT64_T
+# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG
+#else
+# error "nothing appropriate for uint64_t"
+#endif
+
/*
* The sizes of file objects have their own types defined here, use a 64-bit
* type.
*/
-#if H5_SIZEOF_LONG_LONG >= 8
-H5_GCC_DIAG_OFF(long-long)
-typedef unsigned long long hsize_t;
-typedef signed long long hssize_t;
-H5_GCC_DIAG_ON(long-long)
-# define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG
-# define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG
-#else
-# error "nothing appropriate for hsize_t"
-#endif
-#define HSIZE_UNDEF ((hsize_t)(hssize_t)(-1))
+typedef uint64_t hsize_t;
+typedef int64_t hssize_t;
+#define PRIXHSIZE PRIX64
+#define PRIdHSIZE PRId64
+#define PRIiHSIZE PRIi64
+#define PRIoHSIZE PRIo64
+#define PRIuHSIZE PRIu64
+#define PRIxHSIZE PRIx64
+#define H5_SIZEOF_HSIZE_T H5_SIZEOF_UINT64_T
+#define H5_SIZEOF_HSSIZE_T H5_SIZEOF_INT64_T
+#define HSIZE_UNDEF UINT64_MAX
/*
* File addresses have their own types.
*/
#if H5_SIZEOF_INT >= 8
typedef unsigned haddr_t;
-# define HADDR_UNDEF ((haddr_t)(-1))
+# define HADDR_UNDEF UINT_MAX
# define H5_SIZEOF_HADDR_T H5_SIZEOF_INT
# ifdef H5_HAVE_PARALLEL
# define HADDR_AS_MPI_TYPE MPI_UNSIGNED
# endif /* H5_HAVE_PARALLEL */
#elif H5_SIZEOF_LONG >= 8
typedef unsigned long haddr_t;
-# define HADDR_UNDEF ((haddr_t)(long)(-1))
+# define HADDR_UNDEF ULONG_MAX
# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG
# ifdef H5_HAVE_PARALLEL
# define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG
# endif /* H5_HAVE_PARALLEL */
#elif H5_SIZEOF_LONG_LONG >= 8
typedef unsigned long long haddr_t;
-# define HADDR_UNDEF ((haddr_t)(long long)(-1))
+# define HADDR_UNDEF ULLONG_MAX
# define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG
# ifdef H5_HAVE_PARALLEL
# define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT
@@ -218,14 +258,24 @@ H5_GCC_DIAG_ON(long-long)
# error "nothing appropriate for haddr_t"
#endif
#if H5_SIZEOF_HADDR_T == H5_SIZEOF_INT
-# define H5_PRINTF_HADDR_FMT "%u"
+# define PRIXHADDR "X"
+# define PRIoHADDR "o"
+# define PRIuHADDR "u"
+# define PRIxHADDR "x"
#elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG
-# define H5_PRINTF_HADDR_FMT "%lu"
+# define PRIXHADDR "lX"
+# define PRIoHADDR "lo"
+# define PRIuHADDR "lu"
+# define PRIxHADDR "lx"
#elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG_LONG
-# define H5_PRINTF_HADDR_FMT "%" H5_PRINTF_LL_WIDTH "u"
+# define PRIXHADDR H5_PRINTF_LL_WIDTH "X"
+# define PRIoHADDR H5_PRINTF_LL_WIDTH "o"
+# define PRIuHADDR H5_PRINTF_LL_WIDTH "u"
+# define PRIxHADDR H5_PRINTF_LL_WIDTH "x"
#else
# error "nothing appropriate for H5_PRINTF_HADDR_FMT"
#endif
+#define H5_PRINTF_HADDR_FMT "%" PRIuHADDR
#define HADDR_MAX (HADDR_UNDEF-1)
/* uint32_t type is used for creation order field for messages. It may be
@@ -248,46 +298,6 @@ H5_GCC_DIAG_ON(long-long)
# error "nothing appropriate for uint32_t"
#endif
-/* int64_t type is used for creation order field for links. It may be
- * defined in Posix.1g, otherwise it is defined here.
- */
-#if H5_SIZEOF_INT64_T>=8
-#elif H5_SIZEOF_INT>=8
- typedef int int64_t;
-# undef H5_SIZEOF_INT64_T
-# define H5_SIZEOF_INT64_T H5_SIZEOF_INT
-#elif H5_SIZEOF_LONG>=8
- typedef long int64_t;
-# undef H5_SIZEOF_INT64_T
-# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG
-#elif H5_SIZEOF_LONG_LONG>=8
- typedef long long int64_t;
-# undef H5_SIZEOF_INT64_T
-# define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG
-#else
-# error "nothing appropriate for int64_t"
-#endif
-
-/* uint64_t type is used for fields for H5O_info_t. It may be
- * defined in Posix.1g, otherwise it is defined here.
- */
-#if H5_SIZEOF_UINT64_T>=8
-#elif H5_SIZEOF_INT>=8
- typedef unsigned uint64_t;
-# undef H5_SIZEOF_UINT64_T
-# define H5_SIZEOF_UINT64_T H5_SIZEOF_INT
-#elif H5_SIZEOF_LONG>=8
- typedef unsigned long uint64_t;
-# undef H5_SIZEOF_UINT64_T
-# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG
-#elif H5_SIZEOF_LONG_LONG>=8
- typedef unsigned long long uint64_t;
-# undef H5_SIZEOF_UINT64_T
-# define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG
-#else
-# error "nothing appropriate for uint64_t"
-#endif
-
/* Common iteration orders */
typedef enum {
H5_ITER_UNKNOWN = -1, /* Unknown order */
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 69cecb0..f427c35 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -81,7 +81,7 @@ h5tool_format_t h5tools_dataformat = {
1, /*skip_first */
1, /*obj_hidefileno */
- " "H5_PRINTF_HADDR_FMT, /*obj_format */
+ " %" PRIuHADDR, /*obj_format */
1, /*dset_hidefileno */
"DATASET %s ", /*dset_format */
@@ -1910,7 +1910,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
if(obj) {
if(!obj->recorded)
- h5tools_str_append(buffer,"\"/#"H5_PRINTF_HADDR_FMT"\"", obj->objno);
+ h5tools_str_append(buffer,"\"/#%" PRIuHADDR"\"", obj->objno);
else
h5tools_str_append(buffer, "\"%s\"", obj->objname);
}
@@ -3091,7 +3091,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
h5tools_str_reset(&buffer);
ioffset = H5Dget_offset(obj_id);
- h5tools_str_append(&buffer, "OFFSET "H5_PRINTF_HADDR_FMT, ioffset);
+ h5tools_str_append(&buffer, "OFFSET %" PRIuHADDR, ioffset);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
}
ctx->indent_level--;
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index 5c47abd..9b3a4ca 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -864,7 +864,7 @@ dump_group(hid_t gid, const char *name)
if(!type_table->objs[u].recorded) {
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+ sprintf(type_name, "#%" PRIuHADDR, type_table->objs[u].objno);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
@@ -1313,7 +1313,7 @@ dump_fcontents(hid_t fid)
for (u = 0; u < type_table->nobjs; u++) {
if (!type_table->objs[u].recorded)
- PRINTSTREAM(rawoutstream, " %-10s /#"H5_PRINTF_HADDR_FMT"\n", "datatype", type_table->objs[u].objno);
+ PRINTSTREAM(rawoutstream, " %-10s /#%" PRIuHADDR "\n", "datatype", type_table->objs[u].objno);
}
}
@@ -2022,7 +2022,7 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe
if(!type_table->objs[idx].recorded) {
/* unamed datatype */
- sprintf(name, "/#"H5_PRINTF_HADDR_FMT, type_table->objs[idx].objno);
+ sprintf(name, "/#%" PRIuHADDR, type_table->objs[idx].objno);
if(!HDstrcmp(name, real_name))
break;
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c
index e399d8f..854f4a5 100644
--- a/tools/src/h5dump/h5dump_xml.c
+++ b/tools/src/h5dump/h5dump_xml.c
@@ -93,7 +93,7 @@ static h5tool_format_t xml_dataformat = {
1, /*skip_first */
1, /*obj_hidefileno */
- " "H5_PRINTF_HADDR_FMT, /*obj_format */
+ " %" PRIuHADDR, /*obj_format */
1, /*dset_hidefileno */
"DATASET %s ", /*dset_format */
@@ -587,7 +587,7 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen)
if (objno == HADDR_UNDEF) {
if (gen) {
objno = ref_path_table_gen_fake(str);
- sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ sprintf(outstr, "xid_%" PRIuHADDR, objno);
return 0;
}
else {
@@ -598,7 +598,7 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen)
else {
if (gen) {
objno = ref_path_table_gen_fake(str);
- sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ sprintf(outstr, "xid_%" PRIuHADDR, objno);
return 0;
}
else {
@@ -607,7 +607,7 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen)
}
}
- sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, objno);
+ sprintf(outstr, "xid_%" PRIuHADDR, objno);
return(0);
}
@@ -2685,7 +2685,7 @@ xml_dump_group(hid_t gid, const char *name)
if(!type_table->objs[u].recorded) {
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+ sprintf(type_name, "#%" PRIuHADDR, type_table->objs[u].objno);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
@@ -2767,7 +2767,7 @@ xml_dump_group(hid_t gid, const char *name)
if(!type_table->objs[u].recorded) {
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- sprintf(type_name, "#"H5_PRINTF_HADDR_FMT, type_table->objs[u].objno);
+ sprintf(type_name, "#%" PRIuHADDR, type_table->objs[u].objno);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
H5Dclose(dset);
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index cf03b30..0a69550 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -95,7 +95,7 @@ static h5tool_format_t ls_dataformat = {
0, /*skip_first */
0, /*obj_hidefileno */
- "-%lu:"H5_PRINTF_HADDR_FMT, /*obj_format */
+ "-%lu:%" PRIuHADDR, /*obj_format */
0, /*dset_hidefileno */
"DSET-%s ", /*dset_format */
@@ -1323,7 +1323,7 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind)
H5O_info_t oi;
if(H5Oget_info2(type, &oi, H5O_INFO_BASIC) >= 0)
- h5tools_str_append(buffer,"shared-%lu:"H5_PRINTF_HADDR_FMT" ",
+ h5tools_str_append(buffer,"shared-%lu:%" PRIuHADDR " ",
oi.fileno, oi.addr);
else
h5tools_str_append(buffer,"shared ");
@@ -2098,7 +2098,7 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void
/* Object location & reference count */
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", oinfo->fileno, oinfo->addr);
+ h5tools_str_append(&buffer, " %-10s %lu:%" PRIuHADDR "\n", "Location:", oinfo->fileno, oinfo->addr);
h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc);
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);