Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Introduce minor changes to the C11 threading ...



details:   https://anonhg.NetBSD.org/src/rev/3a41ec6ad0e4
branches:  trunk
changeset: 998638:3a41ec6ad0e4
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Apr 24 18:47:54 2019 +0000

description:
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.

diffstat:

 lib/libpthread/thrd.3    |  12 ++----------
 lib/libpthread/thrd.c    |   6 +++---
 lib/libpthread/threads.h |   6 +++---
 3 files changed, 8 insertions(+), 16 deletions(-)

diffs (87 lines):

diff -r 03cdd38dc3b0 -r 3a41ec6ad0e4 lib/libpthread/thrd.3
--- a/lib/libpthread/thrd.3     Wed Apr 24 18:45:15 2019 +0000
+++ b/lib/libpthread/thrd.3     Wed Apr 24 18:47:54 2019 +0000
@@ -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 @@
 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
diff -r 03cdd38dc3b0 -r 3a41ec6ad0e4 lib/libpthread/thrd.c
--- a/lib/libpthread/thrd.c     Wed Apr 24 18:45:15 2019 +0000
+++ b/lib/libpthread/thrd.c     Wed Apr 24 18:47:54 2019 +0000
@@ -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 @@
        return pthread_equal(t1, t2);
 }
 
-__dead void
+_Noreturn void
 thrd_exit(int res)
 {
 
diff -r 03cdd38dc3b0 -r 3a41ec6ad0e4 lib/libpthread/threads.h
--- a/lib/libpthread/threads.h  Wed Apr 24 18:45:15 2019 +0000
+++ b/lib/libpthread/threads.h  Wed Apr 24 18:47:54 2019 +0000
@@ -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 @@
 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);



Home | Main Index | Thread Index | Old Index