guix/gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
Josselin Poiret 0dd293b4d9
gnu: Add libc-for-target and glibc/hurd.
* gnu/packages/patches/glibc-2.37-hurd-clock_t_centiseconds.patch
* gnu/packages/patches/glibc-2.37-hurd-local-clock_gettime_MONOTONIC.patch
* gnu/packages/patches/glibc-2.37-versioned-locpath.patch: New patches.
* gnu/local.mk (dist_patch_DATA): Register them.

* gnu/packages/base.scm (glibc/hurd, libc-for-target): New variables.
(glibc/hurd-headers): Use glibc/hurd.
* gnu/packages/commencement.scm (glibc-final-with-bootstrap-bash)[outputs,
source, arguments]
(glibc-final)[source]: Use libc-for-target instead of glibc.
* gnu/packages/cross-base.scm (cross-libc/deprecated, cross-libc*): Use
libc-for-target.

This part fixes

    https://issues.guix.gnu.org/63641#25

* gnu/packages/commencement.scm (%final-inputs): Change to memoized lambda
taking "system".
* gnu/packages/commencement.scm (canonical-package): Likewise, and update
user, passing (%current-system).
(make-gcc-toolchain): Update user, passing (%current-system).
* gnu/packages/base.scm (%final-inputs): Likewise.
* guix/scripts/refresh.scm (options->update-specs): Likewise.
* guix/build-system/gnu.scm (standard-packages): Add optional "system"
parameter.
(lower): Update caller.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Co-authored-by: Janneke Nieuwenhuizen <janneke@gnu.org>
2023-07-13 18:20:05 +02:00

136 lines
4.9 KiB
Diff

Taken from: https://salsa.debian.org/glibc-team/glibc/-/blob/9ce19663f00176f30d6eab29fd14db3e7cd53dcf/debian/patches/hurd-i386/local-clock_gettime_MONOTONIC.diff
Use the realtime clock for the monotonic clock. This is of course not a proper
implementation (which is being done in Mach), but will permit to fix at least
the iceweasel stack.
vlc however doesn't build when _POSIX_CLOCK_SELECTION is enabled but
_POSIX_TIMERS is not, and they refuse to fix that (see #765578), so disable the
former.
---
sysdeps/mach/hurd/bits/posix_opt.h | 2 +-
sysdeps/unix/clock_gettime.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
Index: glibc-2.27/sysdeps/mach/clock_gettime.c
===================================================================
--- glibc-2.27.orig/sysdeps/mach/clock_gettime.c
+++ glibc-2.27/sysdeps/mach/clock_gettime.c
@@ -31,6 +31,10 @@ __clock_gettime (clockid_t clock_id, str
switch (clock_id) {
case CLOCK_REALTIME:
+ case CLOCK_MONOTONIC:
+ case CLOCK_MONOTONIC_RAW:
+ case CLOCK_REALTIME_COARSE:
+ case CLOCK_MONOTONIC_COARSE:
{
/* __host_get_time can only fail if passed an invalid host_t.
__mach_host_self could theoretically fail (producing an
Index: glibc-2.27/rt/timer_create.c
===================================================================
--- glibc-2.27.orig/rt/timer_create.c
+++ glibc-2.27/rt/timer_create.c
@@ -48,7 +48,7 @@ timer_create (clockid_t clock_id, struct
return -1;
}
- if (clock_id != CLOCK_REALTIME)
+ if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE)
{
__set_errno (EINVAL);
return -1;
Index: glibc-2.27/sysdeps/mach/hurd/bits/posix_opt.h
===================================================================
--- glibc-2.27.orig/sysdeps/mach/hurd/bits/posix_opt.h
+++ glibc-2.27/sysdeps/mach/hurd/bits/posix_opt.h
@@ -163,10 +163,10 @@
#define _POSIX_THREAD_PROCESS_SHARED -1
/* The monotonic clock might be available. */
-#define _POSIX_MONOTONIC_CLOCK 0
+#define _POSIX_MONOTONIC_CLOCK 200809L
-/* The clock selection interfaces are available. */
-#define _POSIX_CLOCK_SELECTION 200809L
+/* The clock selection interfaces are not really available yet. */
+#define _POSIX_CLOCK_SELECTION -1
/* Advisory information interfaces could be available in future. */
#define _POSIX_ADVISORY_INFO 0
Index: glibc-upstream/sysdeps/posix/clock_getres.c
===================================================================
--- glibc-upstream.orig/sysdeps/posix/clock_getres.c
+++ glibc-upstream/sysdeps/posix/clock_getres.c
@@ -52,6 +52,10 @@ __clock_getres (clockid_t clock_id, stru
switch (clock_id)
{
case CLOCK_REALTIME:
+ case CLOCK_MONOTONIC:
+ case CLOCK_MONOTONIC_RAW:
+ case CLOCK_REALTIME_COARSE:
+ case CLOCK_MONOTONIC_COARSE:
retval = realtime_getres (res);
break;
--- ./sysdeps/mach/clock_nanosleep.c.original 2020-07-21 00:31:35.226113142 +0200
+++ ./sysdeps/mach/clock_nanosleep.c 2020-07-21 00:31:49.026185761 +0200
@@ -62,7 +62,7 @@
__clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
struct timespec *rem)
{
- if (clock_id != CLOCK_REALTIME
+ if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_MONOTONIC_RAW && clock_id != CLOCK_REALTIME_COARSE && clock_id != CLOCK_MONOTONIC_COARSE)
|| !valid_nanoseconds (req->tv_nsec)
|| (flags != 0 && flags != TIMER_ABSTIME))
return EINVAL;
Index: glibc-2.32/hurd/hurdlock.c
===================================================================
--- glibc-2.32.orig/hurd/hurdlock.c
+++ glibc-2.32/hurd/hurdlock.c
@@ -47,7 +47,7 @@ int
__lll_abstimed_wait (void *ptr, int val,
const struct timespec *tsp, int flags, int clk)
{
- if (clk != CLOCK_REALTIME)
+ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
return EINVAL;
int mlsec = compute_reltime (tsp, clk);
@@ -59,7 +59,7 @@ int
__lll_abstimed_wait_intr (void *ptr, int val,
const struct timespec *tsp, int flags, int clk)
{
- if (clk != CLOCK_REALTIME)
+ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
return EINVAL;
int mlsec = compute_reltime (tsp, clk);
@@ -79,7 +79,7 @@ int
__lll_abstimed_xwait (void *ptr, int lo, int hi,
const struct timespec *tsp, int flags, int clk)
{
- if (clk != CLOCK_REALTIME)
+ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
return EINVAL;
int mlsec = compute_reltime (tsp, clk);
@@ -91,7 +91,7 @@ int
__lll_abstimed_lock (void *ptr,
const struct timespec *tsp, int flags, int clk)
{
- if (clk != CLOCK_REALTIME)
+ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
return EINVAL;
if (__lll_trylock (ptr) == 0)
@@ -177,7 +177,7 @@ __lll_robust_abstimed_lock (void *ptr,
int wait_time = 25;
unsigned int val;
- if (clk != CLOCK_REALTIME)
+ if (clk != CLOCK_REALTIME && clk != CLOCK_MONOTONIC)
return EINVAL;
while (1)