xref: /illumos-gate/usr/src/lib/libc/inc/libc.h (revision 8fd04b83)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5494a4c51Sraf  * Common Development and Distribution License (the "License").
6494a4c51Sraf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
210ec57554Sraf 
227c478bd9Sstevel@tonic-gate /*
23*8fd04b83SRoger A. Faulkner  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * This is where all the interfaces that are internal to libc
297c478bd9Sstevel@tonic-gate  * which do not have a better home live
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef _LIBC_H
337c478bd9Sstevel@tonic-gate #define	_LIBC_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <thread.h>
367c478bd9Sstevel@tonic-gate #include <stdio.h>
37494a4c51Sraf #include <dirent.h>
387c478bd9Sstevel@tonic-gate #include <ucontext.h>
397c478bd9Sstevel@tonic-gate #include <nsswitch.h>
407c478bd9Sstevel@tonic-gate #include <stddef.h>
417c478bd9Sstevel@tonic-gate #include <poll.h>
427c478bd9Sstevel@tonic-gate #include <sys/dl.h>
437c478bd9Sstevel@tonic-gate #include <sys/door.h>
447c478bd9Sstevel@tonic-gate #include <sys/ieeefp.h>
457c478bd9Sstevel@tonic-gate #include <sys/mount.h>
467c478bd9Sstevel@tonic-gate #include <floatingpoint.h>
477c478bd9Sstevel@tonic-gate #include <nl_types.h>
487c478bd9Sstevel@tonic-gate #include <regex.h>
497c478bd9Sstevel@tonic-gate #include <stdarg.h>
507c478bd9Sstevel@tonic-gate #include <wchar.h>
517c478bd9Sstevel@tonic-gate #include <wctype.h>
52d8ac9b2dSmarks #include <libnvpair.h>
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
557c478bd9Sstevel@tonic-gate extern "C" {
567c478bd9Sstevel@tonic-gate #endif
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate extern void __set_panicstr(const char *);
597c478bd9Sstevel@tonic-gate extern void _rewind_unlocked(FILE *);
607c478bd9Sstevel@tonic-gate extern long _sysconfig(int);
617c478bd9Sstevel@tonic-gate extern int kill(pid_t pid, int sig);
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate extern int primary_link_map;
647c478bd9Sstevel@tonic-gate extern int thr_main(void);
657c478bd9Sstevel@tonic-gate extern int thr_kill(thread_t tid, int sig);
667c478bd9Sstevel@tonic-gate extern thread_t thr_self(void);
677c478bd9Sstevel@tonic-gate extern int mutex_lock(mutex_t *mp);
687c478bd9Sstevel@tonic-gate extern int mutex_unlock(mutex_t *mp);
6998c1a6b4Sraf extern void callout_lock_enter(void);
7098c1a6b4Sraf extern void callout_lock_exit(void);
717c478bd9Sstevel@tonic-gate extern void *lmalloc(size_t);
727c478bd9Sstevel@tonic-gate extern void lfree(void *, size_t);
73d8ac9b2dSmarks extern void libc_nvlist_free(nvlist_t *);
74d8ac9b2dSmarks extern int libc_nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *);
757c478bd9Sstevel@tonic-gate extern void *libc_malloc(size_t);
767c478bd9Sstevel@tonic-gate extern void *libc_realloc(void *, size_t);
777c478bd9Sstevel@tonic-gate extern void libc_free(void *);
787c478bd9Sstevel@tonic-gate extern char *libc_strdup(const char *);
797c478bd9Sstevel@tonic-gate extern int _pollsys(struct pollfd *, nfds_t, const timespec_t *,
807c478bd9Sstevel@tonic-gate 	const sigset_t *);
817c478bd9Sstevel@tonic-gate 
82494a4c51Sraf /*
83494a4c51Sraf  * The private_DIR structure is the same as the DIR structure,
84494a4c51Sraf  * with the addition of a mutex lock for libc's internal use.
85494a4c51Sraf  */
86494a4c51Sraf typedef struct {
87494a4c51Sraf 	DIR	dd_dir;
88494a4c51Sraf 	mutex_t	dd_lock;
89494a4c51Sraf } private_DIR;
90494a4c51Sraf 
917c478bd9Sstevel@tonic-gate #if !defined(_LP64)
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * getdents64 transitional interface is intentionally internal to libc
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate extern int getdents64(int, struct dirent64 *, size_t);
967c478bd9Sstevel@tonic-gate #endif
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate extern int _scrwidth(wchar_t);
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate extern int64_t __div64(int64_t, int64_t);
1017c478bd9Sstevel@tonic-gate extern int64_t __rem64(int64_t, int64_t);
1027c478bd9Sstevel@tonic-gate extern uint64_t __udiv64(uint64_t, uint64_t);
1037c478bd9Sstevel@tonic-gate extern uint64_t __urem64(uint64_t, uint64_t);
1047c478bd9Sstevel@tonic-gate extern int64_t __mul64(int64_t, int64_t);
1057c478bd9Sstevel@tonic-gate extern uint64_t __umul64(uint64_t, uint64_t);
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * Rounding direction functions
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
1127c478bd9Sstevel@tonic-gate extern enum fp_direction_type __xgetRD(void);
1137c478bd9Sstevel@tonic-gate #elif defined(__sparc)
1147c478bd9Sstevel@tonic-gate extern enum fp_direction_type _QgetRD(void);
1157c478bd9Sstevel@tonic-gate #else
1167c478bd9Sstevel@tonic-gate #error Unknown architecture!
1177c478bd9Sstevel@tonic-gate #endif
1187c478bd9Sstevel@tonic-gate 
119*8fd04b83SRoger A. Faulkner /*
120*8fd04b83SRoger A. Faulkner  * defined in open.c
121*8fd04b83SRoger A. Faulkner  */
122*8fd04b83SRoger A. Faulkner extern	int	__open(const char *, int, mode_t);
123*8fd04b83SRoger A. Faulkner extern	int	__open64(const char *, int, mode_t);
124*8fd04b83SRoger A. Faulkner extern	int	__openat(int, const char *, int, mode_t);
125*8fd04b83SRoger A. Faulkner extern	int	__openat64(int, const char *, int, mode_t);
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * defined in hex_bin.c
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate extern void __hex_to_single(decimal_record *, enum fp_direction_type,
1317c478bd9Sstevel@tonic-gate 	single *, fp_exception_field_type *);
1327c478bd9Sstevel@tonic-gate extern void __hex_to_double(decimal_record *, enum fp_direction_type,
1337c478bd9Sstevel@tonic-gate 	double *, fp_exception_field_type *);
1347c478bd9Sstevel@tonic-gate #if defined(__sparc)
1357c478bd9Sstevel@tonic-gate extern void __hex_to_quadruple(decimal_record *, enum fp_direction_type,
1367c478bd9Sstevel@tonic-gate 	quadruple *, fp_exception_field_type *);
1377c478bd9Sstevel@tonic-gate #elif defined(__i386) || defined(__amd64)
1387c478bd9Sstevel@tonic-gate extern void __hex_to_extended(decimal_record *, enum fp_direction_type,
1397c478bd9Sstevel@tonic-gate 	extended *, fp_exception_field_type *);
1407c478bd9Sstevel@tonic-gate #else
1417c478bd9Sstevel@tonic-gate #error Unknown architecture
1427c478bd9Sstevel@tonic-gate #endif
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate /*
1457c478bd9Sstevel@tonic-gate  * defined in ctime.c
1467c478bd9Sstevel@tonic-gate  */
1477c478bd9Sstevel@tonic-gate extern char	*__posix_asctime_r(const struct tm *, char *);
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * Internal routine from fsync.c
1517c478bd9Sstevel@tonic-gate  */
1527c478bd9Sstevel@tonic-gate extern int __fdsync(int, int);	/* 2nd arg may be wrong in 64bit mode */
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * Internal routine from _xregs_clrptr.c
1567c478bd9Sstevel@tonic-gate  */
1577c478bd9Sstevel@tonic-gate extern void _xregs_clrptr(ucontext_t *);
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /*
1607c478bd9Sstevel@tonic-gate  * Internal routine from nfssys.c
1617c478bd9Sstevel@tonic-gate  */
1627c478bd9Sstevel@tonic-gate extern int _nfssys(int, void *); /* int in 64bit mode ???, void * ??? */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * Internal routine from psetsys.c
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate extern int _pset(int, ...); /* int in 64bit mode ??? */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate /*
1707c478bd9Sstevel@tonic-gate  * defined in sigpending.s
1717c478bd9Sstevel@tonic-gate  */
1727c478bd9Sstevel@tonic-gate extern int __sigfillset(sigset_t *);
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate /*
1757c478bd9Sstevel@tonic-gate  * defined in sparc/fp/_Q_set_except.c and i386/fp/exception.c
1767c478bd9Sstevel@tonic-gate  */
1777c478bd9Sstevel@tonic-gate extern int _Q_set_exception(unsigned int);
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate  * defined in nsparse.c
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate extern struct __nsw_switchconfig *_nsw_getoneconfig(const char *name,
1837c478bd9Sstevel@tonic-gate 	char *linep, enum __nsw_parse_err *);
1847c478bd9Sstevel@tonic-gate extern struct __nsw_switchconfig_v1 *_nsw_getoneconfig_v1(const char *name,
1857c478bd9Sstevel@tonic-gate 	char *linep, enum __nsw_parse_err *);
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate  * Internal routine from getusershell.c
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate extern char *getusershell(void);
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate  * defined in _sigaction.s
1947c478bd9Sstevel@tonic-gate  */
1957c478bd9Sstevel@tonic-gate extern int __sigaction(int, const struct sigaction *, struct sigaction *);
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate /*
1987c478bd9Sstevel@tonic-gate  * defined in _getsp.s
1997c478bd9Sstevel@tonic-gate  */
2007c478bd9Sstevel@tonic-gate extern greg_t _getsp(void);
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * defined in _so_setsockopt.s
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate extern int _so_setsockopt(int, int, int, const char *, int);
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate /*
2087c478bd9Sstevel@tonic-gate  * defined in _so_getsockopt.s
2097c478bd9Sstevel@tonic-gate  */
2107c478bd9Sstevel@tonic-gate extern int _so_getsockopt(int, int, int, char *, int *);
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate /*
2137c478bd9Sstevel@tonic-gate  * defined in lsign.s
2147c478bd9Sstevel@tonic-gate  */
2157c478bd9Sstevel@tonic-gate extern int lsign(dl_t);
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * defined in ucontext.s
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate extern int __getcontext(ucontext_t *);
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * defined in door.s
2247c478bd9Sstevel@tonic-gate  */
2257c478bd9Sstevel@tonic-gate extern int __door_info(int, door_info_t *);
2267c478bd9Sstevel@tonic-gate extern int __door_call(int, door_arg_t *);
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate /*
2297c478bd9Sstevel@tonic-gate  * defined in _portfs.s
2307c478bd9Sstevel@tonic-gate  */
2317c478bd9Sstevel@tonic-gate extern int64_t _portfs(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
2327c478bd9Sstevel@tonic-gate     uintptr_t);
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate  * defined in xpg4.c
2367c478bd9Sstevel@tonic-gate  */
237a574db85Sraf extern int __xpg4;		/* global */
238a574db85Sraf extern int libc__xpg4;		/* copy of __xpg4, private to libc */
239a574db85Sraf 
240a574db85Sraf /*
241a574db85Sraf  * defined in xpg6.c
242a574db85Sraf  */
243a574db85Sraf extern uint_t __xpg6;		/* global */
244a574db85Sraf extern uint_t libc__xpg6;	/* copy of __xpg6, private to libc */
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate /*
2477c478bd9Sstevel@tonic-gate  * defined in port/stdio/doscan.c
2487c478bd9Sstevel@tonic-gate  */
2497c478bd9Sstevel@tonic-gate extern int _doscan(FILE *, const char *, va_list);
2507c478bd9Sstevel@tonic-gate extern int __doscan_u(FILE *, const char *, va_list, int);
2517c478bd9Sstevel@tonic-gate extern int __wdoscan_u(FILE *, const wchar_t *, va_list, int);
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate #ifndef _LP64
2547c478bd9Sstevel@tonic-gate /* Flag for _ndoprnt() and _doscan_u() */
2557c478bd9Sstevel@tonic-gate #define	_F_INTMAX32	0x1	/* if set read 4 bytes for u/intmax %j */
2567c478bd9Sstevel@tonic-gate extern int _fprintf_c89(FILE *, const char *, ...);
2577c478bd9Sstevel@tonic-gate extern int _printf_c89(const char *, ...);
2587c478bd9Sstevel@tonic-gate extern int _snprintf_c89(char *, size_t, const char *, ...);
2597c478bd9Sstevel@tonic-gate extern int _sprintf_c89(char *, const char *, ...);
2607c478bd9Sstevel@tonic-gate extern int _wprintf_c89(const wchar_t *, ...);
2617c478bd9Sstevel@tonic-gate extern int _fwprintf_c89(FILE *, const wchar_t *, ...);
2627c478bd9Sstevel@tonic-gate extern int _swprintf_c89(wchar_t *, size_t, const wchar_t *, ...);
2637c478bd9Sstevel@tonic-gate extern int _vfprintf_c89(FILE *, const char *, va_list);
2647c478bd9Sstevel@tonic-gate extern int _vprintf_c89(const char *, va_list);
2657c478bd9Sstevel@tonic-gate extern int _vsnprintf_c89(char *, size_t, const char *, va_list);
2667c478bd9Sstevel@tonic-gate extern int _vsprintf_c89(char *, const char *, va_list);
2677c478bd9Sstevel@tonic-gate extern int _vwprintf_c89(const wchar_t *, va_list);
2687c478bd9Sstevel@tonic-gate extern int _vfwprintf_c89(FILE *, const wchar_t *, va_list);
2697c478bd9Sstevel@tonic-gate extern int _vswprintf_c89(wchar_t *, size_t, const wchar_t *, va_list);
2707c478bd9Sstevel@tonic-gate extern int _scanf_c89(const char *, ...);
2717c478bd9Sstevel@tonic-gate extern int _fscanf_c89(FILE *, const char *, ...);
2727c478bd9Sstevel@tonic-gate extern int _sscanf_c89(const char *, const char *, ...);
2737c478bd9Sstevel@tonic-gate extern int _vscanf_c89(const char *, va_list);
2747c478bd9Sstevel@tonic-gate extern int _vfscanf_c89(FILE *, const char *, va_list);
2757c478bd9Sstevel@tonic-gate extern int _vsscanf_c89(const char *, const char *, va_list);
2767c478bd9Sstevel@tonic-gate extern int _vwscanf_c89(const wchar_t *, va_list);
2777c478bd9Sstevel@tonic-gate extern int _vfwscanf_c89(FILE *, const wchar_t *, va_list);
2787c478bd9Sstevel@tonic-gate extern int _vswscanf_c89(const wchar_t *, const wchar_t *, va_list);
2797c478bd9Sstevel@tonic-gate extern int _wscanf_c89(const wchar_t *, ...);
2807c478bd9Sstevel@tonic-gate extern int _fwscanf_c89(FILE *, const wchar_t *, ...);
2817c478bd9Sstevel@tonic-gate extern int _swscanf_c89(const wchar_t *, const wchar_t *, ...);
2827c478bd9Sstevel@tonic-gate #endif	/*	_LP64	*/
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate /*
2857c478bd9Sstevel@tonic-gate  * defined in port/stdio/popen.c
2867c478bd9Sstevel@tonic-gate  */
2877c478bd9Sstevel@tonic-gate extern int _insert(pid_t pid, int fd);
2887c478bd9Sstevel@tonic-gate extern pid_t _delete(int fd);
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * defined in port/print/doprnt.c
2927c478bd9Sstevel@tonic-gate  */
2937c478bd9Sstevel@tonic-gate extern ssize_t	_wdoprnt(const wchar_t *, va_list, FILE *);
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /*
2967c478bd9Sstevel@tonic-gate  * defined in fgetwc.c
2977c478bd9Sstevel@tonic-gate  */
2987c478bd9Sstevel@tonic-gate extern wint_t _fgetwc_unlocked(FILE *);
2997c478bd9Sstevel@tonic-gate extern wint_t __getwc_xpg5(FILE *);
3007c478bd9Sstevel@tonic-gate extern wint_t __fgetwc_xpg5(FILE *);
3017c478bd9Sstevel@tonic-gate extern wint_t _getwc(FILE *);
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * defined in fputwc.c
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate extern wint_t __putwc_xpg5(wint_t, FILE *);
3077c478bd9Sstevel@tonic-gate extern wint_t _putwc(wint_t, FILE *);
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  * defined in ungetwc.c
3117c478bd9Sstevel@tonic-gate  */
3127c478bd9Sstevel@tonic-gate extern wint_t	__ungetwc_xpg5(wint_t, FILE *);
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3157c478bd9Sstevel@tonic-gate }
3167c478bd9Sstevel@tonic-gate #endif
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate #endif /* _LIBC_H */
319