[3/5] timer: Decouple x86_64 specific timer_settime from generic Linux implementation

Message ID 20191111214758.3677-4-lukma@denx.de
State New
Headers show
Series
  • y2038: linux: timer_[sg]ettime conversion to 64 bit time
Related show

Commit Message

Lukasz Majewski Nov. 11, 2019, 9:47 p.m.
The x86_64 specific timer_settime implementation (from
./linux/x86_64/timer_settime.c) reused the Linux generic one (from
./linux/timer_settime.c) to implement handling some compatible timers
(previously defined in librt, now in libc).

As the generic implementation now is going to also support new (available
from Linux 5.1+) timer_settime64 syscall, those two implementations have
been decoupled for easier conversion.
---
 sysdeps/unix/sysv/linux/timer_settime.c        |  7 -------
 sysdeps/unix/sysv/linux/x86_64/timer_settime.c | 14 ++++++++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

-- 
2.20.1

Comments

Lukasz Majewski Nov. 27, 2019, 4:59 p.m. | #1
Dear All,

> The x86_64 specific timer_settime implementation (from

> ./linux/x86_64/timer_settime.c) reused the Linux generic one (from

> ./linux/timer_settime.c) to implement handling some compatible timers

> (previously defined in librt, now in libc).

> 

> As the generic implementation now is going to also support new

> (available from Linux 5.1+) timer_settime64 syscall, those two

> implementations have been decoupled for easier conversion.

> ---

>  sysdeps/unix/sysv/linux/timer_settime.c        |  7 -------

>  sysdeps/unix/sysv/linux/x86_64/timer_settime.c | 14 ++++++++++----

>  2 files changed, 10 insertions(+), 11 deletions(-)

> 

> diff --git a/sysdeps/unix/sysv/linux/timer_settime.c

> b/sysdeps/unix/sysv/linux/timer_settime.c index

> a8350aedaa..51f24200aa 100644 ---

> a/sysdeps/unix/sysv/linux/timer_settime.c +++

> b/sysdeps/unix/sysv/linux/timer_settime.c @@ -22,17 +22,10 @@

>  #include <sysdep.h>

>  #include "kernel-posix-timers.h"

>  

> -

> -#ifdef timer_settime_alias

> -# define timer_settime timer_settime_alias

> -#endif

> -

> -

>  int

>  timer_settime (timer_t timerid, int flags, const struct itimerspec

> *value, struct itimerspec *ovalue)

>  {

> -#undef timer_settime

>    struct timer *kt = (struct timer *) timerid;

>  

>    /* Delete the kernel timer object.  */

> diff --git a/sysdeps/unix/sysv/linux/x86_64/timer_settime.c

> b/sysdeps/unix/sysv/linux/x86_64/timer_settime.c index

> ea8978d5cd..b71a82e8cc 100644 ---

> a/sysdeps/unix/sysv/linux/x86_64/timer_settime.c +++

> b/sysdeps/unix/sysv/linux/x86_64/timer_settime.c @@ -17,13 +17,19 @@

>     not, see <https://www.gnu.org/licenses/>.  */

>  

>  #include <shlib-compat.h>

> +#include <sysdep.h>

> +#include "kernel-posix-timers.h"

>  #include "compat-timer.h"

>  

> +int

> +__timer_settime_new (timer_t timerid, int flags, const struct

> itimerspec *value,

> +                     struct itimerspec *ovalue)

> +{

> +  struct timer *kt = (struct timer *) timerid;

>  

> -#define timer_settime_alias __timer_settime_new

> -#include <sysdeps/unix/sysv/linux/timer_settime.c>

> -

> -#undef timer_settime

> +  return INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,

> +                         value, ovalue);

> +}

>  versioned_symbol (librt, __timer_settime_new, timer_settime,

> GLIBC_2_3_3); 

>  


Gentle ping,


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Adhemerval Zanella Dec. 4, 2019, 7:41 p.m. | #2
On 11/11/2019 18:47, Lukasz Majewski wrote:
> The x86_64 specific timer_settime implementation (from

> ./linux/x86_64/timer_settime.c) reused the Linux generic one (from

> ./linux/timer_settime.c) to implement handling some compatible timers

> (previously defined in librt, now in libc).

> 

> As the generic implementation now is going to also support new (available

> from Linux 5.1+) timer_settime64 syscall, those two implementations have

> been decoupled for easier conversion.



LGTM with a nit below.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>


> ---

>  sysdeps/unix/sysv/linux/timer_settime.c        |  7 -------

>  sysdeps/unix/sysv/linux/x86_64/timer_settime.c | 14 ++++++++++----

>  2 files changed, 10 insertions(+), 11 deletions(-)

> 

> diff --git a/sysdeps/unix/sysv/linux/timer_settime.c b/sysdeps/unix/sysv/linux/timer_settime.c

> index a8350aedaa..51f24200aa 100644

> --- a/sysdeps/unix/sysv/linux/timer_settime.c

> +++ b/sysdeps/unix/sysv/linux/timer_settime.c

> @@ -22,17 +22,10 @@

>  #include <sysdep.h>

>  #include "kernel-posix-timers.h"

>  

> -

> -#ifdef timer_settime_alias

> -# define timer_settime timer_settime_alias

> -#endif

> -

> -

>  int

>  timer_settime (timer_t timerid, int flags, const struct itimerspec *value,

>  	       struct itimerspec *ovalue)

>  {

> -#undef timer_settime

>    struct timer *kt = (struct timer *) timerid;

>  

>    /* Delete the kernel timer object.  */


Ok.

> diff --git a/sysdeps/unix/sysv/linux/x86_64/timer_settime.c b/sysdeps/unix/sysv/linux/x86_64/timer_settime.c

> index ea8978d5cd..b71a82e8cc 100644

> --- a/sysdeps/unix/sysv/linux/x86_64/timer_settime.c

> +++ b/sysdeps/unix/sysv/linux/x86_64/timer_settime.c

> @@ -17,13 +17,19 @@

>     not, see <https://www.gnu.org/licenses/>.  */

>  

>  #include <shlib-compat.h>

> +#include <sysdep.h>

> +#include "kernel-posix-timers.h"

>  #include "compat-timer.h"

>  

> +int

> +__timer_settime_new (timer_t timerid, int flags, const struct itimerspec *value,

> +                     struct itimerspec *ovalue)

> +{

> +  struct timer *kt = (struct timer *) timerid;

>  

> -#define timer_settime_alias __timer_settime_new

> -#include <sysdeps/unix/sysv/linux/timer_settime.c>

> -

> -#undef timer_settime

> +  return INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,

> +                         value, ovalue);

> +}


Use INLINE_SYSCALL_CALL.

>  versioned_symbol (librt, __timer_settime_new, timer_settime, GLIBC_2_3_3);

>  

>  

>

Patch

diff --git a/sysdeps/unix/sysv/linux/timer_settime.c b/sysdeps/unix/sysv/linux/timer_settime.c
index a8350aedaa..51f24200aa 100644
--- a/sysdeps/unix/sysv/linux/timer_settime.c
+++ b/sysdeps/unix/sysv/linux/timer_settime.c
@@ -22,17 +22,10 @@ 
 #include <sysdep.h>
 #include "kernel-posix-timers.h"
 
-
-#ifdef timer_settime_alias
-# define timer_settime timer_settime_alias
-#endif
-
-
 int
 timer_settime (timer_t timerid, int flags, const struct itimerspec *value,
 	       struct itimerspec *ovalue)
 {
-#undef timer_settime
   struct timer *kt = (struct timer *) timerid;
 
   /* Delete the kernel timer object.  */
diff --git a/sysdeps/unix/sysv/linux/x86_64/timer_settime.c b/sysdeps/unix/sysv/linux/x86_64/timer_settime.c
index ea8978d5cd..b71a82e8cc 100644
--- a/sysdeps/unix/sysv/linux/x86_64/timer_settime.c
+++ b/sysdeps/unix/sysv/linux/x86_64/timer_settime.c
@@ -17,13 +17,19 @@ 
    not, see <https://www.gnu.org/licenses/>.  */
 
 #include <shlib-compat.h>
+#include <sysdep.h>
+#include "kernel-posix-timers.h"
 #include "compat-timer.h"
 
+int
+__timer_settime_new (timer_t timerid, int flags, const struct itimerspec *value,
+                     struct itimerspec *ovalue)
+{
+  struct timer *kt = (struct timer *) timerid;
 
-#define timer_settime_alias __timer_settime_new
-#include <sysdeps/unix/sysv/linux/timer_settime.c>
-
-#undef timer_settime
+  return INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
+                         value, ovalue);
+}
 versioned_symbol (librt, __timer_settime_new, timer_settime, GLIBC_2_3_3);