summaryrefslogtreecommitdiff
path: root/cesar/host
diff options
context:
space:
mode:
authordufour2009-01-09 13:28:45 +0000
committerdufour2009-01-09 13:28:45 +0000
commit4ee9a011ca47bd920019bc81535ee02f5faf3d95 (patch)
tree69d17f7a5d5dd4be75a7af2895dfd3f3312b77c6 /cesar/host
parentc1d582784850a3ef6dd6647d0f75c547199be720 (diff)
* host/netclock & hal/leon/maximus (see #232):
- fix the problem of 32 and 64 bits date comparison by adding a function to check if the 32 bits date has overflown. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@3740 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/host')
-rw-r--r--cesar/host/netclock/netclock.h12
-rw-r--r--cesar/host/netclock/src/netclock.c11
2 files changed, 23 insertions, 0 deletions
diff --git a/cesar/host/netclock/netclock.h b/cesar/host/netclock/netclock.h
index 094d927723..90013c9ef6 100644
--- a/cesar/host/netclock/netclock.h
+++ b/cesar/host/netclock/netclock.h
@@ -153,6 +153,18 @@ int netclock_recv(sci_msg_t *msg, void *netclock);
void netclock_hdr_dump(netclock_msg_hdr_t *hdr, int fd, char *buffer, int size);
+/**
+ * Convert a 32 bits date to a 64 one for comparison purpose.
+ * \param date_32 the 32 bits date to convert.
+ * \param date_64 the 64 bits date to compare to.
+ * \return the 32 bits converted date into 64 bits.
+ *
+ * The purpose of this function is to help handling the comparison between the
+ * hardware and simulator dates.
+ */
+u64
+netclock_date_32_to_64 (u32 date_32, u64 date_64);
+
//END_DECLS
#endif /*NETCLOCK_H_*/
diff --git a/cesar/host/netclock/src/netclock.c b/cesar/host/netclock/src/netclock.c
index 2b0f7f20bc..5163a401fb 100644
--- a/cesar/host/netclock/src/netclock.c
+++ b/cesar/host/netclock/src/netclock.c
@@ -358,3 +358,14 @@ void netclock_hdr_dump(netclock_msg_hdr_t *hdr, int fd, char *buffer, int size)
write(fd, buffer, strlen(buffer));
return;
}
+
+u64
+netclock_date_32_to_64 (u32 date_32, u64 date_64)
+{
+ /* Check date_32 has overflown (by adding half of a 32 bits integer). */
+ if ((date_32 + (1ull << 31)) < date_64)
+ /* Convert and return it. */
+ return date_32 + (1ull << 32);
+ /* No overflow, just return the 32 bits date. */
+ return date_32;
+}