summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33abbbd)
raw | patch | inline | side by side (parent: 33abbbd)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 11 Jan 2010 09:06:59 +0000 (09:06 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 11 Jan 2010 09:06:59 +0000 (09:06 +0000) |
since on freebsd in 64bit mode time_t is 32 bit while long is 64 bit
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1997 a5681a0c-68f1-0310-ab6d-d61299d08faa
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1997 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/configure.ac | patch | blob | history | |
program/src/rrd_restore.c | patch | blob | history |
diff --git a/program/configure.ac b/program/configure.ac
index b90e189a3e049ed229a4278efeadfe60f77931f1..a4e9383c8f362c4a8e6d943456a443285f78bcbf 100644 (file)
--- a/program/configure.ac
+++ b/program/configure.ac
]
)
-dnl is time_t long or long long ?
-AC_DEFINE([TIME_T_IS_LONG], [], [time_t is long])
-AC_DEFINE([TIME_T_IS_LONG_LONG], [], [time_t is long long])
+dnl is time_t 32 of 64 bit ?
+AC_DEFINE([TIME_T_IS_32BIT], [], [time_t is 32bit])
+AC_DEFINE([TIME_T_IS_64BIT], [], [time_t is 64bit])
AC_MSG_CHECKING([the type of time_t])
AC_RUN_IFELSE(
AC_LANG_PROGRAM(
[[#include <time.h>]],
- [[if (sizeof(long) != sizeof(time_t)) return 1; ]]
+ [[if (sizeof(time_t) != 32) return 1; ]]
),
- [ AC_MSG_RESULT([time_t is long])
- AC_DEFINE([TIME_T_IS_LONG])
+ [ AC_MSG_RESULT([time_t is 32 bit])
+ AC_DEFINE([TIME_T_IS_32BIT])
],
[ AC_RUN_IFELSE(
AC_LANG_PROGRAM(
[[#include <time.h>]],
- [[if (sizeof(long long) != sizeof(time_t)) return 1; ]]
+ [[if (sizeof(time_t) != 64) return 1; ]]
),
[
- AC_MSG_RESULT([time_t is long long])
- AC_DEFINE([TIME_T_IS_LONG_LONG])
+ AC_MSG_RESULT([time_t is 64 bit])
+ AC_DEFINE([TIME_T_IS_64BIT])
],
[AC_MSG_ERROR([can not figure type of time_t])]
)
index 2f671a1103fc98d995fc2fc1bf1d812b80655464..8cde6f1fbd54aff8c4761626c3f043ba021195f0 100644 (file)
}
-static int get_xml_long(
+static int get_xml_time_t(
xmlTextReaderPtr reader,
- long *value)
+ time_t *value)
{
xmlChar *text;
- long temp;
+ time_t temp;
if ((text = get_xml_text(reader)) != NULL){
errno = 0;
+#ifdef TIME_T_IS_32BIT
temp = strtol((char *)text,NULL, 0);
+#else
+#ifdef TIME_T_IS_64BIT
+ temp = strtoll((char *)text,NULL, 0);
+#else
+ if (sizeof(time_t) == 32){
+ temp = strtol((char *)text,NULL, 0);
+ } else {
+ temp = strtoll((char *)text,NULL, 0);
+ }
+#endif
+#endif
if (errno>0){
- rrd_set_error("ling %d: get_xml_long from '%s' %s",
+ rrd_set_error("ling %d: get_xml_time_t from '%s' %s",
xmlTextReaderGetParserLineNumber(reader),
text,rrd_strerror(errno));
xmlFree(text);
return 0;
}
return -1;
-} /* get_xml_long */
+} /* get_xml_time_t */
static int get_xml_ulong(
xmlTextReaderPtr reader,
return -1;
} /* get_xml_ulong */
-#ifndef TIME_T_IS_LONG
-static int get_xml_llong(
- xmlTextReaderPtr reader,
- long long *value)
-{
-
- xmlChar *text;
- long long temp;
- if ((text = get_xml_text(reader)) != NULL){
- errno = 0;
- temp = strtoll((char *)text,NULL, 0);
- if (errno>0){
- rrd_set_error("ling %d: get_xml_llong from '%s' %s",
- xmlTextReaderGetParserLineNumber(reader),
- text,rrd_strerror(errno));
- xmlFree(text);
- return -1;
- }
- xmlFree(text);
- *value = temp;
- return 0;
- }
- return -1;
-} /* get_xml_llong */
-
-#endif
-
static int get_xml_double(
xmlTextReaderPtr reader,
double *value)
status = get_xml_ulong(reader,
&rrd->stat_head->pdp_step);
else if (xmlStrcasecmp(element, (const xmlChar *) "lastupdate") == 0) {
-#ifdef TIME_T_IS_LONG
- status = get_xml_long(reader, &rrd->live_head->last_up);
-#else
-#ifdef TIME_T_IS_LONG_LONG
- status = get_xml_llong(reader, &rrd->live_head->last_up);
-#else
- if (sizeof(time_t) == sizeof(long)) {
- status = get_xml_long(reader,
- (long *)&rrd->live_head->last_up);
- }
- else if (sizeof(time_t) == sizeof(long long)) {
- status = get_xml_llong(reader,
- (long long *)&rrd->live_head->last_up);
- }
-#endif
-#endif
+ status = get_xml_time_t(reader, &rrd->live_head->last_up);
}
else if (xmlStrcasecmp(element, (const xmlChar *) "ds") == 0){
xmlFree(element);