On Sat, 2021-02-20 at 16:18 +0100, Philippe Gerum via Xenomai wrote:
[snip]
> +#if __BITS_PER_LONG == 64

That might be a beginner question, but I'm learning from the best ;-)

Do we really care about each single assignment (two per timespec) and
each object on the stack that it is worth duplicating all this helpers?
We could use the __BITS_PER_LONG == 32 version for both worlds,
couldn't we?

Thanks in advance...

> +
> +/*
> + * NOTE: those copy helpers won't work in compat mode: use
> + * sys32_get_timespec(), sys32_put_timespec() instead.
> + */
> +
> +static inline int cobalt_get_u_timespec(struct timespec64 *dst,
> +                     const struct __user_old_timespec __user *src)
> +{
> +     return cobalt_copy_from_user(dst, src, sizeof(*dst));
> +}
> +
> +static inline int cobalt_put_u_timespec(
> +     struct __user_old_timespec __user *dst,
> +     const struct timespec64 *src)
> +{
> +     return cobalt_copy_to_user(dst, src, sizeof(*dst));
> +}
> +
> +#else /* __BITS_PER_LONG == 32 */
> +
> +static inline int cobalt_get_u_timespec(struct timespec64 *dst,
> +                     const struct __user_old_timespec __user *src)
> +{
> +     struct __user_old_timespec u_ts;
> +     int ret;
> +
> +     ret = cobalt_copy_from_user(&u_ts, src, sizeof(u_ts));
> +     if (ret)
> +             return ret;
> +
> +     dst->tv_sec = u_ts.tv_sec;
> +     dst->tv_nsec = u_ts.tv_nsec;
> +
> +     return 0;
> +}
> +
> +static inline int cobalt_put_u_timespec(
> +     struct __user_old_timespec __user *dst,
> +     const struct timespec64 *src)
> +{
> +     struct __user_old_timespec u_ts;
> +     int ret;
> +
> +     u_ts.tv_sec = src->tv_sec;
> +     u_ts.tv_nsec = src->tv_nsec;
> +
> +     ret = cobalt_copy_to_user(dst, &u_ts, sizeof(*dst));
> +     if (ret)
> +             return ret;
> +
> +     return 0;
> +}
> +
> +#endif

[snip]

Reply via email to