xref: /linux-6.15/include/linux/time32.h (revision bbd9d056)
1 #ifndef _LINUX_TIME32_H
2 #define _LINUX_TIME32_H
3 /*
4  * These are all interfaces based on the old time_t definition
5  * that overflows in 2038 on 32-bit architectures. New code
6  * should use the replacements based on time64_t and timespec64.
7  *
8  * Any interfaces in here that become unused as we migrate
9  * code to time64_t should get removed.
10  */
11 
12 #include <linux/time64.h>
13 #include <linux/timex.h>
14 
15 typedef s32		old_time32_t;
16 
17 struct old_timespec32 {
18 	old_time32_t	tv_sec;
19 	s32		tv_nsec;
20 };
21 
22 struct old_timeval32 {
23 	old_time32_t	tv_sec;
24 	s32		tv_usec;
25 };
26 
27 struct old_itimerspec32 {
28 	struct old_timespec32 it_interval;
29 	struct old_timespec32 it_value;
30 };
31 
32 struct old_utimbuf32 {
33 	old_time32_t	actime;
34 	old_time32_t	modtime;
35 };
36 
37 struct old_timex32 {
38 	u32 modes;
39 	s32 offset;
40 	s32 freq;
41 	s32 maxerror;
42 	s32 esterror;
43 	s32 status;
44 	s32 constant;
45 	s32 precision;
46 	s32 tolerance;
47 	struct old_timeval32 time;
48 	s32 tick;
49 	s32 ppsfreq;
50 	s32 jitter;
51 	s32 shift;
52 	s32 stabil;
53 	s32 jitcnt;
54 	s32 calcnt;
55 	s32 errcnt;
56 	s32 stbcnt;
57 	s32 tai;
58 
59 	s32:32; s32:32; s32:32; s32:32;
60 	s32:32; s32:32; s32:32; s32:32;
61 	s32:32; s32:32; s32:32;
62 };
63 
64 extern int get_old_timespec32(struct timespec64 *, const void __user *);
65 extern int put_old_timespec32(const struct timespec64 *, void __user *);
66 extern int get_old_itimerspec32(struct itimerspec64 *its,
67 			const struct old_itimerspec32 __user *uits);
68 extern int put_old_itimerspec32(const struct itimerspec64 *its,
69 			struct old_itimerspec32 __user *uits);
70 struct __kernel_timex;
71 int get_old_timex32(struct __kernel_timex *, const struct old_timex32 __user *);
72 int put_old_timex32(struct old_timex32 __user *, const struct __kernel_timex *);
73 
74 /**
75  * ns_to_kernel_old_timeval - Convert nanoseconds to timeval
76  * @nsec:	the nanoseconds value to be converted
77  *
78  * Returns the timeval representation of the nsec parameter.
79  */
80 extern struct __kernel_old_timeval ns_to_kernel_old_timeval(s64 nsec);
81 
82 #endif
83