Module Name:    src
Committed By:   kamil
Date:           Wed Apr 24 18:47:54 UTC 2019

Modified Files:
        src/lib/libpthread: thrd.3 thrd.c threads.h

Log Message:
Introduce minor changes to the C11 threading library

Switch tss_t type from int to pthread_key_t (no functional change as
pthread_key_t was already typedefed as int).

Noted by <enh from Google>.

Use C11 _Noreturn in thrd_exit(3) instead of NetBSD specific __dead.
The former is documented in the standard as an attribute of thrd_exit(3),
the latter is more portable to pre-C11 compilers, however C11 thread
support library needs C11 compiler for TLS anyway. __dead made a little bit
more point 3 years ago than today as 3 years ago pre-C11 compilers were
more common.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libpthread/thrd.3 src/lib/libpthread/thrd.c \
    src/lib/libpthread/threads.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/thrd.3
diff -u src/lib/libpthread/thrd.3:1.1 src/lib/libpthread/thrd.3:1.2
--- src/lib/libpthread/thrd.3:1.1	Wed Apr 24 11:43:19 2019
+++ src/lib/libpthread/thrd.3	Wed Apr 24 18:47:54 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: thrd.3,v 1.1 2019/04/24 11:43:19 kamil Exp $
+.\"	$NetBSD: thrd.3,v 1.2 2019/04/24 18:47:54 kamil Exp $
 .\"
 .\" Copyright (c) 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -46,7 +46,7 @@
 .Fn thrd_detach "thrd_t thr"
 .Ft int
 .Fn thrd_equal "thrd_t t1" "thrd_t t2"
-.Ft __dead void
+.Ft _Noreturn void
 .Fn thrd_exit "int res"
 .Ft int
 .Fn thrd_join "thrd_t thr" "int *res"
@@ -191,14 +191,6 @@ otherwise it will return non-zero.
 The
 .Fn thrd_exit
 function does not return.
-The standard attributes this function with the
-.Dv _Noreturn
-keyword,
-however in the
-.Nx
-version it is attributed with the traditional and functionally equivalent
-.Dv __dead
-keyword.
 .Pp
 The
 .Fn thrd_join
Index: src/lib/libpthread/thrd.c
diff -u src/lib/libpthread/thrd.c:1.1 src/lib/libpthread/thrd.c:1.2
--- src/lib/libpthread/thrd.c:1.1	Wed Apr 24 11:43:19 2019
+++ src/lib/libpthread/thrd.c	Wed Apr 24 18:47:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: thrd.c,v 1.1 2019/04/24 11:43:19 kamil Exp $	*/
+/*	$NetBSD: thrd.c,v 1.2 2019/04/24 18:47:54 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: thrd.c,v 1.1 2019/04/24 11:43:19 kamil Exp $");
+__RCSID("$NetBSD: thrd.c,v 1.2 2019/04/24 18:47:54 kamil Exp $");
 
 #include <assert.h>
 #include <errno.h>
@@ -85,7 +85,7 @@ thrd_equal(thrd_t t1, thrd_t t2)
 	return pthread_equal(t1, t2);
 }
 
-__dead void
+_Noreturn void
 thrd_exit(int res)
 {
 
Index: src/lib/libpthread/threads.h
diff -u src/lib/libpthread/threads.h:1.1 src/lib/libpthread/threads.h:1.2
--- src/lib/libpthread/threads.h:1.1	Wed Apr 24 11:43:19 2019
+++ src/lib/libpthread/threads.h	Wed Apr 24 18:47:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: threads.h,v 1.1 2019/04/24 11:43:19 kamil Exp $	*/
+/*	$NetBSD: threads.h,v 1.2 2019/04/24 18:47:54 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 /* ISO/IEC 9899:201x 7.26.1/4 */
 typedef pthread_cond_t	  cnd_t;
 typedef pthread_t	  thrd_t;
-typedef int		  tss_t;
+typedef pthread_key_t	  tss_t;
 typedef pthread_mutex_t	  mtx_t;
 typedef void		(*tss_dtor_t)	(void *);
 typedef int		(*thrd_start_t)	(void *);
@@ -106,7 +106,7 @@ int	thrd_create(thrd_t *, thrd_start_t, 
 thrd_t	thrd_current(void);
 int	thrd_detach(thrd_t);
 int	thrd_equal(thrd_t, thrd_t);
-void	thrd_exit(int) __dead;
+_Noreturn void	thrd_exit(int);
 int	thrd_join(thrd_t, int *);
 int	thrd_sleep(const struct timespec *, struct timespec *);
 void	thrd_yield(void);

Reply via email to