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 v7 0/3] y2038: Linux: Introduce __clock_settime64 function


On Fri, Sep 6, 2019 at 7:59 AM Lukasz Majewski <lukma@denx.de> wrote:
>
> This patch set introduces the conversion of clock_settime to explicit
> 64 bit struct __timespec64 arguments. As a result this function is now
> Y2038 safe.
>
> This work is (loosely) based on a previous development/patches:
> https://libc-alpha.sourceware.narkive.com/zniMOWui/rfc-patch-00-52-make-glibc-y2038-proof#post68
>
> Github branch (including the y2038 conversion example):
> https://github.com/lmajewski/y2038_glibc/commits/glibc__clock_settime-conversion-v7
>
> Those patches have been applied on top of master branch:
> SHA1: a26918cfda4bc4b9dad8aae1496e3ef7cbb63d96
>
> Shall be used with provided meta-y2038 for development and testing:
> https://github.com/lmajewski/meta-y2038
>
> I've used guidelines from:
> https://www.gnu.org/software/libc/manual/html_mono/libc.html
> "D.2.1 64-bit time symbol handling in the GNU C Library"
> to convert *clock_settime*.
>
> and most notably from:
> https://sourceware.org/glibc/wiki/Y2038ProofnessDesign#clock_gettime.28.29

Thanks for the patches Lukassz!

With my RV32 port I see this failure when compiling:

In file included from ../sysdeps/generic/hp-timing.h:23,
                 from ../nptl/descr.h:27,
                 from ../sysdeps/riscv/nptl/tls.h:41,
                 from ../include/errno.h:25,
                 from ../sysdeps/unix/sysv/linux/clock_settime.c:18:
../include/time.h:129:28: error: conflicting types for '__clock_settime'
 # define __clock_settime64 __clock_settime
                            ^~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/clock_settime.c:25:1: note: in expansion of
macro '__clock_settime64'
 __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
 ^~~~~~~~~~~~~~~~~
In file included from <command-line>:
../include/time.h:25:20: note: previous declaration of
'__clock_settime' was here
 libc_hidden_proto (__clock_settime)
                    ^~~~~~~~~~~~~~~
./../include/libc-symbols.h:598:33: note: in definition of macro
'__hidden_proto'
   extern thread __typeof (name) name __hidden_proto_hiddenattr (attrs);
                                 ^~~~
./../include/libc-symbols.h:617:44: note: in expansion of macro 'hidden_proto'
 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
                                            ^~~~~~~~~~~~
../include/time.h:25:1: note: in expansion of macro 'libc_hidden_proto'
 libc_hidden_proto (__clock_settime)
 ^~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/clock_settime.c:70:42: error: conflicting
types for 'clock_settime'
 versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17);
                                          ^~~~~~~~~~~~~
./../include/libc-symbols.h:152:26: note: in definition of macro '_weak_alias'
   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
                          ^~~~~~~~~
../include/shlib-compat.h:74:3: note: in expansion of macro 'weak_alias'
   weak_alias (local, symbol)
   ^~~~~~~~~~
../sysdeps/unix/sysv/linux/clock_settime.c:70:1: note: in expansion of
macro 'versioned_symbol'
 versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17);
 ^~~~~~~~~~~~~~~~
In file included from ../include/time.h:2,
                 from ../sysdeps/generic/hp-timing.h:23,
                 from ../nptl/descr.h:27,
                 from ../sysdeps/riscv/nptl/tls.h:41,
                 from ../include/errno.h:25,
                 from ../sysdeps/unix/sysv/linux/clock_settime.c:18:
../time/time.h:222:12: note: previous declaration of 'clock_settime' was here
 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)

Which I can fix with this diff:

diff --git a/include/time.h b/include/time.h
index 7ed3aa61d1d..28e2722de21 100644
--- a/include/time.h
+++ b/include/time.h
@@ -125,13 +125,9 @@ extern __time64_t __timegm64 (struct tm *__tp) __THROW;
 libc_hidden_proto (__timegm64)
 #endif

-#if __TIMESIZE == 64
-# define __clock_settime64 __clock_settime
-#else
 extern int __clock_settime64 (clockid_t clock_id,
                               const struct __timespec64 *tp);
 libc_hidden_proto (__clock_settime64)
-#endif

 /* Compute the `struct tm' representation of T,
    offset OFFSET seconds east of UTC,
diff --git a/sysdeps/unix/sysv/linux/clock_settime.c
b/sysdeps/unix/sysv/linux/clock_settime.c
index f5e084238a5..ab033c56ea9 100644
--- a/sysdeps/unix/sysv/linux/clock_settime.c
+++ b/sysdeps/unix/sysv/linux/clock_settime.c
@@ -54,7 +54,6 @@ __clock_settime64 (clockid_t clock_id, const struct
__timespec64 *tp)
 #endif
 }

-#if __TIMESIZE != 64
 int
 __clock_settime (clockid_t clock_id, const struct timespec *tp)
 {
@@ -63,7 +62,6 @@ __clock_settime (clockid_t clock_id, const struct
timespec *tp)
   valid_timespec_to_timespec64 (tp, &ts64);
   return __clock_settime64 (clock_id, &ts64);
 }
-#endif

 libc_hidden_def (__clock_settime)

Alistair

>
>
> Lukasz Majewski (3):
>   y2038: Introduce internal for glibc struct __timespec64
>   y2038: Provide conversion helpers for struct __timespec64
>   y2038: linux: Provide __clock_settime64 implementation
>
>  include/time.h                          | 116 ++++++++++++++++++++++++
>  sysdeps/unix/sysv/linux/clock_settime.c |  38 +++++++-
>  2 files changed, 150 insertions(+), 4 deletions(-)
>
> --
> 2.20.1
>


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