[v3] sys/lock.h: Add clock selection APIs for the

Message ID 20260303215850.77326-1-mez3n1151@gmail.com
State New
Headers
Series [v3] sys/lock.h: Add clock selection APIs for the |

Commit Message

Mazen Adel Elmessady March 3, 2026, 9:58 p.m. UTC
  Updated _Semaphore_Wait_timed (which is currently unused in RTEMS)
to _Semaphore_Wait_timed_clock which
to be used in RTEMS sempahore API.
This will ease the support of the new clock
functions added in Posix Issue 8.

V2: Kept _Semaphore_Wait_timed while adding
_Semaphore_Wait_timed_clock

V3: Added _Mutex_Acquire_timed_clock()
_Mutex_recursive_Acquire_timed_clock()
_Condition_Wait_timed_clock()
_Condition_Wait_recursive_timed_clock()
To include all the clock selection APIs for
all of the synchronization object class
---
 newlib/libc/sys/rtems/include/sys/lock.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Comments

Sebastian Huber March 5, 2026, 1:01 p.m. UTC | #1
----- Am 3. Mrz 2026 um 22:58 schrieb Mazen Adel Elmessady mez3n1151@gmail.com:

> Updated _Semaphore_Wait_timed (which is currently unused in RTEMS)
> to _Semaphore_Wait_timed_clock which
> to be used in RTEMS sempahore API.
> This will ease the support of the new clock
> functions added in Posix Issue 8.
> 
> V2: Kept _Semaphore_Wait_timed while adding
> _Semaphore_Wait_timed_clock
> 
> V3: Added _Mutex_Acquire_timed_clock()
> _Mutex_recursive_Acquire_timed_clock()
> _Condition_Wait_timed_clock()
> _Condition_Wait_recursive_timed_clock()
> To include all the clock selection APIs for
> all of the synchronization object class
> ---
> newlib/libc/sys/rtems/include/sys/lock.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
> 
> diff --git a/newlib/libc/sys/rtems/include/sys/lock.h
> b/newlib/libc/sys/rtems/include/sys/lock.h
> index d6169025b..79fb6b2de 100644
> --- a/newlib/libc/sys/rtems/include/sys/lock.h
> +++ b/newlib/libc/sys/rtems/include/sys/lock.h
> @@ -27,6 +27,7 @@
> #define _SYS_LOCK_H_
> 
> #include <sys/cdefs.h>
> +#include <sys/_timespec.h>

In this case, you can drop the struct timespec forward declaration below.

> #include <stddef.h>
> 
> __BEGIN_DECLS
> @@ -137,6 +138,9 @@ void _Mutex_Acquire(struct _Mutex_Control *);
> 
> int _Mutex_Acquire_timed(struct _Mutex_Control *, const struct timespec *);
> 
> +int _Mutex_Acquire_timed_clock(struct _Mutex_Control *,
> +	const struct timespec *, __clockid_t)

Missing ';'?

Did you test building GCC with this patch?

Please keep the four spaces line continuation format of the FreeBSD style in this file.

The rest looks good.

[...]
  
Sebastian Huber March 6, 2026, 3:39 a.m. UTC | #2
----- Am 5. Mrz 2026 um 19:36 schrieb Mazen Adel Elmessady mez3n1151@gmail.com:

> It should all be good now.
> I tested the patch by building the tools for RTEMS 7 for the target
> xilinx_zynq_a9_qemu
> and then running RTEMS tests and everything worked fine.

Thanks, I checked it in with a modified commit message.
  

Patch

diff --git a/newlib/libc/sys/rtems/include/sys/lock.h b/newlib/libc/sys/rtems/include/sys/lock.h
index d6169025b..79fb6b2de 100644
--- a/newlib/libc/sys/rtems/include/sys/lock.h
+++ b/newlib/libc/sys/rtems/include/sys/lock.h
@@ -27,6 +27,7 @@ 
 #define _SYS_LOCK_H_
 
 #include <sys/cdefs.h>
+#include <sys/_timespec.h>
 #include <stddef.h>
 
 __BEGIN_DECLS
@@ -137,6 +138,9 @@  void _Mutex_Acquire(struct _Mutex_Control *);
 
 int _Mutex_Acquire_timed(struct _Mutex_Control *, const struct timespec *);
 
+int _Mutex_Acquire_timed_clock(struct _Mutex_Control *,
+	const struct timespec *, __clockid_t)
+
 int _Mutex_Acquire_timed_ticks(struct _Mutex_Control *, __uint32_t);
 
 int _Mutex_Try_acquire(struct _Mutex_Control *);
@@ -187,6 +191,9 @@  void _Mutex_recursive_Acquire(struct _Mutex_recursive_Control *);
 int _Mutex_recursive_Acquire_timed(struct _Mutex_recursive_Control *,
     const struct timespec *);
 
+int _Mutex_recursive_Acquire_timed_clock(struct _Mutex_recursive_Control *,
+    const struct timespec *, __clockid_t);
+
 int _Mutex_recursive_Acquire_timed_ticks(struct _Mutex_recursive_Control *,
     __uint32_t);
 
@@ -237,6 +244,9 @@  void _Condition_Wait(struct _Condition_Control *, struct _Mutex_Control *);
 int _Condition_Wait_timed(struct _Condition_Control *,
     struct _Mutex_Control *, const struct timespec *);
 
+int _Condition_Wait_timed_clock(struct _Condition_Control *,
+    struct _Mutex_Control *, const struct timespec *, __clockid_t);
+
 int _Condition_Wait_timed_ticks(struct _Condition_Control *,
     struct _Mutex_Control *, __uint32_t);
 
@@ -246,6 +256,9 @@  void _Condition_Wait_recursive(struct _Condition_Control *,
 int _Condition_Wait_recursive_timed(struct _Condition_Control *,
     struct _Mutex_recursive_Control *, const struct timespec *);
 
+int _Condition_Wait_recursive_timed_clock(struct _Condition_Control *,
+    struct _Mutex_recursive_Control *, const struct timespec *, __clockid_t);
+
 int _Condition_Wait_recursive_timed_ticks(struct _Condition_Control *,
     struct _Mutex_recursive_Control *, __uint32_t);
 
@@ -298,6 +311,9 @@  void _Semaphore_Wait(struct _Semaphore_Control *);
 int _Semaphore_Wait_timed(struct _Semaphore_Control *,
     const struct timespec *);
 
+int _Semaphore_Wait_timed_clock(struct _Semaphore_Control *,
+    const struct timespec *, __clockid_t);
+
 int _Semaphore_Wait_timed_ticks(struct _Semaphore_Control *, __uint32_t);
 
 int _Semaphore_Try_wait(struct _Semaphore_Control *);