Index | Thread | Search

From:
Stuart Henderson <stu@spacehopper.org>
Subject:
Re: devel/libstdthreads: Manpage contains incorrect information
To:
Christian Schulte <cs@schulte.it>
Cc:
ports@openbsd.org, Matthieu Herrb <matthieu.herrb@laas.fr>
Date:
Thu, 2 Jul 2026 13:06:28 +0100

Download raw body.

Thread
On 2026/07/02 13:31, Christian Schulte wrote:
> Hi maintainers,
> 
> the manual of function thrd_sleep as documented in thrd_create.3
> in package devel/libstdthreads contains incorrect information. The same
> page is served at man.freebsd.org and contains the same incorrect
> return value section there as well. I think this should be fixed.
> Following that manual one is lead to checking for thrd_success which
> happens to be zero on some platforms, but not BSD. Reading that manual
> should not lead to broken code only working by accident on other platforms
> but BSD.

+cc matthieu@

Should we also mention the need to check errno? It's noted in
https://pubs.opengroup.org/onlinepubs/9799919799/functions/thrd_sleep.html

Updated diff below

> Index: devel/libstdthreads/patches/patch-thrd_create_3
> ===================================================================
> RCS file: devel/libstdthreads/patches/patch-thrd_create_3
> diff -N devel/libstdthreads/patches/patch-thrd_create_3
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ devel/libstdthreads/patches/patch-thrd_create_3	2 Jul 2026 11:23:07 -0000
> @@ -0,0 +1,24 @@
> +Index: thrd_create.3
> +--- thrd_create.3.orig
> ++++ thrd_create.3
> +@@ -191,7 +191,6 @@ If successful, the
> + .Fn thrd_detach ,
> + .Fn thrd_equal ,
> + .Fn thrd_join ,
> +-.Fn thrd_sleep ,
> + .Fn tss_create
> + and
> + .Fn tss_set
> +@@ -202,6 +201,12 @@ Otherwise an error code will be returned to indicate t
> + The
> + .Fn thrd_current
> + function returns the thread ID of the calling thread.
> ++.Pp
> ++The
> ++.Fn thrd_sleep
> ++function returns zero if the requested time has elapsed,
> ++-1 if it has been interrupted by a signal,
> ++or a negative value (which can also be -1) if it fails.
> + .Pp
> + The
> + .Fn tss_get
> 

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/libstdthreads/Makefile,v
diff -u -p -w -r1.6 Makefile
--- Makefile	17 Nov 2025 19:25:59 -0000	1.6
+++ Makefile	2 Jul 2026 12:05:07 -0000
@@ -2,11 +2,11 @@ COMMENT = C11 standard threads library
 
 DISTNAME =	libstdthreads-${V}
 V =		0.3.2
-REVISION =	2
+REVISION =	3
 
 CATEGORIES =	devel
 
-SITES =	https://code.tetaneutral.net/mherrb/libstdthreads//archive/
+SITES =	https://code.tetaneutral.net/mherrb/libstdthreads/archive/
 DISTFILES =     ${DISTNAME}-1{${DISTNAME}}.tar.gz
 
 SHARED_LIBS +=  stdthreads                0.0 # 0.0
Index: patches/patch-thrd_create_3
===================================================================
RCS file: patches/patch-thrd_create_3
diff -N patches/patch-thrd_create_3
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-thrd_create_3	2 Jul 2026 12:05:07 -0000
@@ -0,0 +1,28 @@
+Index: thrd_create.3
+--- thrd_create.3.orig
++++ thrd_create.3
+@@ -191,7 +191,6 @@ If successful, the
+ .Fn thrd_detach ,
+ .Fn thrd_equal ,
+ .Fn thrd_join ,
+-.Fn thrd_sleep ,
+ .Fn tss_create
+ and
+ .Fn tss_set
+@@ -202,6 +201,16 @@ Otherwise an error code will be returned to indicate t
+ The
+ .Fn thrd_current
+ function returns the thread ID of the calling thread.
++.Pp
++The
++.Fn thrd_sleep
++function returns zero if the requested time has elapsed,
++-1 if it has been interrupted by a signal,
++or a negative value (which can also be -1) if it fails for any other reason.
++If a negative value is returned, errno should be checked to distinguish
++EINTR (in which case,
++.Fa remaining
++contains the unslept time) from other values.
+ .Pp
+ The
+ .Fn tss_get