6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libc / port / gen / sh_locks.c
blob6583efbc9c93d76f63df95310c219f2c63c86307
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "lint.h"
30 #include <mtlib.h>
31 #include <sys/types.h>
32 #include <synch.h>
33 #include <thread.h>
34 #include <pthread.h>
35 #include "libc.h"
38 * fork1-safety.
39 * These three routines were used to make some libc interfaces fork1-safe.
40 * With the merge of libthread into libc, almost all libc internal-only
41 * locks are acquired via lmutex_lock() or lrw_rdlock()/lrw_wrlock(),
42 * which makes them automatically fork1-safe (as well as async-signal
43 * safe), so these functions are now used only for the locks that cannot
44 * be used with lmutex_lock or lrw_rdlock()/lrw_wrlock().
47 extern void atexit_locks(void);
48 extern void atexit_unlocks(void);
50 extern void stdio_locks(void);
51 extern void stdio_unlocks(void);
53 extern void malloc_locks(void);
54 extern void malloc_unlocks(void);
56 static void
57 libc_prepare_atfork(void)
59 atexit_locks();
60 stdio_locks();
61 malloc_locks();
64 static void
65 libc_child_atfork(void)
67 malloc_unlocks();
68 stdio_unlocks();
69 atexit_unlocks();
72 static void
73 libc_parent_atfork(void)
75 malloc_unlocks();
76 stdio_unlocks();
77 atexit_unlocks();
80 /* called from libc_init() */
81 void
82 atfork_init(void)
84 (void) pthread_atfork(libc_prepare_atfork,
85 libc_parent_atfork, libc_child_atfork);