This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

32-bit time_t inside itimerval


Hey,

I just noticed something strange.

The setitimer syscall is not different for 32/64-bit time_t. So we use
this syscall for both 32/64 time_t [1]

SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
        struct itimerval __user *, ovalue)

Where struct itimerval __user *, value looks like this [2]:

struct itimerval {
    struct timeval it_interval;    /* timer interval */
    struct timeval it_value;    /* current value */
};

Which then uses this structure for timeval [3]:

struct timeval {
    __kernel_old_time_t    tv_sec;        /* seconds */
    __kernel_suseconds_t    tv_usec;    /* microseconds */
};

And __kernel_old_time_t is defined [4] as:

typedef __kernel_long_t    __kernel_old_time_t;
typedef __kernel_long_t    __kernel_time_t;


So __kernel_old_time_t and __kernel_time_t are both 32-bit values
inside the kernel. and the setiimer syscall expects a 32-bit time_t
for the values inside it.

This is different to the current glibc implementation where all time_t
values are treated as 64-bit for RISC-V [5].

What should we do here?

1. Change glibc to use a 32-bit time_t for some structures, such as
the timeval inside itimerval?
2. Convert the kernel time_t to be 64-bit for RV32?

Alistair

1: https://github.com/torvalds/linux/blob/ceb307474506f888e8f16dab183405ff01dffa08/kernel/time/itimer.c#L336
2: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/linux/time.h#L39
3: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/linux/time.h#L16
4: https://github.com/torvalds/linux/blob/b01d7cb41ff51b7779977de601a984406e2a5ba9/include/uapi/asm-generic/posix_types.h#L89
5: https://github.com/alistair23/glibc/commit/71faeb322c4f4a163d138893b6855920dad45e07


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]