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