summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-10-28 20:13:16 +0000
committerdillon <dillon@FreeBSD.org>2001-10-28 20:13:16 +0000
commitcdd5ebd3b2b4da560e1502d2af05a4eded9b8fc9 (patch)
tree1ed18984204d465714c14b43e94e4f3ac5eba93c /lib/libc
parent41f4e0eb175e0e1ec2c7fa0af905e97ed76996c7 (diff)
downloadFreeBSD-src-cdd5ebd3b2b4da560e1502d2af05a4eded9b8fc9.zip
FreeBSD-src-cdd5ebd3b2b4da560e1502d2af05a4eded9b8fc9.tar.gz
Add time_to_int(), int_to_time(), time_to_long(), long_to_time().
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdtime/time32.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/libc/stdtime/time32.c b/lib/libc/stdtime/time32.c
index 4886f7c..ed3d3e0 100644
--- a/lib/libc/stdtime/time32.c
+++ b/lib/libc/stdtime/time32.c
@@ -58,3 +58,43 @@ time_to_time64(time_t t)
return((__int64_t)t);
}
+/*
+ * Convert to/from 'long'. Depending on the sizeof(long) this may or
+ * may not require using the 50-year rule.
+ */
+long
+time_to_long(time_t t)
+{
+ if (sizeof(long) == sizeof(__int64_t))
+ return(time_to_time64(t));
+ return((long)t);
+}
+
+time_t
+long_to_time(long tlong)
+{
+ if (sizeof(long) == sizeof(__int32_t))
+ return(time32_to_time(tlong));
+ return((time_t)tlong);
+}
+
+/*
+ * Convert to/from 'int'. Depending on the sizeof(int) this may or
+ * may not require using the 50-year rule.
+ */
+int
+time_to_int(time_t t)
+{
+ if (sizeof(int) == sizeof(__int64_t))
+ return(time_to_time64(t));
+ return((int)t);
+}
+
+time_t
+int_to_time(int tint)
+{
+ if (sizeof(int) == sizeof(__int32_t))
+ return(time32_to_time(tint));
+ return((time_t)tint);
+}
+
OpenPOWER on IntegriCloud