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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
38 /* these are private to the library */
39 extern int primary_link_map
;
40 extern void lmutex_lock(mutex_t
*);
41 extern void lmutex_unlock(mutex_t
*);
42 extern void lrw_rdlock(rwlock_t
*);
43 extern void lrw_wrlock(rwlock_t
*);
44 extern void lrw_unlock(rwlock_t
*);
45 extern void sig_mutex_lock(mutex_t
*);
46 extern void sig_mutex_unlock(mutex_t
*);
47 extern int sig_mutex_trylock(mutex_t
*);
48 extern int sig_cond_wait(cond_t
*, mutex_t
*);
49 extern int sig_cond_reltimedwait(cond_t
*, mutex_t
*, const timespec_t
*);
50 extern void cancel_safe_mutex_lock(mutex_t
*);
51 extern void cancel_safe_mutex_unlock(mutex_t
*);
52 extern int cancel_safe_mutex_trylock(mutex_t
*);
53 extern int cancel_active(void);
54 extern int _thrp_cancelled(void);
56 /* the private libc thread-safe allocator */
57 extern void *lmalloc(size_t);
58 extern void lfree(void *, size_t);
60 #if defined(THREAD_DEBUG)
61 extern void assert_no_libc_locks_held(void);
63 #define assert_no_libc_locks_held()
66 #define _FWRITE _fwrite_unlocked
67 #define FILENO(s) _fileno(s)
68 #define FERROR(s) ferror(s)
69 #define GETC(s) _getc_unlocked(s)
70 #define UNGETC(c, s) _ungetc_unlocked(c, s)
71 #define PUTC(c, s) _putc_unlocked(c, s)
72 #define GETWC(s) getwc(s)
73 #define PUTWC(c, s) putwc(c, s)
76 * Cheap check to tell if stdio needs to lock for MT progs.
77 * Referenced directly in port/stdio/flush.c and FLOCKFILE and
78 * FUNLOCKFILE macros. __libc_threaded gets set to 1 when the first
79 * thread (beyond the main thread) is created in _thrp_create().
81 extern int __libc_threaded
;
83 #define FILELOCKING(iop) (GET_IONOLOCK(iop) == 0)
85 #define FLOCKFILE(lk, iop) \
87 if (__libc_threaded && FILELOCKING(iop)) \
88 lk = _flockget((iop)); \
93 #define FUNLOCKFILE(lk) \
99 #define FLOCKRETURN(iop, ret) \
102 FLOCKFILE(lk, iop); \
112 #endif /* _MTLIB_H */