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]

Re: [PATCH v9] y2038: Provide conversion helpers for struct __timespec64


On 9/26/19 2:55 PM, Lukasz Majewski wrote:
+/* Convert a known valid struct timeval into a struct __timespec64.  */
+static inline void
+valid_timeval_to_timespec64 (const struct timeval *tv32,
+			     struct __timespec64 *ts64)
+{
+  ts64->tv_sec = tv32->tv_sec;
+  ts64->tv_nsec = tv32->tv_usec * 1000;
+}

I suggest using values rather than pointers. That is, this function can accept a struct timeval and return a struct __timespec64. The *s and the consts just get in the way for something simple like this, and using values will simplify the source code.

For the fancier functions that do range checking, you can simply return an invalid result (with tv_nsec < 0, say). So you don't need a separate boolean there. Some GNU apps do this sort of thing.


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