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