Source-Changes-HG archive

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

[src/trunk]: src/lib/libc libc: Use RB_TREE_INITIALIZER to nix initfini.c/_en...



details:   https://anonhg.NetBSD.org/src/rev/e5abcb454b38
branches:  trunk
changeset: 377602:e5abcb454b38
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jul 18 11:44:32 2023 +0000

description:
libc: Use RB_TREE_INITIALIZER to nix initfini.c/_env.c coupling.

Doesn't actually help to remove _env.c from programs that don't use
it, though, because various internal things like __diagassert13 still
call getenv.

diffstat:

 lib/libc/misc/initfini.c |   7 ++-----
 lib/libc/stdlib/_env.c   |  14 ++++----------
 2 files changed, 6 insertions(+), 15 deletions(-)

diffs (65 lines):

diff -r b27154e93df8 -r e5abcb454b38 lib/libc/misc/initfini.c
--- a/lib/libc/misc/initfini.c  Tue Jul 18 11:43:21 2023 +0000
+++ b/lib/libc/misc/initfini.c  Tue Jul 18 11:44:32 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: initfini.c,v 1.15 2021/04/20 21:42:32 christos Exp $    */
+/*     $NetBSD: initfini.c,v 1.16 2023/07/18 11:44:32 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: initfini.c,v 1.15 2021/04/20 21:42:32 christos Exp $");
+__RCSID("$NetBSD: initfini.c,v 1.16 2023/07/18 11:44:32 riastradh Exp $");
 
 #ifdef _LIBC
 #include "namespace.h"
@@ -132,7 +132,4 @@ void __section(".text.startup")
 
        /* Initialize the atexit mutexes */
        __libc_atexit_init();
-
-       /* Initialize environment memory RB tree. */
-       __libc_env_init();
 }
diff -r b27154e93df8 -r e5abcb454b38 lib/libc/stdlib/_env.c
--- a/lib/libc/stdlib/_env.c    Tue Jul 18 11:43:21 2023 +0000
+++ b/lib/libc/stdlib/_env.c    Tue Jul 18 11:44:32 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _env.c,v 1.13 2022/03/12 17:31:39 christos Exp $ */
+/*     $NetBSD: _env.c,v 1.14 2023/07/18 11:44:32 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _env.c,v 1.13 2022/03/12 17:31:39 christos Exp $");
+__RCSID("$NetBSD: _env.c,v 1.14 2023/07/18 11:44:32 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -73,7 +73,8 @@ static const rb_tree_ops_t env_tree_ops 
 };
 
 /* The single instance of above tree. */
-static rb_tree_t       env_tree;
+static rb_tree_t       env_tree =
+    RB_TREE_INITIALIZER(env_tree, &env_tree_ops);
 
 /* The allocated environment. */
 static char    **allocated_environ;
@@ -401,10 +402,3 @@ bool
 }
 
 #endif
-
-/* Initialize environment memory RB tree. */
-void __section(".text.startup")
-__libc_env_init(void)
-{
-       rb_tree_init(&env_tree, &env_tree_ops);
-}



Home | Main Index | Thread Index | Old Index