xref: /titanic_41/usr/src/lib/libc/inc/libc.h (revision d89fccd8788afe1e920f842edd883fe192a1b8fe)
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
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 int fork_lock_enter(const char *);
73 extern void fork_lock_exit(void);
74 extern void *lmalloc(size_t);
75 extern void lfree(void *, size_t);
76 extern void *libc_malloc(size_t);
77 extern void *libc_realloc(void *, size_t);
78 extern void libc_free(void *);
79 extern char *libc_strdup(const char *);
80 extern int _sigwait(sigset_t *);
81 extern int _thr_getspecific(thread_key_t key, void **valuep);
82 extern int _thr_setspecific(unsigned int key, void *value);
83 extern int _thr_keycreate(thread_key_t *pkey, void (*destructor)(void *));
84 extern void *_pthread_getspecific(thread_key_t);
85 extern int _pollsys(struct pollfd *, nfds_t, const timespec_t *,
86 	const sigset_t *);
87 extern void _private_testcancel(void);
88 
89 #if !defined(_LP64)
90 /*
91  * getdents64 transitional interface is intentionally internal to libc
92  */
93 extern int getdents64(int, struct dirent64 *, size_t);
94 #endif
95 
96 extern int _scrwidth(wchar_t);
97 
98 extern int64_t __div64(int64_t, int64_t);
99 extern int64_t __rem64(int64_t, int64_t);
100 extern uint64_t __udiv64(uint64_t, uint64_t);
101 extern uint64_t __urem64(uint64_t, uint64_t);
102 extern int64_t __mul64(int64_t, int64_t);
103 extern uint64_t __umul64(uint64_t, uint64_t);
104 
105 
106 /*
107  * Rounding direction functions
108  */
109 #if defined(__i386) || defined(__amd64)
110 extern enum fp_direction_type __xgetRD(void);
111 #elif defined(__sparc)
112 extern enum fp_direction_type _QgetRD(void);
113 #else
114 #error Unknown architecture!
115 #endif
116 
117 
118 /*
119  * defined in hex_bin.c
120  */
121 extern void __hex_to_single(decimal_record *, enum fp_direction_type,
122 	single *, fp_exception_field_type *);
123 extern void __hex_to_double(decimal_record *, enum fp_direction_type,
124 	double *, fp_exception_field_type *);
125 #if defined(__sparc)
126 extern void __hex_to_quadruple(decimal_record *, enum fp_direction_type,
127 	quadruple *, fp_exception_field_type *);
128 #elif defined(__i386) || defined(__amd64)
129 extern 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  */
138 extern char	*__posix_asctime_r(const struct tm *, char *);
139 
140 /*
141  * Internal routine from fsync.c
142  */
143 extern int __fdsync(int, int);	/* 2nd arg may be wrong in 64bit mode */
144 
145 /*
146  * Internal routine from _xregs_clrptr.c
147  */
148 extern void _xregs_clrptr(ucontext_t *);
149 
150 /*
151  * Internal routine from nfssys.c
152  */
153 extern int _nfssys(int, void *); /* int in 64bit mode ???, void * ??? */
154 
155 /*
156  * Internal routine from psetsys.c
157  */
158 extern int _pset(int, ...); /* int in 64bit mode ??? */
159 
160 /*
161  * defined in sigpending.s
162  */
163 extern int __sigfillset(sigset_t *);
164 
165 /*
166  * defined in sparc/fp/_Q_set_except.c and i386/fp/exception.c
167  */
168 extern int _Q_set_exception(unsigned int);
169 
170 /*
171  * defined in nsparse.c
172  */
173 extern struct __nsw_switchconfig *_nsw_getoneconfig(const char *name,
174 	char *linep, enum __nsw_parse_err *);
175 extern 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  */
181 extern char *getusershell(void);
182 
183 /*
184  * defined in _sigaction.s
185  */
186 extern int __sigaction(int, const struct sigaction *, struct sigaction *);
187 
188 /*
189  * defined in _getsp.s
190  */
191 extern greg_t _getsp(void);
192 
193 /*
194  * defined in _so_setsockopt.s
195  */
196 extern int _so_setsockopt(int, int, int, const char *, int);
197 
198 /*
199  * defined in _so_getsockopt.s
200  */
201 extern int _so_getsockopt(int, int, int, char *, int *);
202 
203 /*
204  * defined in lsign.s
205  */
206 extern 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  */
214 extern int __getcontext(ucontext_t *);
215 extern int __getcontext_syscall(ucontext_t *);
216 
217 /*
218  * defined in door.s
219  */
220 extern int __door_info(int, door_info_t *);
221 extern int __door_call(int, door_arg_t *);
222 
223 /*
224  * defined in _portfs.s
225  */
226 extern int64_t _portfs(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
227     uintptr_t);
228 
229 /*
230  * defined in xpg4.c
231  */
232 extern int __xpg4;
233 
234 /*
235  * i18n prototypes - strong symbols (weak symbols are in libintl.h)
236  */
237 extern char *_textdomain(const char *);
238 extern char *_bindtextdomain(const char *, const char *);
239 extern char *_dcgettext(const char *, const char *, const int);
240 extern char *_dgettext(const char *, const char *);
241 extern char *_gettext(const char *);
242 extern int _fnmatch(const char *, const char *, int);
243 
244 
245 /*
246  * defined in port/stdio/doscan.c
247  */
248 extern int _doscan(FILE *, const char *, va_list);
249 extern int __doscan_u(FILE *, const char *, va_list, int);
250 extern 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 */
255 extern int _fprintf_c89(FILE *, const char *, ...);
256 extern int _printf_c89(const char *, ...);
257 extern int _snprintf_c89(char *, size_t, const char *, ...);
258 extern int _sprintf_c89(char *, const char *, ...);
259 extern int _wprintf_c89(const wchar_t *, ...);
260 extern int _fwprintf_c89(FILE *, const wchar_t *, ...);
261 extern int _swprintf_c89(wchar_t *, size_t, const wchar_t *, ...);
262 extern int _vfprintf_c89(FILE *, const char *, va_list);
263 extern int _vprintf_c89(const char *, va_list);
264 extern int _vsnprintf_c89(char *, size_t, const char *, va_list);
265 extern int _vsprintf_c89(char *, const char *, va_list);
266 extern int _vwprintf_c89(const wchar_t *, va_list);
267 extern int _vfwprintf_c89(FILE *, const wchar_t *, va_list);
268 extern int _vswprintf_c89(wchar_t *, size_t, const wchar_t *, va_list);
269 extern int _scanf_c89(const char *, ...);
270 extern int _fscanf_c89(FILE *, const char *, ...);
271 extern int _sscanf_c89(const char *, const char *, ...);
272 extern int _vscanf_c89(const char *, va_list);
273 extern int _vfscanf_c89(FILE *, const char *, va_list);
274 extern int _vsscanf_c89(const char *, const char *, va_list);
275 extern int _vwscanf_c89(const wchar_t *, va_list);
276 extern int _vfwscanf_c89(FILE *, const wchar_t *, va_list);
277 extern int _vswscanf_c89(const wchar_t *, const wchar_t *, va_list);
278 extern int _wscanf_c89(const wchar_t *, ...);
279 extern int _fwscanf_c89(FILE *, const wchar_t *, ...);
280 extern int _swscanf_c89(const wchar_t *, const wchar_t *, ...);
281 #endif	/*	_LP64	*/
282 
283 /*
284  * defined in port/stdio/popen.c
285  */
286 extern int _insert(pid_t pid, int fd);
287 extern pid_t _delete(int fd);
288 
289 /*
290  * defined in port/print/doprnt.c
291  */
292 extern ssize_t	_wdoprnt(const wchar_t *, va_list, FILE *);
293 
294 /*
295  * defined in fgetwc.c
296  */
297 extern wint_t _fgetwc_unlocked(FILE *);
298 extern wint_t __getwc_xpg5(FILE *);
299 extern wint_t __fgetwc_xpg5(FILE *);
300 extern wint_t _getwc(FILE *);
301 
302 /*
303  * defined in fputwc.c
304  */
305 extern wint_t __putwc_xpg5(wint_t, FILE *);
306 extern wint_t _putwc(wint_t, FILE *);
307 
308 /*
309  * defined in ungetwc.c
310  */
311 extern wint_t	__ungetwc_xpg5(wint_t, FILE *);
312 
313 /*
314  * defined in wscmp.c
315  */
316 extern int	_wcscmp(const wchar_t *, const wchar_t *);
317 
318 /*
319  * defined in wslen.c
320  */
321 extern size_t	_wcslen(const wchar_t *);
322 
323 /*
324  * defined in wscpy.c
325  */
326 extern wchar_t	*_wcscpy(wchar_t *, const wchar_t *);
327 
328 /*
329  * misc synonyms
330  */
331 extern int _wctomb(char *, wchar_t);
332 extern wint_t _towlower(wint_t);
333 extern int _doscan(FILE *, const char *, va_list);
334 extern int _wcscoll(const wchar_t *, const wchar_t *);
335 extern size_t _wcsxfrm(wchar_t *, const wchar_t *, size_t);
336 extern wint_t _fputwc(wint_t, FILE *);
337 extern pid_t waitpid_cancel(pid_t, int *, int);
338 #ifdef	__cplusplus
339 }
340 #endif
341 
342 #endif /* _LIBC_H */
343