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