1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* 28*0Sstevel@tonic-gate * This is where all the interfaces that are internal to libc 29*0Sstevel@tonic-gate * which do not have a better home live 30*0Sstevel@tonic-gate */ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifndef _LIBC_H 33*0Sstevel@tonic-gate #define _LIBC_H 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include <thread.h> 38*0Sstevel@tonic-gate #include <stdio.h> 39*0Sstevel@tonic-gate #include <sys/dirent.h> 40*0Sstevel@tonic-gate #include <ucontext.h> 41*0Sstevel@tonic-gate #include <nsswitch.h> 42*0Sstevel@tonic-gate #include <stddef.h> 43*0Sstevel@tonic-gate #include <poll.h> 44*0Sstevel@tonic-gate #include <sys/dl.h> 45*0Sstevel@tonic-gate #include <sys/door.h> 46*0Sstevel@tonic-gate #include <sys/ieeefp.h> 47*0Sstevel@tonic-gate #include <sys/mount.h> 48*0Sstevel@tonic-gate #include <floatingpoint.h> 49*0Sstevel@tonic-gate #include <nl_types.h> 50*0Sstevel@tonic-gate #include <regex.h> 51*0Sstevel@tonic-gate #include <stdarg.h> 52*0Sstevel@tonic-gate #include <wchar.h> 53*0Sstevel@tonic-gate #include <wctype.h> 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #ifdef __cplusplus 56*0Sstevel@tonic-gate extern "C" { 57*0Sstevel@tonic-gate #endif 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate extern void __set_panicstr(const char *); 60*0Sstevel@tonic-gate extern void _rewind_unlocked(FILE *); 61*0Sstevel@tonic-gate extern int _rename(const char *, const char *); 62*0Sstevel@tonic-gate extern long _sysconfig(int); 63*0Sstevel@tonic-gate extern int kill(pid_t pid, int sig); 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate extern int primary_link_map; 66*0Sstevel@tonic-gate extern int thr_main(void); 67*0Sstevel@tonic-gate extern int thr_kill(thread_t tid, int sig); 68*0Sstevel@tonic-gate extern thread_t thr_self(void); 69*0Sstevel@tonic-gate extern int mutex_lock(mutex_t *mp); 70*0Sstevel@tonic-gate extern int mutex_unlock(mutex_t *mp); 71*0Sstevel@tonic-gate extern int fork_lock_enter(const char *); 72*0Sstevel@tonic-gate extern void fork_lock_exit(void); 73*0Sstevel@tonic-gate extern void *lmalloc(size_t); 74*0Sstevel@tonic-gate extern void lfree(void *, size_t); 75*0Sstevel@tonic-gate extern void *libc_malloc(size_t); 76*0Sstevel@tonic-gate extern void *libc_realloc(void *, size_t); 77*0Sstevel@tonic-gate extern void libc_free(void *); 78*0Sstevel@tonic-gate extern char *libc_strdup(const char *); 79*0Sstevel@tonic-gate extern int _sigwait(sigset_t *); 80*0Sstevel@tonic-gate extern int _thr_getspecific(thread_key_t key, void **valuep); 81*0Sstevel@tonic-gate extern int _thr_setspecific(unsigned int key, void *value); 82*0Sstevel@tonic-gate extern int _thr_keycreate(thread_key_t *pkey, void (*destructor)(void *)); 83*0Sstevel@tonic-gate extern void *_pthread_getspecific(thread_key_t); 84*0Sstevel@tonic-gate extern int _pollsys(struct pollfd *, nfds_t, const timespec_t *, 85*0Sstevel@tonic-gate const sigset_t *); 86*0Sstevel@tonic-gate extern void _private_testcancel(void); 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate #if !defined(_LP64) 89*0Sstevel@tonic-gate /* 90*0Sstevel@tonic-gate * getdents64 transitional interface is intentionally internal to libc 91*0Sstevel@tonic-gate */ 92*0Sstevel@tonic-gate extern int getdents64(int, struct dirent64 *, size_t); 93*0Sstevel@tonic-gate #endif 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate extern int _scrwidth(wchar_t); 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate extern int64_t __div64(int64_t, int64_t); 98*0Sstevel@tonic-gate extern int64_t __rem64(int64_t, int64_t); 99*0Sstevel@tonic-gate extern uint64_t __udiv64(uint64_t, uint64_t); 100*0Sstevel@tonic-gate extern uint64_t __urem64(uint64_t, uint64_t); 101*0Sstevel@tonic-gate extern uint64_t _umul32x32to64(uint32_t, uint32_t); 102*0Sstevel@tonic-gate extern int64_t __mul64(int64_t, int64_t); 103*0Sstevel@tonic-gate extern uint64_t __umul64(uint64_t, uint64_t); 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate /* 107*0Sstevel@tonic-gate * Rounding direction functions 108*0Sstevel@tonic-gate */ 109*0Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 110*0Sstevel@tonic-gate extern enum fp_direction_type __xgetRD(void); 111*0Sstevel@tonic-gate #elif defined(__sparc) 112*0Sstevel@tonic-gate extern enum fp_direction_type _QgetRD(void); 113*0Sstevel@tonic-gate #else 114*0Sstevel@tonic-gate #error Unknown architecture! 115*0Sstevel@tonic-gate #endif 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * defined in hex_bin.c 120*0Sstevel@tonic-gate */ 121*0Sstevel@tonic-gate extern void __hex_to_single(decimal_record *, enum fp_direction_type, 122*0Sstevel@tonic-gate single *, fp_exception_field_type *); 123*0Sstevel@tonic-gate extern void __hex_to_double(decimal_record *, enum fp_direction_type, 124*0Sstevel@tonic-gate double *, fp_exception_field_type *); 125*0Sstevel@tonic-gate #if defined(__sparc) 126*0Sstevel@tonic-gate extern void __hex_to_quadruple(decimal_record *, enum fp_direction_type, 127*0Sstevel@tonic-gate quadruple *, fp_exception_field_type *); 128*0Sstevel@tonic-gate #elif defined(__i386) || defined(__amd64) 129*0Sstevel@tonic-gate extern void __hex_to_extended(decimal_record *, enum fp_direction_type, 130*0Sstevel@tonic-gate extended *, fp_exception_field_type *); 131*0Sstevel@tonic-gate #else 132*0Sstevel@tonic-gate #error Unknown architecture 133*0Sstevel@tonic-gate #endif 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate /* 136*0Sstevel@tonic-gate * defined in ctime.c 137*0Sstevel@tonic-gate */ 138*0Sstevel@tonic-gate extern char *__posix_asctime_r(const struct tm *, char *); 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate /* 141*0Sstevel@tonic-gate * Internal routine from fsync.c 142*0Sstevel@tonic-gate */ 143*0Sstevel@tonic-gate extern int __fdsync(int, int); /* 2nd arg may be wrong in 64bit mode */ 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate /* 146*0Sstevel@tonic-gate * Internal routine from _xregs_clrptr.c 147*0Sstevel@tonic-gate */ 148*0Sstevel@tonic-gate extern void _xregs_clrptr(ucontext_t *); 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate /* 151*0Sstevel@tonic-gate * Internal routine from nfssys.c 152*0Sstevel@tonic-gate */ 153*0Sstevel@tonic-gate extern int _nfssys(int, void *); /* int in 64bit mode ???, void * ??? */ 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate /* 156*0Sstevel@tonic-gate * Internal routine from psetsys.c 157*0Sstevel@tonic-gate */ 158*0Sstevel@tonic-gate extern int _pset(int, ...); /* int in 64bit mode ??? */ 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate /* 161*0Sstevel@tonic-gate * defined in sigpending.s 162*0Sstevel@tonic-gate */ 163*0Sstevel@tonic-gate extern int __sigfillset(sigset_t *); 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate /* 166*0Sstevel@tonic-gate * defined in sparc/fp/_Q_set_except.c and i386/fp/exception.c 167*0Sstevel@tonic-gate */ 168*0Sstevel@tonic-gate extern int _Q_set_exception(unsigned int); 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate /* 171*0Sstevel@tonic-gate * defined in nsparse.c 172*0Sstevel@tonic-gate */ 173*0Sstevel@tonic-gate extern struct __nsw_switchconfig *_nsw_getoneconfig(const char *name, 174*0Sstevel@tonic-gate char *linep, enum __nsw_parse_err *); 175*0Sstevel@tonic-gate extern struct __nsw_switchconfig_v1 *_nsw_getoneconfig_v1(const char *name, 176*0Sstevel@tonic-gate char *linep, enum __nsw_parse_err *); 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate /* 179*0Sstevel@tonic-gate * Internal routine from getusershell.c 180*0Sstevel@tonic-gate */ 181*0Sstevel@tonic-gate extern char *getusershell(void); 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate /* 184*0Sstevel@tonic-gate * defined in _sigaction.s 185*0Sstevel@tonic-gate */ 186*0Sstevel@tonic-gate extern int __sigaction(int, const struct sigaction *, struct sigaction *); 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate /* 189*0Sstevel@tonic-gate * defined in _getsp.s 190*0Sstevel@tonic-gate */ 191*0Sstevel@tonic-gate extern greg_t _getsp(void); 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate /* 194*0Sstevel@tonic-gate * defined in _so_setsockopt.s 195*0Sstevel@tonic-gate */ 196*0Sstevel@tonic-gate extern int _so_setsockopt(int, int, int, const char *, int); 197*0Sstevel@tonic-gate 198*0Sstevel@tonic-gate /* 199*0Sstevel@tonic-gate * defined in _so_getsockopt.s 200*0Sstevel@tonic-gate */ 201*0Sstevel@tonic-gate extern int _so_getsockopt(int, int, int, char *, int *); 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate /* 204*0Sstevel@tonic-gate * defined in lsign.s 205*0Sstevel@tonic-gate */ 206*0Sstevel@tonic-gate extern int lsign(dl_t); 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate /* 209*0Sstevel@tonic-gate * defined in ucontext.s 210*0Sstevel@tonic-gate * __getcontext() is exported by libc 211*0Sstevel@tonic-gate * __getcontext_syscall() is private to libc 212*0Sstevel@tonic-gate * otherwise they are the same function 213*0Sstevel@tonic-gate */ 214*0Sstevel@tonic-gate extern int __getcontext(ucontext_t *); 215*0Sstevel@tonic-gate extern int __getcontext_syscall(ucontext_t *); 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gate /* 218*0Sstevel@tonic-gate * defined in door.s 219*0Sstevel@tonic-gate */ 220*0Sstevel@tonic-gate extern int __door_info(int, door_info_t *); 221*0Sstevel@tonic-gate extern int __door_call(int, door_arg_t *); 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gate /* 224*0Sstevel@tonic-gate * defined in _portfs.s 225*0Sstevel@tonic-gate */ 226*0Sstevel@tonic-gate extern int64_t _portfs(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t, 227*0Sstevel@tonic-gate uintptr_t); 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate /* 230*0Sstevel@tonic-gate * defined in xpg4.c 231*0Sstevel@tonic-gate */ 232*0Sstevel@tonic-gate extern int __xpg4; 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate /* 235*0Sstevel@tonic-gate * i18n prototypes - strong symbols (weak symbols are in libintl.h) 236*0Sstevel@tonic-gate */ 237*0Sstevel@tonic-gate extern char *_textdomain(const char *); 238*0Sstevel@tonic-gate extern char *_bindtextdomain(const char *, const char *); 239*0Sstevel@tonic-gate extern char *_dcgettext(const char *, const char *, const int); 240*0Sstevel@tonic-gate extern char *_dgettext(const char *, const char *); 241*0Sstevel@tonic-gate extern char *_gettext(const char *); 242*0Sstevel@tonic-gate extern int _fnmatch(const char *, const char *, int); 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate /* 246*0Sstevel@tonic-gate * defined in port/stdio/doscan.c 247*0Sstevel@tonic-gate */ 248*0Sstevel@tonic-gate extern int _doscan(FILE *, const char *, va_list); 249*0Sstevel@tonic-gate extern int __doscan_u(FILE *, const char *, va_list, int); 250*0Sstevel@tonic-gate extern int __wdoscan_u(FILE *, const wchar_t *, va_list, int); 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate #ifndef _LP64 253*0Sstevel@tonic-gate /* Flag for _ndoprnt() and _doscan_u() */ 254*0Sstevel@tonic-gate #define _F_INTMAX32 0x1 /* if set read 4 bytes for u/intmax %j */ 255*0Sstevel@tonic-gate extern int _fprintf_c89(FILE *, const char *, ...); 256*0Sstevel@tonic-gate extern int _printf_c89(const char *, ...); 257*0Sstevel@tonic-gate extern int _snprintf_c89(char *, size_t, const char *, ...); 258*0Sstevel@tonic-gate extern int _sprintf_c89(char *, const char *, ...); 259*0Sstevel@tonic-gate extern int _wprintf_c89(const wchar_t *, ...); 260*0Sstevel@tonic-gate extern int _fwprintf_c89(FILE *, const wchar_t *, ...); 261*0Sstevel@tonic-gate extern int _swprintf_c89(wchar_t *, size_t, const wchar_t *, ...); 262*0Sstevel@tonic-gate extern int _vfprintf_c89(FILE *, const char *, va_list); 263*0Sstevel@tonic-gate extern int _vprintf_c89(const char *, va_list); 264*0Sstevel@tonic-gate extern int _vsnprintf_c89(char *, size_t, const char *, va_list); 265*0Sstevel@tonic-gate extern int _vsprintf_c89(char *, const char *, va_list); 266*0Sstevel@tonic-gate extern int _vwprintf_c89(const wchar_t *, va_list); 267*0Sstevel@tonic-gate extern int _vfwprintf_c89(FILE *, const wchar_t *, va_list); 268*0Sstevel@tonic-gate extern int _vswprintf_c89(wchar_t *, size_t, const wchar_t *, va_list); 269*0Sstevel@tonic-gate extern int _scanf_c89(const char *, ...); 270*0Sstevel@tonic-gate extern int _fscanf_c89(FILE *, const char *, ...); 271*0Sstevel@tonic-gate extern int _sscanf_c89(const char *, const char *, ...); 272*0Sstevel@tonic-gate extern int _vscanf_c89(const char *, va_list); 273*0Sstevel@tonic-gate extern int _vfscanf_c89(FILE *, const char *, va_list); 274*0Sstevel@tonic-gate extern int _vsscanf_c89(const char *, const char *, va_list); 275*0Sstevel@tonic-gate extern int _vwscanf_c89(const wchar_t *, va_list); 276*0Sstevel@tonic-gate extern int _vfwscanf_c89(FILE *, const wchar_t *, va_list); 277*0Sstevel@tonic-gate extern int _vswscanf_c89(const wchar_t *, const wchar_t *, va_list); 278*0Sstevel@tonic-gate extern int _wscanf_c89(const wchar_t *, ...); 279*0Sstevel@tonic-gate extern int _fwscanf_c89(FILE *, const wchar_t *, ...); 280*0Sstevel@tonic-gate extern int _swscanf_c89(const wchar_t *, const wchar_t *, ...); 281*0Sstevel@tonic-gate #endif /* _LP64 */ 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate /* 284*0Sstevel@tonic-gate * defined in port/stdio/popen.c 285*0Sstevel@tonic-gate */ 286*0Sstevel@tonic-gate extern int _insert(pid_t pid, int fd); 287*0Sstevel@tonic-gate extern pid_t _delete(int fd); 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate /* 290*0Sstevel@tonic-gate * defined in port/print/doprnt.c 291*0Sstevel@tonic-gate */ 292*0Sstevel@tonic-gate extern ssize_t _wdoprnt(const wchar_t *, va_list, FILE *); 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate /* 295*0Sstevel@tonic-gate * defined in fgetwc.c 296*0Sstevel@tonic-gate */ 297*0Sstevel@tonic-gate extern wint_t _fgetwc_unlocked(FILE *); 298*0Sstevel@tonic-gate extern wint_t __getwc_xpg5(FILE *); 299*0Sstevel@tonic-gate extern wint_t __fgetwc_xpg5(FILE *); 300*0Sstevel@tonic-gate extern wint_t _getwc(FILE *); 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate /* 303*0Sstevel@tonic-gate * defined in fputwc.c 304*0Sstevel@tonic-gate */ 305*0Sstevel@tonic-gate extern wint_t __putwc_xpg5(wint_t, FILE *); 306*0Sstevel@tonic-gate extern wint_t _putwc(wint_t, FILE *); 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate /* 309*0Sstevel@tonic-gate * defined in ungetwc.c 310*0Sstevel@tonic-gate */ 311*0Sstevel@tonic-gate extern wint_t __ungetwc_xpg5(wint_t, FILE *); 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate /* 314*0Sstevel@tonic-gate * defined in wscmp.c 315*0Sstevel@tonic-gate */ 316*0Sstevel@tonic-gate extern int _wcscmp(const wchar_t *, const wchar_t *); 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate /* 319*0Sstevel@tonic-gate * defined in wslen.c 320*0Sstevel@tonic-gate */ 321*0Sstevel@tonic-gate extern size_t _wcslen(const wchar_t *); 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate /* 324*0Sstevel@tonic-gate * defined in wscpy.c 325*0Sstevel@tonic-gate */ 326*0Sstevel@tonic-gate extern wchar_t *_wcscpy(wchar_t *, const wchar_t *); 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate #ifdef __sparc 329*0Sstevel@tonic-gate extern ulong_t caller(void); 330*0Sstevel@tonic-gate extern ulong_t getfp(void); 331*0Sstevel@tonic-gate #endif 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate /* 334*0Sstevel@tonic-gate * misc synonyms 335*0Sstevel@tonic-gate */ 336*0Sstevel@tonic-gate extern int _wctomb(char *, wchar_t); 337*0Sstevel@tonic-gate extern wint_t _towlower(wint_t); 338*0Sstevel@tonic-gate extern int _doscan(FILE *, const char *, va_list); 339*0Sstevel@tonic-gate extern int _wcscoll(const wchar_t *, const wchar_t *); 340*0Sstevel@tonic-gate extern size_t _wcsxfrm(wchar_t *, const wchar_t *, size_t); 341*0Sstevel@tonic-gate extern wint_t _fputwc(wint_t, FILE *); 342*0Sstevel@tonic-gate #ifdef __cplusplus 343*0Sstevel@tonic-gate } 344*0Sstevel@tonic-gate #endif 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate #endif /* _LIBC_H */ 347