xref: /titanic_50/usr/src/lib/libc/inc/libc.h (revision 2654012f83cec5dc15b61dfe3e4a4915f186e7a6)
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 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 void callout_lock_enter(void);
72 extern void callout_lock_exit(void);
73 extern void *lmalloc(size_t);
74 extern void lfree(void *, size_t);
75 extern void libc_nvlist_free(nvlist_t *);
76 extern int libc_nvlist_lookup_uint64(nvlist_t *, const char *, uint64_t *);
77 extern void *libc_malloc(size_t);
78 extern void *libc_realloc(void *, size_t);
79 extern void libc_free(void *);
80 extern char *libc_strdup(const char *);
81 extern int _pollsys(struct pollfd *, nfds_t, const timespec_t *,
82 	const sigset_t *);
83 
84 /*
85  * The private_DIR structure is the same as the DIR structure,
86  * with the addition of a mutex lock for libc's internal use.
87  */
88 typedef struct {
89 	DIR	dd_dir;
90 	mutex_t	dd_lock;
91 } private_DIR;
92 
93 #if !defined(_LP64)
94 /*
95  * getdents64 transitional interface is intentionally internal to libc
96  */
97 extern int getdents64(int, struct dirent64 *, size_t);
98 #endif
99 
100 extern int _scrwidth(wchar_t);
101 
102 extern int64_t __div64(int64_t, int64_t);
103 extern int64_t __rem64(int64_t, int64_t);
104 extern uint64_t __udiv64(uint64_t, uint64_t);
105 extern uint64_t __urem64(uint64_t, uint64_t);
106 extern int64_t __mul64(int64_t, int64_t);
107 extern uint64_t __umul64(uint64_t, uint64_t);
108 
109 
110 /*
111  * Rounding direction functions
112  */
113 #if defined(__i386) || defined(__amd64)
114 extern enum fp_direction_type __xgetRD(void);
115 #elif defined(__sparc)
116 extern enum fp_direction_type _QgetRD(void);
117 #else
118 #error Unknown architecture!
119 #endif
120 
121 
122 /*
123  * defined in hex_bin.c
124  */
125 extern void __hex_to_single(decimal_record *, enum fp_direction_type,
126 	single *, fp_exception_field_type *);
127 extern void __hex_to_double(decimal_record *, enum fp_direction_type,
128 	double *, fp_exception_field_type *);
129 #if defined(__sparc)
130 extern void __hex_to_quadruple(decimal_record *, enum fp_direction_type,
131 	quadruple *, fp_exception_field_type *);
132 #elif defined(__i386) || defined(__amd64)
133 extern void __hex_to_extended(decimal_record *, enum fp_direction_type,
134 	extended *, fp_exception_field_type *);
135 #else
136 #error Unknown architecture
137 #endif
138 
139 /*
140  * defined in ctime.c
141  */
142 extern char	*__posix_asctime_r(const struct tm *, char *);
143 
144 /*
145  * Internal routine from fsync.c
146  */
147 extern int __fdsync(int, int);	/* 2nd arg may be wrong in 64bit mode */
148 
149 /*
150  * Internal routine from _xregs_clrptr.c
151  */
152 extern void _xregs_clrptr(ucontext_t *);
153 
154 /*
155  * Internal routine from nfssys.c
156  */
157 extern int _nfssys(int, void *); /* int in 64bit mode ???, void * ??? */
158 
159 /*
160  * Internal routine from psetsys.c
161  */
162 extern int _pset(int, ...); /* int in 64bit mode ??? */
163 
164 /*
165  * defined in sigpending.s
166  */
167 extern int __sigfillset(sigset_t *);
168 
169 /*
170  * defined in sparc/fp/_Q_set_except.c and i386/fp/exception.c
171  */
172 extern int _Q_set_exception(unsigned int);
173 
174 /*
175  * defined in nsparse.c
176  */
177 extern struct __nsw_switchconfig *_nsw_getoneconfig(const char *name,
178 	char *linep, enum __nsw_parse_err *);
179 extern struct __nsw_switchconfig_v1 *_nsw_getoneconfig_v1(const char *name,
180 	char *linep, enum __nsw_parse_err *);
181 
182 /*
183  * Internal routine from getusershell.c
184  */
185 extern char *getusershell(void);
186 
187 /*
188  * defined in _sigaction.s
189  */
190 extern int __sigaction(int, const struct sigaction *, struct sigaction *);
191 
192 /*
193  * defined in _getsp.s
194  */
195 extern greg_t _getsp(void);
196 
197 /*
198  * defined in _so_setsockopt.s
199  */
200 extern int _so_setsockopt(int, int, int, const char *, int);
201 
202 /*
203  * defined in _so_getsockopt.s
204  */
205 extern int _so_getsockopt(int, int, int, char *, int *);
206 
207 /*
208  * defined in lsign.s
209  */
210 extern int lsign(dl_t);
211 
212 /*
213  * defined in ucontext.s
214  */
215 extern int __getcontext(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;		/* global */
233 extern int libc__xpg4;		/* copy of __xpg4, private to libc */
234 
235 /*
236  * defined in xpg6.c
237  */
238 extern uint_t __xpg6;		/* global */
239 extern uint_t libc__xpg6;	/* copy of __xpg6, private to libc */
240 
241 /*
242  * defined in port/stdio/doscan.c
243  */
244 extern int _doscan(FILE *, const char *, va_list);
245 extern int __doscan_u(FILE *, const char *, va_list, int);
246 extern int __wdoscan_u(FILE *, const wchar_t *, va_list, int);
247 
248 #ifndef _LP64
249 /* Flag for _ndoprnt() and _doscan_u() */
250 #define	_F_INTMAX32	0x1	/* if set read 4 bytes for u/intmax %j */
251 extern int _fprintf_c89(FILE *, const char *, ...);
252 extern int _printf_c89(const char *, ...);
253 extern int _snprintf_c89(char *, size_t, const char *, ...);
254 extern int _sprintf_c89(char *, const char *, ...);
255 extern int _wprintf_c89(const wchar_t *, ...);
256 extern int _fwprintf_c89(FILE *, const wchar_t *, ...);
257 extern int _swprintf_c89(wchar_t *, size_t, const wchar_t *, ...);
258 extern int _vfprintf_c89(FILE *, const char *, va_list);
259 extern int _vprintf_c89(const char *, va_list);
260 extern int _vsnprintf_c89(char *, size_t, const char *, va_list);
261 extern int _vsprintf_c89(char *, const char *, va_list);
262 extern int _vwprintf_c89(const wchar_t *, va_list);
263 extern int _vfwprintf_c89(FILE *, const wchar_t *, va_list);
264 extern int _vswprintf_c89(wchar_t *, size_t, const wchar_t *, va_list);
265 extern int _scanf_c89(const char *, ...);
266 extern int _fscanf_c89(FILE *, const char *, ...);
267 extern int _sscanf_c89(const char *, const char *, ...);
268 extern int _vscanf_c89(const char *, va_list);
269 extern int _vfscanf_c89(FILE *, const char *, va_list);
270 extern int _vsscanf_c89(const char *, const char *, va_list);
271 extern int _vwscanf_c89(const wchar_t *, va_list);
272 extern int _vfwscanf_c89(FILE *, const wchar_t *, va_list);
273 extern int _vswscanf_c89(const wchar_t *, const wchar_t *, va_list);
274 extern int _wscanf_c89(const wchar_t *, ...);
275 extern int _fwscanf_c89(FILE *, const wchar_t *, ...);
276 extern int _swscanf_c89(const wchar_t *, const wchar_t *, ...);
277 #endif	/*	_LP64	*/
278 
279 /*
280  * defined in port/stdio/popen.c
281  */
282 extern int _insert(pid_t pid, int fd);
283 extern pid_t _delete(int fd);
284 
285 /*
286  * defined in port/print/doprnt.c
287  */
288 extern ssize_t	_wdoprnt(const wchar_t *, va_list, FILE *);
289 
290 /*
291  * defined in fgetwc.c
292  */
293 extern wint_t _fgetwc_unlocked(FILE *);
294 extern wint_t __getwc_xpg5(FILE *);
295 extern wint_t __fgetwc_xpg5(FILE *);
296 extern wint_t _getwc(FILE *);
297 
298 /*
299  * defined in fputwc.c
300  */
301 extern wint_t __putwc_xpg5(wint_t, FILE *);
302 extern wint_t _putwc(wint_t, FILE *);
303 
304 /*
305  * defined in ungetwc.c
306  */
307 extern wint_t	__ungetwc_xpg5(wint_t, FILE *);
308 
309 #ifdef	__cplusplus
310 }
311 #endif
312 
313 #endif /* _LIBC_H */
314