Skip to content

Commit 412c53a

Browse files
arndbtorvalds
authored andcommitted
y2038: remove unused time32 interfaces
No users remain, so kill these off before we grow new ones. Link: http://lkml.kernel.org/r/20200110154232.4104492-3-arnd@arndb.de Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Deepa Dinamani <deepa.kernel@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 595abba commit 412c53a

6 files changed

Lines changed: 1 addition & 326 deletions

File tree

include/linux/compat.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,6 @@ typedef struct compat_siginfo {
248248
} _sifields;
249249
} compat_siginfo_t;
250250

251-
/*
252-
* These functions operate on 32- or 64-bit specs depending on
253-
* COMPAT_USE_64BIT_TIME, hence the void user pointer arguments.
254-
*/
255-
extern int compat_get_timespec(struct timespec *, const void __user *);
256-
extern int compat_put_timespec(const struct timespec *, void __user *);
257-
extern int compat_get_timeval(struct timeval *, const void __user *);
258-
extern int compat_put_timeval(const struct timeval *, void __user *);
259-
260251
struct compat_iovec {
261252
compat_uptr_t iov_base;
262253
compat_size_t iov_len;
@@ -416,26 +407,6 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *to, const kernel_siginf
416407
int get_compat_sigevent(struct sigevent *event,
417408
const struct compat_sigevent __user *u_event);
418409

419-
static inline int old_timeval32_compare(struct old_timeval32 *lhs,
420-
struct old_timeval32 *rhs)
421-
{
422-
if (lhs->tv_sec < rhs->tv_sec)
423-
return -1;
424-
if (lhs->tv_sec > rhs->tv_sec)
425-
return 1;
426-
return lhs->tv_usec - rhs->tv_usec;
427-
}
428-
429-
static inline int old_timespec32_compare(struct old_timespec32 *lhs,
430-
struct old_timespec32 *rhs)
431-
{
432-
if (lhs->tv_sec < rhs->tv_sec)
433-
return -1;
434-
if (lhs->tv_sec > rhs->tv_sec)
435-
return 1;
436-
return lhs->tv_nsec - rhs->tv_nsec;
437-
}
438-
439410
extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
440411

441412
/*

include/linux/time32.h

Lines changed: 1 addition & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <linux/time64.h>
1313
#include <linux/timex.h>
1414

15-
#define TIME_T_MAX (__kernel_old_time_t)((1UL << ((sizeof(__kernel_old_time_t) << 3) - 1)) - 1)
16-
1715
typedef s32 old_time32_t;
1816

1917
struct old_timespec32 {
@@ -73,162 +71,12 @@ struct __kernel_timex;
7371
int get_old_timex32(struct __kernel_timex *, const struct old_timex32 __user *);
7472
int put_old_timex32(struct old_timex32 __user *, const struct __kernel_timex *);
7573

76-
#if __BITS_PER_LONG == 64
77-
78-
/* timespec64 is defined as timespec here */
79-
static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
80-
{
81-
return *(const struct timespec *)&ts64;
82-
}
83-
84-
static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
85-
{
86-
return *(const struct timespec64 *)&ts;
87-
}
88-
89-
#else
90-
static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64)
91-
{
92-
struct timespec ret;
93-
94-
ret.tv_sec = (time_t)ts64.tv_sec;
95-
ret.tv_nsec = ts64.tv_nsec;
96-
return ret;
97-
}
98-
99-
static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
100-
{
101-
struct timespec64 ret;
102-
103-
ret.tv_sec = ts.tv_sec;
104-
ret.tv_nsec = ts.tv_nsec;
105-
return ret;
106-
}
107-
#endif
108-
109-
static inline int timespec_equal(const struct timespec *a,
110-
const struct timespec *b)
111-
{
112-
return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
113-
}
114-
115-
/*
116-
* lhs < rhs: return <0
117-
* lhs == rhs: return 0
118-
* lhs > rhs: return >0
119-
*/
120-
static inline int timespec_compare(const struct timespec *lhs, const struct timespec *rhs)
121-
{
122-
if (lhs->tv_sec < rhs->tv_sec)
123-
return -1;
124-
if (lhs->tv_sec > rhs->tv_sec)
125-
return 1;
126-
return lhs->tv_nsec - rhs->tv_nsec;
127-
}
128-
129-
/*
130-
* Returns true if the timespec is norm, false if denorm:
131-
*/
132-
static inline bool timespec_valid(const struct timespec *ts)
133-
{
134-
/* Dates before 1970 are bogus */
135-
if (ts->tv_sec < 0)
136-
return false;
137-
/* Can't have more nanoseconds then a second */
138-
if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
139-
return false;
140-
return true;
141-
}
142-
143-
/**
144-
* timespec_to_ns - Convert timespec to nanoseconds
145-
* @ts: pointer to the timespec variable to be converted
146-
*
147-
* Returns the scalar nanosecond representation of the timespec
148-
* parameter.
149-
*/
150-
static inline s64 timespec_to_ns(const struct timespec *ts)
151-
{
152-
return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
153-
}
154-
15574
/**
156-
* ns_to_timespec - Convert nanoseconds to timespec
157-
* @nsec: the nanoseconds value to be converted
158-
*
159-
* Returns the timespec representation of the nsec parameter.
160-
*/
161-
extern struct timespec ns_to_timespec(const s64 nsec);
162-
163-
/**
164-
* timespec_add_ns - Adds nanoseconds to a timespec
165-
* @a: pointer to timespec to be incremented
166-
* @ns: unsigned nanoseconds value to be added
167-
*
168-
* This must always be inlined because its used from the x86-64 vdso,
169-
* which cannot call other kernel functions.
170-
*/
171-
static __always_inline void timespec_add_ns(struct timespec *a, u64 ns)
172-
{
173-
a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
174-
a->tv_nsec = ns;
175-
}
176-
177-
static inline unsigned long mktime(const unsigned int year,
178-
const unsigned int mon, const unsigned int day,
179-
const unsigned int hour, const unsigned int min,
180-
const unsigned int sec)
181-
{
182-
return mktime64(year, mon, day, hour, min, sec);
183-
}
184-
185-
static inline bool timeval_valid(const struct timeval *tv)
186-
{
187-
/* Dates before 1970 are bogus */
188-
if (tv->tv_sec < 0)
189-
return false;
190-
191-
/* Can't have more microseconds then a second */
192-
if (tv->tv_usec < 0 || tv->tv_usec >= USEC_PER_SEC)
193-
return false;
194-
195-
return true;
196-
}
197-
198-
/**
199-
* timeval_to_ns - Convert timeval to nanoseconds
200-
* @ts: pointer to the timeval variable to be converted
201-
*
202-
* Returns the scalar nanosecond representation of the timeval
203-
* parameter.
204-
*/
205-
static inline s64 timeval_to_ns(const struct timeval *tv)
206-
{
207-
return ((s64) tv->tv_sec * NSEC_PER_SEC) +
208-
tv->tv_usec * NSEC_PER_USEC;
209-
}
210-
211-
/**
212-
* ns_to_timeval - Convert nanoseconds to timeval
75+
* ns_to_kernel_old_timeval - Convert nanoseconds to timeval
21376
* @nsec: the nanoseconds value to be converted
21477
*
21578
* Returns the timeval representation of the nsec parameter.
21679
*/
217-
extern struct timeval ns_to_timeval(const s64 nsec);
21880
extern struct __kernel_old_timeval ns_to_kernel_old_timeval(s64 nsec);
21981

220-
/*
221-
* Old names for the 32-bit time_t interfaces, these will be removed
222-
* when everything uses the new names.
223-
*/
224-
#define compat_time_t old_time32_t
225-
#define compat_timeval old_timeval32
226-
#define compat_timespec old_timespec32
227-
#define compat_itimerspec old_itimerspec32
228-
#define ns_to_compat_timeval ns_to_old_timeval32
229-
#define get_compat_itimerspec64 get_old_itimerspec32
230-
#define put_compat_itimerspec64 put_old_itimerspec32
231-
#define compat_get_timespec64 get_old_timespec32
232-
#define compat_put_timespec64 put_old_timespec32
233-
23482
#endif

include/linux/timekeeping32.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,4 @@ static inline unsigned long get_seconds(void)
1111
return ktime_get_real_seconds();
1212
}
1313

14-
static inline void getnstimeofday(struct timespec *ts)
15-
{
16-
struct timespec64 ts64;
17-
18-
ktime_get_real_ts64(&ts64);
19-
*ts = timespec64_to_timespec(ts64);
20-
}
21-
22-
static inline void ktime_get_ts(struct timespec *ts)
23-
{
24-
struct timespec64 ts64;
25-
26-
ktime_get_ts64(&ts64);
27-
*ts = timespec64_to_timespec(ts64);
28-
}
29-
30-
static inline void getrawmonotonic(struct timespec *ts)
31-
{
32-
struct timespec64 ts64;
33-
34-
ktime_get_raw_ts64(&ts64);
35-
*ts = timespec64_to_timespec(ts64);
36-
}
37-
38-
static inline void getboottime(struct timespec *ts)
39-
{
40-
struct timespec64 ts64;
41-
42-
getboottime64(&ts64);
43-
*ts = timespec64_to_timespec(ts64);
44-
}
45-
4614
#endif

include/linux/types.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ typedef __kernel_ssize_t ssize_t;
6565
typedef __kernel_ptrdiff_t ptrdiff_t;
6666
#endif
6767

68-
#ifndef _TIME_T
69-
#define _TIME_T
70-
typedef __kernel_old_time_t time_t;
71-
#endif
72-
7368
#ifndef _CLOCK_T
7469
#define _CLOCK_T
7570
typedef __kernel_clock_t clock_t;

kernel/compat.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -26,70 +26,6 @@
2626

2727
#include <linux/uaccess.h>
2828

29-
static int __compat_get_timeval(struct timeval *tv, const struct old_timeval32 __user *ctv)
30-
{
31-
return (!access_ok(ctv, sizeof(*ctv)) ||
32-
__get_user(tv->tv_sec, &ctv->tv_sec) ||
33-
__get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
34-
}
35-
36-
static int __compat_put_timeval(const struct timeval *tv, struct old_timeval32 __user *ctv)
37-
{
38-
return (!access_ok(ctv, sizeof(*ctv)) ||
39-
__put_user(tv->tv_sec, &ctv->tv_sec) ||
40-
__put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
41-
}
42-
43-
static int __compat_get_timespec(struct timespec *ts, const struct old_timespec32 __user *cts)
44-
{
45-
return (!access_ok(cts, sizeof(*cts)) ||
46-
__get_user(ts->tv_sec, &cts->tv_sec) ||
47-
__get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
48-
}
49-
50-
static int __compat_put_timespec(const struct timespec *ts, struct old_timespec32 __user *cts)
51-
{
52-
return (!access_ok(cts, sizeof(*cts)) ||
53-
__put_user(ts->tv_sec, &cts->tv_sec) ||
54-
__put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
55-
}
56-
57-
int compat_get_timeval(struct timeval *tv, const void __user *utv)
58-
{
59-
if (COMPAT_USE_64BIT_TIME)
60-
return copy_from_user(tv, utv, sizeof(*tv)) ? -EFAULT : 0;
61-
else
62-
return __compat_get_timeval(tv, utv);
63-
}
64-
EXPORT_SYMBOL_GPL(compat_get_timeval);
65-
66-
int compat_put_timeval(const struct timeval *tv, void __user *utv)
67-
{
68-
if (COMPAT_USE_64BIT_TIME)
69-
return copy_to_user(utv, tv, sizeof(*tv)) ? -EFAULT : 0;
70-
else
71-
return __compat_put_timeval(tv, utv);
72-
}
73-
EXPORT_SYMBOL_GPL(compat_put_timeval);
74-
75-
int compat_get_timespec(struct timespec *ts, const void __user *uts)
76-
{
77-
if (COMPAT_USE_64BIT_TIME)
78-
return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
79-
else
80-
return __compat_get_timespec(ts, uts);
81-
}
82-
EXPORT_SYMBOL_GPL(compat_get_timespec);
83-
84-
int compat_put_timespec(const struct timespec *ts, void __user *uts)
85-
{
86-
if (COMPAT_USE_64BIT_TIME)
87-
return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
88-
else
89-
return __compat_put_timespec(ts, uts);
90-
}
91-
EXPORT_SYMBOL_GPL(compat_put_timespec);
92-
9329
#ifdef __ARCH_WANT_SYS_SIGPROCMASK
9430

9531
/*

kernel/time/time.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -449,49 +449,6 @@ time64_t mktime64(const unsigned int year0, const unsigned int mon0,
449449
}
450450
EXPORT_SYMBOL(mktime64);
451451

452-
/**
453-
* ns_to_timespec - Convert nanoseconds to timespec
454-
* @nsec: the nanoseconds value to be converted
455-
*
456-
* Returns the timespec representation of the nsec parameter.
457-
*/
458-
struct timespec ns_to_timespec(const s64 nsec)
459-
{
460-
struct timespec ts;
461-
s32 rem;
462-
463-
if (!nsec)
464-
return (struct timespec) {0, 0};
465-
466-
ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
467-
if (unlikely(rem < 0)) {
468-
ts.tv_sec--;
469-
rem += NSEC_PER_SEC;
470-
}
471-
ts.tv_nsec = rem;
472-
473-
return ts;
474-
}
475-
EXPORT_SYMBOL(ns_to_timespec);
476-
477-
/**
478-
* ns_to_timeval - Convert nanoseconds to timeval
479-
* @nsec: the nanoseconds value to be converted
480-
*
481-
* Returns the timeval representation of the nsec parameter.
482-
*/
483-
struct timeval ns_to_timeval(const s64 nsec)
484-
{
485-
struct timespec ts = ns_to_timespec(nsec);
486-
struct timeval tv;
487-
488-
tv.tv_sec = ts.tv_sec;
489-
tv.tv_usec = (suseconds_t) ts.tv_nsec / 1000;
490-
491-
return tv;
492-
}
493-
EXPORT_SYMBOL(ns_to_timeval);
494-
495452
struct __kernel_old_timeval ns_to_kernel_old_timeval(const s64 nsec)
496453
{
497454
struct timespec64 ts = ns_to_timespec64(nsec);

0 commit comments

Comments
 (0)