git-lll-wait-intr
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Thu, 15 Aug 2024 09:21:36 +0000 (11:21 +0200)
committerAurelien Jarno <aurel32@debian.org>
Thu, 15 Aug 2024 09:21:36 +0000 (11:21 +0200)
Commited for 2.33

commit 1c3c8e342a3973fc5e1ddcba7d3e9b68dfe9a25b
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Dec 13 11:01:52 2020 +0000

    hurd: Add __lll_abstimed_wait_intr

    For semaphores, we need an interruptible version of low-level locks.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-lll-wait-intr.diff

hurd/Makefile
hurd/RPC_gsync_wait_intr.c [new file with mode: 0644]
hurd/Versions
hurd/hurdlock.c
hurd/hurdlock.h
mach/lowlevellock.h

index e3c66002b23cc584880c2db5dc517efd8d7f5d43..91302255a8ecd7ccf95e60ad3944d00739a08083 100644 (file)
@@ -93,6 +93,7 @@ CFLAGS-RPC_exec_startup_get_info.o = $(no-stack-protector)
 # Make generated headers compatible with all support standards
 migheaderpipe := | sed -e 's/\<ino64_t\>/__ino64_t/' -e 's/\<loff_t\>/__loff_t/'
 include ../mach/Machrules
+libhurduser-routines += RPC_gsync_wait_intr
 include ../Rules
 \f
 # intr-rpc.defs defines the INTR_INTERFACE macro to make the generated RPC
diff --git a/hurd/RPC_gsync_wait_intr.c b/hurd/RPC_gsync_wait_intr.c
new file mode 100644 (file)
index 0000000..51b6321
--- /dev/null
@@ -0,0 +1,4 @@
+#include "intr-rpc.h"
+#define gsync_wait gsync_wait_intr
+#define __gsync_wait __gsync_wait_intr
+#include "RPC_gsync_wait.c"
index 1098085c1db8a854a6c707e13d10d85a1ed62e40..9a4dc2d2c8d6e21095e76486f75cb0dd7c5a3624 100644 (file)
@@ -156,7 +156,7 @@ libc {
 
   GLIBC_PRIVATE {
     # Used by other libs.
-    __lll_abstimed_wait; __lll_abstimed_xwait;
+    __lll_abstimed_wait; __lll_abstimed_wait_intr; __lll_abstimed_xwait;
     __lll_abstimed_lock; __lll_robust_lock;
     __lll_robust_abstimed_lock; __lll_robust_trylock;
     __lll_robust_unlock;
index 0bed500e57c1ac0dc5f924140bbc6db89a8170b3..f624b873260a2bc933db087cf317a13dfe2d29e2 100644 (file)
@@ -51,6 +51,27 @@ __lll_abstimed_wait (void *ptr, int val,
   return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_wait (ptr, val, mlsec, flags);
 }
 
+#if 1
+int
+__lll_abstimed_wait_intr (void *ptr, int val,
+  const struct timespec *tsp, int flags, int clk)
+{
+  if (clk != CLOCK_REALTIME)
+    return EINVAL;
+
+  int mlsec = compute_reltime (tsp, clk);
+  extern void _S_msg_server(void);
+  extern void __fsys_get_children(void);
+  //return (int) (intptr_t) _S_msg_server;
+  //return (int) (intptr_t) __fsys_get_children;
+  //return (int) (intptr_t) __gsync_wait_intr;
+  //return (int) (intptr_t) _hurd_intr_rpc_mach_msg;
+  //return mlsec < 0 ? KERN_TIMEDOUT : 0;
+  //__lll_timed_wait_intr (ptr, val, mlsec, flags);
+  return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_wait_intr (ptr, val, mlsec, flags);
+}
+#endif
+
 int
 __lll_abstimed_xwait (void *ptr, int lo, int hi,
   const struct timespec *tsp, int flags, int clk)
index c1df42bea4d07041a902a1e8aa9e3369d64f8db7..0a7f6eaf901a3d8a61d20d83da1a6172044e5c09 100644 (file)
@@ -40,6 +40,11 @@ struct timespec;
   __gsync_wait (__mach_task_self (), \
     (vm_offset_t)ptr, val, 0, mlsec, flags | GSYNC_TIMED)
 
+/* Interruptible version.  */
+#define __lll_timed_wait_intr(ptr, val, mlsec, flags) \
+  __gsync_wait_intr (__mach_task_self (), \
+    (vm_offset_t)ptr, val, 0, mlsec, flags | GSYNC_TIMED)
+
 /* Same as '__lll_xwait', but only block for MLSEC milliseconds.  */
 #define __lll_timed_xwait(ptr, lo, hi, mlsec, flags) \
   __gsync_wait (__mach_task_self (), (vm_offset_t)ptr, \
@@ -50,6 +55,10 @@ struct timespec;
 extern int __lll_abstimed_wait (void *__ptr, int __val,
   const struct timespec *__tsp, int __flags, int __clk);
 
+/* Interruptible version.  */
+extern int __lll_abstimed_wait_intr (void *__ptr, int __val,
+  const struct timespec *__tsp, int __flags, int __clk);
+
 /* Same as 'lll_xwait', but only block until TSP elapses,
    using clock CLK.  */
 extern int __lll_abstimed_xwait (void *__ptr, int __lo, int __hi,
@@ -106,6 +115,13 @@ extern void __lll_robust_unlock (void *__ptr, int __flags);
        __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]);   \
    })
 
+#define lll_abstimed_wait_intr(var, val, tsp, flags, ...)   \
+  ({   \
+     const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ };   \
+     __lll_abstimed_wait_intr (&(var), (val), (tsp), (flags),   \
+       __clk[sizeof (__clk) / sizeof (__clk[0]) - 1]);   \
+   })
+
 #define lll_abstimed_xwait(var, lo, hi, tsp, flags, ...)   \
   ({   \
      const clockid_t __clk[] = { CLOCK_REALTIME, ##__VA_ARGS__ };   \
index 0a22a030b46946c3eddf2292980ef27abe4eab50..b872d0fe1e128055c3c49d2afd8c92d67f6bf17a 100644 (file)
 /* Static initializer for low-level locks.  */
 #define LLL_LOCK_INITIALIZER   0
 
+/* Interruptible version of __gsync_wait.  */
+extern kern_return_t __gsync_wait_intr
+(
+       mach_port_t task,
+       vm_offset_t addr,
+       unsigned val1,
+       unsigned val2,
+       natural_t msec,
+       int flags
+);
+
 /* Wait on address PTR, without blocking if its contents
  * are different from VAL.  */
 #define __lll_wait(ptr, val, flags)   \
 #define lll_wait(var, val, flags) \
   __lll_wait (&(var), val, flags)
 
+/* Interruptible version.  */
+#define __lll_wait_intr(ptr, val, flags)   \
+  __gsync_wait_intr (__mach_task_self (),   \
+    (vm_offset_t)(ptr), (val), 0, 0, (flags))
+#define lll_wait_intr(var, val, flags) \
+  __lll_wait_intr ((&var), val, flags)
+
 /* Wake one or more threads waiting on address PTR.  */
 #define __lll_wake(ptr, flags)   \
   __gsync_wake (__mach_task_self (), (vm_offset_t)(ptr), 0, (flags))