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