As you are surely aware, there will be a problem with our current 32bit type time_t, since values after 19 Jan 2038 will become negative and thus cannot be represented. Although that will give us about 13 years before it really will become a problem, an increasing number of packages already may misbehave when working with 32bit time_t values. Eg. the some backends in gcc are starting to deprecate such a type in their runtime library, and as a result expect the underlying c-library to support a 64bit time_t type.
Actually, i think the situation is not that bad. For example, our struct stat already has members for the high values of time values:
So using a 64bit time_t for those will not change the layout.
Introducing such a type (from the application point of view) should be implement following glibc. The application can define _TIME_BITS to be either 32 or 64, and will get a default value for it if that is undefined (much like is done for _FILE_OFFSET_BITS for file related functions). For a start, we could even set the default to 32 so existing applications don't break.
Using a 64bit time_t has (after a first look) direct consequences to the following structures
- struct timeval
- struct timespec
- struct itimerspec
- struct itimerval
- struct utimbuf
- struct timeb
- struct msqid_ds
- struct shmid_ds
- struct semid_ds
So we will need alternate names for all those. As a result, following functions in mintlib will be affected:
- gettimeofday()
|
__gettimeofday (struct timeval *tp, struct timezone *tzp) |
- settimeofday)
|
__settimeofday (const struct timeval *tp, const struct timezone *tzp) |
- time()
- mktime()
|
time_t mktime(struct tm *tmp) |
- difftime()
|
double difftime(time_t time1, time_t time0) |
- gmtime()
|
struct tm *gmtime(const time_t * timep) |
- gmtime_r()
|
struct tm *gmtime_r(const time_t *__restrict timep, struct tm *__restrict tmp) |
- localtime()
|
struct tm *localtime(const time_t *timep) |
- localtime_r()
|
struct tm *localtime_r(const time_t *__restrict timep, struct tm *__restrict tmp) |
- ctime()
|
char *ctime(const time_t *timep) |
- ctime_r()
|
char *ctime_r(const time_t *timep, char *buf) |
- timegm()
|
time_t timegm(struct tm *tmp) |
- timelocal()
|
time_t timelocal(struct tm *tmp) |
- clock_gettime()
|
__clock_gettime(clockid_t clock_id, struct timespec *tp) |
- clock_settime() NYI
- utime()
|
__utime (const char *_filename, const struct utimbuf *_tset) |
- utimes()
|
__utimes (const char *filename, const struct timeval tvp[2]) |
- futimens() NYI
- semctl()
|
__semctl (int semid, int semnum, int cmd, ...) |
- semtimedop() NYI
- sendmsg()
|
__sendmsg (int fd, const struct msghdr *msg, int flags) |
- recvmsg()
|
__recvmsg (int fd, struct msghdr *msg, int flags) |
- adjtime
|
int __adjtime (__const struct timeval *__delta, |
- getitimer()
|
__getitimer (enum __itimer_which which, struct itimerval* old) |
- setitimer()
|
__setitimer (enum __itimer_which which, const struct itimerval* new, |
- ftime()
|
ftime (struct timeb *timebuf) |
- futimes()
|
int __futimes (int fd, const struct timeval tvp[2]) |
- stime()
|
__stime (const time_t *now) |
Note that some of the IPC functions are not yet implement in mintlib and/or the kernel so are currently not that important.
There would also be some more posix functions that are affected, but which are not implemented in mintlib yet.
There are also a bunch of other functions that take a timeval/timespec as argument, but use it as a relative timeout value rather than an absolute value, so maybe don't need to be changed for now (you don't want to do a sleep() for more than 140 years). This also includes pthread_* functions, should they be implemented.
- select()
- pselect()
- poll()
- ppoll()
- fcntl()
- sem_timedwait()
- sem_clockwait()
- nanosleep()
- clock_getres()
- clock_nanosleep()
- getrusage()
- wait3()
- wait4()
As a result of the above, it seems we would need only 2 new functions in the mint kernel for now:
- Tgettimeofday64()
- Tsettimeofday64()
Tgetdate()/Tsetdate are not affected because
- they cannot be changed for TOS-compatibility
- they use a base year of 1980 and therefor will only overflow at 2108
Some other functions should be checked whether they behave correctly. Eg. all the functions that deal with struct stat should check the time values from filesystems to fit into 32bits if needed.
Obviously, we need a kernel first which implements the new functions, otherwise those new interfaces can't be used.
Any comments on these are welcome, especially should i have missed any types/functions that are affected.
PS.: Note that the timezone database is not affected by this. zic (the timezone info compiler) uses a 64bit type internally for quite some time, and produces tables that contain both 32bit and 64bit values.
As you are surely aware, there will be a problem with our current 32bit type time_t, since values after 19 Jan 2038 will become negative and thus cannot be represented. Although that will give us about 13 years before it really will become a problem, an increasing number of packages already may misbehave when working with 32bit time_t values. Eg. the some backends in gcc are starting to deprecate such a type in their runtime library, and as a result expect the underlying c-library to support a 64bit time_t type.
Actually, i think the situation is not that bad. For example, our struct stat already has members for the high values of time values:
mintlib/include/bits/stat.h
Line 45 in fe785b5
So using a 64bit time_t for those will not change the layout.
Introducing such a type (from the application point of view) should be implement following glibc. The application can define
_TIME_BITSto be either 32 or 64, and will get a default value for it if that is undefined (much like is done for_FILE_OFFSET_BITSfor file related functions). For a start, we could even set the default to 32 so existing applications don't break.Using a 64bit time_t has (after a first look) direct consequences to the following structures
So we will need alternate names for all those. As a result, following functions in mintlib will be affected:
mintlib/unix/gettimeofday.c
Line 18 in fe785b5
mintlib/unix/settimeofday.c
Line 17 in fe785b5
mintlib/unix/time.c
Line 17 in fe785b5
mintlib/tz/localtime.c
Line 2367 in fe785b5
mintlib/tz/difftime.c
Line 16 in fe785b5
mintlib/tz/localtime.c
Line 1762 in fe785b5
mintlib/tz/localtime.c
Line 1756 in fe785b5
mintlib/tz/localtime.c
Line 1711 in fe785b5
mintlib/tz/localtime.c
Line 1722 in fe785b5
mintlib/tz/ctime.c
Line 9 in fe785b5
mintlib/tz/ctime.c
Line 18 in fe785b5
mintlib/tz/localtime.c
Line 2393 in fe785b5
mintlib/tz/localtime.c
Line 2386 in fe785b5
mintlib/posix/clock_gettime.c
Line 22 in fe785b5
mintlib/unix/utime.c
Line 28 in fe785b5
mintlib/unix/utimes.c
Line 24 in fe785b5
mintlib/sysvipc/semctl.c
Line 38 in fe785b5
mintlib/socket/sendmsg.c
Line 22 in fe785b5
mintlib/socket/recvmsg.c
Line 22 in fe785b5
mintlib/unix/adjtime.c
Line 16 in fe785b5
mintlib/unix/getitimer.c
Line 19 in fe785b5
mintlib/unix/setitimer.c
Line 19 in fe785b5
mintlib/time/ftime.c
Line 23 in fe785b5
mintlib/unix/futimes.c
Line 26 in fe785b5
mintlib/unix/stime.c
Line 18 in fe785b5
Note that some of the IPC functions are not yet implement in mintlib and/or the kernel so are currently not that important.
There would also be some more posix functions that are affected, but which are not implemented in mintlib yet.
There are also a bunch of other functions that take a timeval/timespec as argument, but use it as a relative timeout value rather than an absolute value, so maybe don't need to be changed for now (you don't want to do a sleep() for more than 140 years). This also includes pthread_* functions, should they be implemented.
As a result of the above, it seems we would need only 2 new functions in the mint kernel for now:
Tgetdate()/Tsetdate are not affected because
Some other functions should be checked whether they behave correctly. Eg. all the functions that deal with struct stat should check the time values from filesystems to fit into 32bits if needed.
Obviously, we need a kernel first which implements the new functions, otherwise those new interfaces can't be used.
Any comments on these are welcome, especially should i have missed any types/functions that are affected.
PS.: Note that the timezone database is not affected by this. zic (the timezone info compiler) uses a 64bit type internally for quite some time, and produces tables that contain both 32bit and 64bit values.