Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread libpthread: Move namespacing include to top o...



details:   https://anonhg.NetBSD.org/src/rev/936d89f6bc37
branches:  trunk
changeset: 361150:936d89f6bc37
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 12 14:59:32 2022 +0000

description:
libpthread: Move namespacing include to top of .c files.

Stuff like libc's namespace.h, or atomic_op_namespace.h, which does
namespacing tricks like `#define atomic_cas_uint _atomic_cas_uint',
has to go at the top of each .c file.  If it goes in the middle, it
might be too late to affect the declarations, and result in compile
errors.

I tripped over this by including <sys/atomic.h> in mips
<machine/lock.h>.

(Maybe we should create a new pthread_namespace.h file for the
purpose, but this'll do for now.)

diffstat:

 lib/libpthread/pthread.c                |  7 +++++--
 lib/libpthread/pthread_attr.c           |  7 +++++--
 lib/libpthread/pthread_barrier.c        |  7 +++++--
 lib/libpthread/pthread_cancelstub.c     |  7 +++++--
 lib/libpthread/pthread_compat.c         |  7 +++++--
 lib/libpthread/pthread_cond.c           |  7 +++++--
 lib/libpthread/pthread_getcpuclockid.c  |  7 +++++--
 lib/libpthread/pthread_int.h            |  5 +----
 lib/libpthread/pthread_lock.c           |  7 +++++--
 lib/libpthread/pthread_makelwp_netbsd.c |  7 +++++--
 lib/libpthread/pthread_misc.c           |  7 +++++--
 lib/libpthread/pthread_mutex.c          |  7 +++++--
 lib/libpthread/pthread_once.c           |  7 +++++--
 lib/libpthread/pthread_rwlock.c         |  7 +++++--
 lib/libpthread/pthread_specific.c       |  7 +++++--
 lib/libpthread/pthread_spin.c           |  7 +++++--
 lib/libpthread/pthread_tsd.c            |  7 +++++--
 lib/libpthread/res_state.c              |  7 +++++--
 18 files changed, 86 insertions(+), 38 deletions(-)

diffs (truncated from 383 to 300 lines):

diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c  Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread.c  Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread.c,v 1.179 2021/04/13 00:31:54 mrg Exp $        */
+/*     $NetBSD: pthread.c,v 1.180 2022/02/12 14:59:32 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -31,10 +31,13 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.179 2021/04/13 00:31:54 mrg Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.180 2022/02/12 14:59:32 riastradh Exp $");
 
 #define        __EXPOSE_STACK  1
 
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
+
 #include <sys/param.h>
 #include <sys/exec_elf.h>
 #include <sys/mman.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_attr.c
--- a/lib/libpthread/pthread_attr.c     Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_attr.c     Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_attr.c,v 1.19 2020/01/29 13:47:31 kamil Exp $  */
+/*     $NetBSD: pthread_attr.c,v 1.20 2022/02/12 14:59:32 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_attr.c,v 1.19 2020/01/29 13:47:31 kamil Exp $");
+__RCSID("$NetBSD: pthread_attr.c,v 1.20 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <errno.h>
 #include <stdio.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_barrier.c
--- a/lib/libpthread/pthread_barrier.c  Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_barrier.c  Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_barrier.c,v 1.22 2020/05/16 22:53:37 ad Exp $  */
+/*     $NetBSD: pthread_barrier.c,v 1.23 2022/02/12 14:59:32 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2001, 2003, 2006, 2007, 2009, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_barrier.c,v 1.22 2020/05/16 22:53:37 ad Exp $");
+__RCSID("$NetBSD: pthread_barrier.c,v 1.23 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <errno.h>
 
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_cancelstub.c
--- a/lib/libpthread/pthread_cancelstub.c       Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_cancelstub.c       Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cancelstub.c,v 1.40 2021/10/01 20:13:38 christos Exp $ */
+/*     $NetBSD: pthread_cancelstub.c,v 1.41 2022/02/12 14:59:32 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -33,7 +33,10 @@
 #undef _FORTIFY_SOURCE
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cancelstub.c,v 1.40 2021/10/01 20:13:38 christos Exp $");
+__RCSID("$NetBSD: pthread_cancelstub.c,v 1.41 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #ifndef lint
 
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_compat.c
--- a/lib/libpthread/pthread_compat.c   Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_compat.c   Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_compat.c,v 1.6 2017/12/08 09:59:26 kre Exp $   */
+/*     $NetBSD: pthread_compat.c,v 1.7 2022/02/12 14:59:32 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_compat.c,v 1.6 2017/12/08 09:59:26 kre Exp $");
+__RCSID("$NetBSD: pthread_compat.c,v 1.7 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <sys/param.h>
 #include <sys/syscall.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c     Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_cond.c     Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cond.c,v 1.76 2020/06/14 21:33:28 ad Exp $     */
+/*     $NetBSD: pthread_cond.c,v 1.77 2022/02/12 14:59:32 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cond.c,v 1.76 2020/06/14 21:33:28 ad Exp $");
+__RCSID("$NetBSD: pthread_cond.c,v 1.77 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <stdlib.h>
 #include <errno.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_getcpuclockid.c
--- a/lib/libpthread/pthread_getcpuclockid.c    Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_getcpuclockid.c    Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_getcpuclockid.c,v 1.3 2020/01/29 16:03:44 kamil Exp $  */
+/*     $NetBSD: pthread_getcpuclockid.c,v 1.4 2022/02/12 14:59:32 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,9 +30,12 @@
  */
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pthread_getcpuclockid.c,v 1.3 2020/01/29 16:03:44 kamil Exp $");
+__RCSID("$NetBSD: pthread_getcpuclockid.c,v 1.4 2022/02/12 14:59:32 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
+
 #include <sys/types.h>
 #include <errno.h>
 #include <pthread.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_int.h
--- a/lib/libpthread/pthread_int.h      Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_int.h      Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_int.h,v 1.107 2020/06/10 22:45:15 ad Exp $     */
+/*     $NetBSD: pthread_int.h,v 1.108 2022/02/12 14:59:32 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -41,9 +41,6 @@
 #include "pthread_queue.h"
 #include "pthread_md.h"
 
-/* Need to use libc-private names for atomic operations. */
-#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
-
 #include <sys/atomic.h>
 #include <sys/rbtree.h>
 #include <sys/param.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_lock.c
--- a/lib/libpthread/pthread_lock.c     Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_lock.c     Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_lock.c,v 1.34 2008/04/28 20:23:01 martin Exp $ */
+/*     $NetBSD: pthread_lock.c,v 1.35 2022/02/12 14:59:32 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc.
@@ -34,7 +34,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_lock.c,v 1.34 2008/04/28 20:23:01 martin Exp $");
+__RCSID("$NetBSD: pthread_lock.c,v 1.35 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <sys/types.h>
 #include <sys/ras.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_makelwp_netbsd.c
--- a/lib/libpthread/pthread_makelwp_netbsd.c   Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_makelwp_netbsd.c   Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_makelwp_netbsd.c,v 1.2 2014/12/17 01:49:08 pooka Exp $ */
+/*     $NetBSD: pthread_makelwp_netbsd.c,v 1.3 2022/02/12 14:59:32 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_makelwp_netbsd.c,v 1.2 2014/12/17 01:49:08 pooka Exp $");
+__RCSID("$NetBSD: pthread_makelwp_netbsd.c,v 1.3 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <sys/param.h>
 
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_misc.c
--- a/lib/libpthread/pthread_misc.c     Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_misc.c     Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_misc.c,v 1.17 2020/01/29 16:34:09 kamil Exp $  */
+/*     $NetBSD: pthread_misc.c,v 1.18 2022/02/12 14:59:32 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_misc.c,v 1.17 2020/01/29 16:34:09 kamil Exp $");
+__RCSID("$NetBSD: pthread_misc.c,v 1.18 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <errno.h>
 #include <string.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c    Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_mutex.c    Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_mutex.c,v 1.81 2020/06/11 18:41:22 ad Exp $    */
+/*     $NetBSD: pthread_mutex.c,v 1.82 2022/02/12 14:59:32 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2001, 2003, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -47,7 +47,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_mutex.c,v 1.81 2020/06/11 18:41:22 ad Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.82 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <sys/types.h>
 #include <sys/lwpctl.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_once.c
--- a/lib/libpthread/pthread_once.c     Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_once.c     Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_once.c,v 1.3 2013/03/21 16:49:12 christos Exp $        */
+/*     $NetBSD: pthread_once.c,v 1.4 2022/02/12 14:59:32 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_once.c,v 1.3 2013/03/21 16:49:12 christos Exp $");
+__RCSID("$NetBSD: pthread_once.c,v 1.4 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include "pthread.h"
 #include "pthread_int.h"
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_rwlock.c
--- a/lib/libpthread/pthread_rwlock.c   Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_rwlock.c   Sat Feb 12 14:59:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_rwlock.c,v 1.43 2022/02/11 21:40:58 riastradh Exp $ */
+/*     $NetBSD: pthread_rwlock.c,v 1.44 2022/02/12 14:59:32 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,10 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_rwlock.c,v 1.43 2022/02/11 21:40:58 riastradh Exp $");
+__RCSID("$NetBSD: pthread_rwlock.c,v 1.44 2022/02/12 14:59:32 riastradh Exp $");
+
+/* Need to use libc-private names for atomic operations. */
+#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <sys/types.h>
 #include <sys/lwpctl.h>
diff -r e9a73983ede3 -r 936d89f6bc37 lib/libpthread/pthread_specific.c
--- a/lib/libpthread/pthread_specific.c Sat Feb 12 13:38:29 2022 +0000
+++ b/lib/libpthread/pthread_specific.c Sat Feb 12 14:59:32 2022 +0000



Home | Main Index | Thread Index | Old Index