10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53453Sraf * Common Development and Distribution License (the "License"). 63453Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211016Sraf 220Sstevel@tonic-gate /* 23*11798SRoger.Faulkner@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* 280Sstevel@tonic-gate * This is where all the interfaces that are internal to libc 290Sstevel@tonic-gate * which do not have a better home live 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifndef _LIBC_H 330Sstevel@tonic-gate #define _LIBC_H 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <thread.h> 360Sstevel@tonic-gate #include <stdio.h> 373453Sraf #include <dirent.h> 380Sstevel@tonic-gate #include <ucontext.h> 390Sstevel@tonic-gate #include <nsswitch.h> 400Sstevel@tonic-gate #include <stddef.h> 410Sstevel@tonic-gate #include <poll.h> 420Sstevel@tonic-gate #include <sys/dl.h> 430Sstevel@tonic-gate #include <sys/door.h> 440Sstevel@tonic-gate #include <sys/ieeefp.h> 450Sstevel@tonic-gate #include <sys/mount.h> 460Sstevel@tonic-gate #include <floatingpoint.h> 470Sstevel@tonic-gate #include <nl_types.h> 480Sstevel@tonic-gate #include <regex.h> 490Sstevel@tonic-gate #include <stdarg.h> 500Sstevel@tonic-gate #include <wchar.h> 510Sstevel@tonic-gate #include <wctype.h> 526082Smarks #include <libnvpair.h> 530Sstevel@tonic-gate 540Sstevel@tonic-gate #ifdef __cplusplus 550Sstevel@tonic-gate extern "C" { 560Sstevel@tonic-gate #endif 570Sstevel@tonic-gate 580Sstevel@tonic-gate extern void __set_panicstr(const char *); 590Sstevel@tonic-gate extern void _rewind_unlocked(FILE *); 600Sstevel@tonic-gate extern long _sysconfig(int); 610Sstevel@tonic-gate extern int kill(pid_t pid, int sig); 620Sstevel@tonic-gate 630Sstevel@tonic-gate extern int primary_link_map; 640Sstevel@tonic-gate extern int thr_main(void); 650Sstevel@tonic-gate extern int thr_kill(thread_t tid, int sig); 660Sstevel@tonic-gate extern thread_t thr_self(void); 670Sstevel@tonic-gate extern int mutex_lock(mutex_t *mp); 680Sstevel@tonic-gate extern int mutex_unlock(mutex_t *mp); 695002Sraf extern void callout_lock_enter(void); 705002Sraf extern void callout_lock_exit(void); 710Sstevel@tonic-gate extern void *lmalloc(size_t); 720Sstevel@tonic-gate extern void lfree(void *, size_t); 736082Smarks extern void libc_nvlist_free(nvlist_t *); 746082Smarks extern int libc_nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *); 750Sstevel@tonic-gate extern void *libc_malloc(size_t); 760Sstevel@tonic-gate extern void *libc_realloc(void *, size_t); 770Sstevel@tonic-gate extern void libc_free(void *); 780Sstevel@tonic-gate extern char *libc_strdup(const char *); 790Sstevel@tonic-gate extern int _pollsys(struct pollfd *, nfds_t, const timespec_t *, 800Sstevel@tonic-gate const sigset_t *); 810Sstevel@tonic-gate 823453Sraf /* 833453Sraf * The private_DIR structure is the same as the DIR structure, 843453Sraf * with the addition of a mutex lock for libc's internal use. 853453Sraf */ 863453Sraf typedef struct { 873453Sraf DIR dd_dir; 883453Sraf mutex_t dd_lock; 893453Sraf } private_DIR; 903453Sraf 910Sstevel@tonic-gate #if !defined(_LP64) 920Sstevel@tonic-gate /* 930Sstevel@tonic-gate * getdents64 transitional interface is intentionally internal to libc 940Sstevel@tonic-gate */ 950Sstevel@tonic-gate extern int getdents64(int, struct dirent64 *, size_t); 960Sstevel@tonic-gate #endif 970Sstevel@tonic-gate 980Sstevel@tonic-gate extern int _scrwidth(wchar_t); 990Sstevel@tonic-gate 1000Sstevel@tonic-gate extern int64_t __div64(int64_t, int64_t); 1010Sstevel@tonic-gate extern int64_t __rem64(int64_t, int64_t); 1020Sstevel@tonic-gate extern uint64_t __udiv64(uint64_t, uint64_t); 1030Sstevel@tonic-gate extern uint64_t __urem64(uint64_t, uint64_t); 1040Sstevel@tonic-gate extern int64_t __mul64(int64_t, int64_t); 1050Sstevel@tonic-gate extern uint64_t __umul64(uint64_t, uint64_t); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* 1090Sstevel@tonic-gate * Rounding direction functions 1100Sstevel@tonic-gate */ 1110Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 1120Sstevel@tonic-gate extern enum fp_direction_type __xgetRD(void); 1130Sstevel@tonic-gate #elif defined(__sparc) 1140Sstevel@tonic-gate extern enum fp_direction_type _QgetRD(void); 1150Sstevel@tonic-gate #else 1160Sstevel@tonic-gate #error Unknown architecture! 1170Sstevel@tonic-gate #endif 1180Sstevel@tonic-gate 119*11798SRoger.Faulkner@Sun.COM /* 120*11798SRoger.Faulkner@Sun.COM * defined in open.c 121*11798SRoger.Faulkner@Sun.COM */ 122*11798SRoger.Faulkner@Sun.COM extern int __open(const char *, int, mode_t); 123*11798SRoger.Faulkner@Sun.COM extern int __open64(const char *, int, mode_t); 124*11798SRoger.Faulkner@Sun.COM extern int __openat(int, const char *, int, mode_t); 125*11798SRoger.Faulkner@Sun.COM extern int __openat64(int, const char *, int, mode_t); 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate /* 1280Sstevel@tonic-gate * defined in hex_bin.c 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate extern void __hex_to_single(decimal_record *, enum fp_direction_type, 1310Sstevel@tonic-gate single *, fp_exception_field_type *); 1320Sstevel@tonic-gate extern void __hex_to_double(decimal_record *, enum fp_direction_type, 1330Sstevel@tonic-gate double *, fp_exception_field_type *); 1340Sstevel@tonic-gate #if defined(__sparc) 1350Sstevel@tonic-gate extern void __hex_to_quadruple(decimal_record *, enum fp_direction_type, 1360Sstevel@tonic-gate quadruple *, fp_exception_field_type *); 1370Sstevel@tonic-gate #elif defined(__i386) || defined(__amd64) 1380Sstevel@tonic-gate extern void __hex_to_extended(decimal_record *, enum fp_direction_type, 1390Sstevel@tonic-gate extended *, fp_exception_field_type *); 1400Sstevel@tonic-gate #else 1410Sstevel@tonic-gate #error Unknown architecture 1420Sstevel@tonic-gate #endif 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate /* 1450Sstevel@tonic-gate * defined in ctime.c 1460Sstevel@tonic-gate */ 1470Sstevel@tonic-gate extern char *__posix_asctime_r(const struct tm *, char *); 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate /* 1500Sstevel@tonic-gate * Internal routine from fsync.c 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate extern int __fdsync(int, int); /* 2nd arg may be wrong in 64bit mode */ 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate /* 1550Sstevel@tonic-gate * Internal routine from _xregs_clrptr.c 1560Sstevel@tonic-gate */ 1570Sstevel@tonic-gate extern void _xregs_clrptr(ucontext_t *); 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * Internal routine from nfssys.c 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate extern int _nfssys(int, void *); /* int in 64bit mode ???, void * ??? */ 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * Internal routine from psetsys.c 1660Sstevel@tonic-gate */ 1670Sstevel@tonic-gate extern int _pset(int, ...); /* int in 64bit mode ??? */ 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate /* 1700Sstevel@tonic-gate * defined in sigpending.s 1710Sstevel@tonic-gate */ 1720Sstevel@tonic-gate extern int __sigfillset(sigset_t *); 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* 1750Sstevel@tonic-gate * defined in sparc/fp/_Q_set_except.c and i386/fp/exception.c 1760Sstevel@tonic-gate */ 1770Sstevel@tonic-gate extern int _Q_set_exception(unsigned int); 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate /* 1800Sstevel@tonic-gate * defined in nsparse.c 1810Sstevel@tonic-gate */ 1820Sstevel@tonic-gate extern struct __nsw_switchconfig *_nsw_getoneconfig(const char *name, 1830Sstevel@tonic-gate char *linep, enum __nsw_parse_err *); 1840Sstevel@tonic-gate extern struct __nsw_switchconfig_v1 *_nsw_getoneconfig_v1(const char *name, 1850Sstevel@tonic-gate char *linep, enum __nsw_parse_err *); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * Internal routine from getusershell.c 1890Sstevel@tonic-gate */ 1900Sstevel@tonic-gate extern char *getusershell(void); 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate /* 1930Sstevel@tonic-gate * defined in _sigaction.s 1940Sstevel@tonic-gate */ 1950Sstevel@tonic-gate extern int __sigaction(int, const struct sigaction *, struct sigaction *); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate /* 1980Sstevel@tonic-gate * defined in _getsp.s 1990Sstevel@tonic-gate */ 2000Sstevel@tonic-gate extern greg_t _getsp(void); 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * defined in _so_setsockopt.s 2040Sstevel@tonic-gate */ 2050Sstevel@tonic-gate extern int _so_setsockopt(int, int, int, const char *, int); 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate /* 2080Sstevel@tonic-gate * defined in _so_getsockopt.s 2090Sstevel@tonic-gate */ 2100Sstevel@tonic-gate extern int _so_getsockopt(int, int, int, char *, int *); 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate /* 2130Sstevel@tonic-gate * defined in lsign.s 2140Sstevel@tonic-gate */ 2150Sstevel@tonic-gate extern int lsign(dl_t); 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate /* 2180Sstevel@tonic-gate * defined in ucontext.s 2190Sstevel@tonic-gate */ 2200Sstevel@tonic-gate extern int __getcontext(ucontext_t *); 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate /* 2230Sstevel@tonic-gate * defined in door.s 2240Sstevel@tonic-gate */ 2250Sstevel@tonic-gate extern int __door_info(int, door_info_t *); 2260Sstevel@tonic-gate extern int __door_call(int, door_arg_t *); 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * defined in _portfs.s 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate extern int64_t _portfs(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t, 2320Sstevel@tonic-gate uintptr_t); 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate /* 2350Sstevel@tonic-gate * defined in xpg4.c 2360Sstevel@tonic-gate */ 2375891Sraf extern int __xpg4; /* global */ 2385891Sraf extern int libc__xpg4; /* copy of __xpg4, private to libc */ 2395891Sraf 2405891Sraf /* 2415891Sraf * defined in xpg6.c 2425891Sraf */ 2435891Sraf extern uint_t __xpg6; /* global */ 2445891Sraf extern uint_t libc__xpg6; /* copy of __xpg6, private to libc */ 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate /* 2470Sstevel@tonic-gate * defined in port/stdio/doscan.c 2480Sstevel@tonic-gate */ 2490Sstevel@tonic-gate extern int _doscan(FILE *, const char *, va_list); 2500Sstevel@tonic-gate extern int __doscan_u(FILE *, const char *, va_list, int); 2510Sstevel@tonic-gate extern int __wdoscan_u(FILE *, const wchar_t *, va_list, int); 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate #ifndef _LP64 2540Sstevel@tonic-gate /* Flag for _ndoprnt() and _doscan_u() */ 2550Sstevel@tonic-gate #define _F_INTMAX32 0x1 /* if set read 4 bytes for u/intmax %j */ 2560Sstevel@tonic-gate extern int _fprintf_c89(FILE *, const char *, ...); 2570Sstevel@tonic-gate extern int _printf_c89(const char *, ...); 2580Sstevel@tonic-gate extern int _snprintf_c89(char *, size_t, const char *, ...); 2590Sstevel@tonic-gate extern int _sprintf_c89(char *, const char *, ...); 2600Sstevel@tonic-gate extern int _wprintf_c89(const wchar_t *, ...); 2610Sstevel@tonic-gate extern int _fwprintf_c89(FILE *, const wchar_t *, ...); 2620Sstevel@tonic-gate extern int _swprintf_c89(wchar_t *, size_t, const wchar_t *, ...); 2630Sstevel@tonic-gate extern int _vfprintf_c89(FILE *, const char *, va_list); 2640Sstevel@tonic-gate extern int _vprintf_c89(const char *, va_list); 2650Sstevel@tonic-gate extern int _vsnprintf_c89(char *, size_t, const char *, va_list); 2660Sstevel@tonic-gate extern int _vsprintf_c89(char *, const char *, va_list); 2670Sstevel@tonic-gate extern int _vwprintf_c89(const wchar_t *, va_list); 2680Sstevel@tonic-gate extern int _vfwprintf_c89(FILE *, const wchar_t *, va_list); 2690Sstevel@tonic-gate extern int _vswprintf_c89(wchar_t *, size_t, const wchar_t *, va_list); 2700Sstevel@tonic-gate extern int _scanf_c89(const char *, ...); 2710Sstevel@tonic-gate extern int _fscanf_c89(FILE *, const char *, ...); 2720Sstevel@tonic-gate extern int _sscanf_c89(const char *, const char *, ...); 2730Sstevel@tonic-gate extern int _vscanf_c89(const char *, va_list); 2740Sstevel@tonic-gate extern int _vfscanf_c89(FILE *, const char *, va_list); 2750Sstevel@tonic-gate extern int _vsscanf_c89(const char *, const char *, va_list); 2760Sstevel@tonic-gate extern int _vwscanf_c89(const wchar_t *, va_list); 2770Sstevel@tonic-gate extern int _vfwscanf_c89(FILE *, const wchar_t *, va_list); 2780Sstevel@tonic-gate extern int _vswscanf_c89(const wchar_t *, const wchar_t *, va_list); 2790Sstevel@tonic-gate extern int _wscanf_c89(const wchar_t *, ...); 2800Sstevel@tonic-gate extern int _fwscanf_c89(FILE *, const wchar_t *, ...); 2810Sstevel@tonic-gate extern int _swscanf_c89(const wchar_t *, const wchar_t *, ...); 2820Sstevel@tonic-gate #endif /* _LP64 */ 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate /* 2850Sstevel@tonic-gate * defined in port/stdio/popen.c 2860Sstevel@tonic-gate */ 2870Sstevel@tonic-gate extern int _insert(pid_t pid, int fd); 2880Sstevel@tonic-gate extern pid_t _delete(int fd); 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate /* 2910Sstevel@tonic-gate * defined in port/print/doprnt.c 2920Sstevel@tonic-gate */ 2930Sstevel@tonic-gate extern ssize_t _wdoprnt(const wchar_t *, va_list, FILE *); 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * defined in fgetwc.c 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate extern wint_t _fgetwc_unlocked(FILE *); 2990Sstevel@tonic-gate extern wint_t __getwc_xpg5(FILE *); 3000Sstevel@tonic-gate extern wint_t __fgetwc_xpg5(FILE *); 3010Sstevel@tonic-gate extern wint_t _getwc(FILE *); 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * defined in fputwc.c 3050Sstevel@tonic-gate */ 3060Sstevel@tonic-gate extern wint_t __putwc_xpg5(wint_t, FILE *); 3070Sstevel@tonic-gate extern wint_t _putwc(wint_t, FILE *); 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate /* 3100Sstevel@tonic-gate * defined in ungetwc.c 3110Sstevel@tonic-gate */ 3120Sstevel@tonic-gate extern wint_t __ungetwc_xpg5(wint_t, FILE *); 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate #ifdef __cplusplus 3150Sstevel@tonic-gate } 3160Sstevel@tonic-gate #endif 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate #endif /* _LIBC_H */ 319