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