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.
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.
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]
23 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2013 OmniTI Computer Consulting, Inc. All rights reserved.
26 * Copyright (c) 2013 Gary Mills
27 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28 * Copyright 2015 Circonus, Inc. All rights reserved.
34 #define __EXTENSIONS__
46 #include <sys/errno.h>
74 #include <rpcsvc/ypclnt.h>
77 #include <semaphore.h>
84 #include <sys/ucred.h>
94 #include <sys/acctctl.h>
96 #include <sys/asynch.h>
97 #include <sys/byteorder.h>
98 #include <sys/cladm.h>
99 #include <sys/corectl.h>
101 #include <sys/exacct.h>
102 #include <sys/fcntl.h>
103 #include <sys/file.h>
104 #include <sys/fs/namenode.h>
105 #include <sys/instance.h>
108 #include <sys/mkdev.h>
109 #include <sys/mman.h>
110 #include <sys/mnttab.h>
111 #include <sys/mount.h>
113 #include <sys/param.h>
114 #include <sys/priocntl.h>
115 #include <sys/procset.h>
116 #include <sys/processor.h>
117 #include <sys/pset.h>
118 #include <sys/rctl_impl.h>
122 #include <sys/signal.h>
123 #include <sys/stat.h>
124 #include <sys/statvfs.h>
125 #include <sys/strlog.h>
126 #include <sys/stropts.h>
127 #include <sys/syscall.h>
128 #include <sys/sysconfig.h>
129 #include <sys/syslog.h>
130 #include <sys/systeminfo.h>
131 #include <sys/task.h>
132 #include <sys/termio.h>
133 #include <sys/termios.h>
134 #include <sys/u8_textprep.h>
135 #include <sys/time.h>
136 #include <sys/timeb.h>
137 #include <sys/times.h>
138 #include <sys/types.h>
139 #include <sys/uadmin.h>
140 #include <sys/utsname.h>
141 #include <sys/vfstab.h>
142 #include <sys/sendfile.h>
143 #include <sys/zone.h>
147 #include <ucontext.h>
157 #include <schedctl.h>
161 #include <inttypes.h>
163 #include <stdio_ext.h>
165 #include <sys/sysi86.h>
168 #include <stack_unwind.h>
173 * This really comes from the crt*.s startup modules.
178 * This is a GNU/Linux/BSD compatibility interface,
179 * not declared in any header file.
181 const char *__progname;
184 * POSIX versions of standard libc routines; these aren't extracted
185 * from the headers above since we cannot #define _POSIX_C_SOURCE.
187 int __posix_readdir_r(DIR * _RESTRICT_KYWD, struct dirent * _RESTRICT_KYWD,
188 struct dirent ** _RESTRICT_KYWD);
189 int __posix_getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
190 int __posix_getgrnam_r(const char *, struct group *, char *, size_t,
192 int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
194 int __posix_getpwnam_r(const char *, struct passwd *, char *, size_t,
196 int __posix_sigwait(const sigset_t * _RESTRICT_KYWD, int * _RESTRICT_KYWD);
197 char *__posix_asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
198 char *__posix_ctime_r(const time_t *, char *);
199 int __posix_ttyname_r(int, char *, size_t);
200 int __posix_getlogin_r(char *, int);
201 int __posix_getloginx_r(char *, int);
204 * XPG4 versions of standard libc routines; these aren't extracted
205 * from the headers above since we cannot #define _XPG4_2.
207 int __xpg4_putmsg(int, const struct strbuf *, const struct strbuf *, int);
208 int __xpg4_putpmsg(int, const struct strbuf *, const struct strbuf *, int, int);
211 * These aren't extracted from the headers above because:
212 * - We cannot #define _STRPTIME_DONTZERO
213 * - We cannot #define _XPG5
215 char *__strptime_dontzero(const char *, const char *, struct tm *);
216 long __sysconf_xpg5(int);
217 wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD,
218 const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
219 size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t,
220 const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
221 wint_t __fgetwc_xpg5(__FILE *);
222 wint_t __getwc_xpg5(__FILE *);
223 wint_t __getwchar_xpg5(void);
224 wint_t __fputwc_xpg5(wint_t, __FILE *);
225 wint_t __putwc_xpg5(wint_t, __FILE *);
226 wint_t __putwchar_xpg5(wint_t);
227 wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD);
228 int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
229 wint_t __ungetwc_xpg5(wint_t, __FILE *);
232 * /usr/src/lib/libc/port/gen routines
242 int _set_tab(const char *loc, int cat);
245 int _xftw(int ver, const char *path, int (*fn)(), int depth);
248 long a64l(const char *);
255 long labs(long int arg);
258 void _assert(const char *assertion, const char *filename, int line_num);
259 void __assert_c99(const char *assertion, const char *filename, int line_num,
260 const char *funcname);
263 int atexit(void(*func)());
264 void _exithandle(void);
267 double atof(const char *p);
270 int atoi(const char *p);
273 long atol(const char *p);
276 char *basename(char *s);
279 int bcmp(const void *s1, const void *s2, size_t len);
282 void bcopy(const void *s1, void *s2, size_t len);
285 void *bsearch(const void *ky, const void *bs, size_t nel,
286 size_t width, int (*compar)());
289 void bzero(void *sp, size_t len);
292 void *calloc(size_t num, size_t size);
295 int catclose(nl_catd catd);
298 char *catgets(nl_catd catd, int set_num, int msg_num, const char *s);
301 nl_catd catopen(const char *name, int mode);
304 speed_t cfgetispeed(const struct termios *termios_p);
307 speed_t cfgetospeed(const struct termios *termios_p);
310 void cfree(void *p, size_t num, size_t size);
313 int cfsetispeed(struct termios *termios_p, speed_t speed);
316 int cfsetospeed(struct termios *termios_p, speed_t speed);
319 int cftime(char *buf, char *format, const time_t *t);
320 int ascftime(char *buf, const char *format, const struct tm *tm);
326 int closedir(DIR *dirp);
329 size_t confstr(int name, char *buf, size_t length);
332 void setkey(const char *key);
333 void encrypt(char *block, int fake);
334 char *crypt(const char *key, const char *salt);
337 int csetlen(int cset);
338 int csetcol(int cset);
341 char *ctime(const time_t *t);
342 char *ctime_r(const time_t *, char *buf, int);
343 char *asctime(const struct tm *t);
344 char *asctime_r(const struct tm *, char *, int);
364 int daemon(int nochdir, int noclose);
367 int directio(int filedes, int advice);
370 char *dirname(char *s);
373 div_t div(int numer, int denom);
374 ldiv_t ldiv(long int numer, long int denom);
377 double drand48(void);
378 double erand48(unsigned short *xsubi);
379 long krand48(unsigned short *xsubi, unsigned int m);
382 void srand48(long seedval);
383 unsigned short *seed48(unsigned short seed16v[3]);
384 void lcong48(unsigned short param[7]);
385 long nrand48(unsigned short *xsubi);
386 long jrand48(unsigned short *xsubi);
390 int dup2(int fildes, int fildes2);
391 int dup3(int fildes, int fildes2, int flags);
394 char *ecvt(double value, int ndigit, int *_RESTRICT_KYWD decpt,
395 int *_RESTRICT_KYWDsign);
396 char *fcvt(double value, int ndigit, int *_RESTRICT_KYWD decpt,
397 int *_RESTRICT_KYWD sign);
400 void _errfp(FILE *, int, const char *, ...);
401 void _verrfp(FILE *, int, const char *, va_list);
402 void _errxfp(FILE *, int, const char *, ...);
403 void _verrxfp(FILE *, int, const char *, va_list);
404 void _warnfp(FILE *, const char *, ...);
405 void _vwarnfp(FILE *, const char *, va_list);
406 void _warnxfp(FILE *, const char *, ...);
407 void _vwarnxfp(FILE *, const char *, va_list);
412 int euccol(const unsigned char *s);
413 int euclen(const unsigned char *s);
414 int eucscol(const unsigned char *s);
418 int execlp(const char *, const char *, ...);
419 int execvp(const char *name, char *const *argv);
422 int fattach(int fildes, const char *path);
425 int fdetach(const char *path);
431 int addseverity(int value, const char *string);
432 int fmtmsg(long class, const char *label, int severity, const char *text,
433 const char *action, const char *tag);
436 int ftime(struct timeb *tp);
439 key_t ftok(const char *path, int id);
442 char *gcvt(double number, int ndigit, char *buf);
445 char *getcwd(char *str, size_t size);
448 struct tm *getdate(const char *expression);
459 int getdtablesize(void);
462 char *getenv(const char *name);
465 const char *getexecname(void);
468 struct group *getgrnam(const char *name);
469 struct group *getgrgid(gid_t gid);
470 struct group *fgetgrent_r(FILE *, struct group *, char *, int);
471 struct group *getgrent_r(struct group *, char *, int);
472 struct group *getgrgid_r(gid_t, struct group *, char *, int);
473 struct group *getgrnam_r(const char *, struct group *, char *, int);
476 long gethostid(void);
482 uint_t getisax(uint32_t *, uint_t);
485 char *getloginx(void);
486 char *getloginx_r(char *, int);
489 #endif /* getlogin */
490 char *getlogin(void);
493 #endif /* getlogin_r */
494 char *getlogin_r(char *, int);
497 int getmntany(FILE *fd, struct mnttab *mgetp, struct mnttab *mrefp);
498 int getmntent(FILE *fd, struct mnttab *mp);
501 int setnetgrent(const char *grp);
502 int endnetgrent(void);
503 int getnetgrent(char **machinep, char **namep, char **domainp);
506 int getopt(int argc, char *const *argv, const char *opts);
509 int getopt_clip(int argc, char *const *argv, const char *optstring,
510 const struct option *long_options, int *long_index);
511 int getopt_long(int argc, char *const *argv, const char *optstring,
512 const struct option *long_options, int *long_index);
513 int getopt_long_only(int argc, char *const *argv, const char *optstring,
514 const struct option *long_options, int *long_index);
517 int getpagesize(void);
520 int getpw(uid_t uid, char *buf);
523 struct passwd *getpwnam(const char *name);
524 struct passwd *getpwuid(uid_t uid);
525 struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int);
526 struct passwd *getpwent_r(struct passwd *, char *, int);
527 struct passwd *getpwnam_r(const char *, struct passwd *, char *, int);
528 struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
531 int getrusage(int who, struct rusage *rusage);
534 int gettimeofday(struct timeval *_RESTRICT_KYWD tp, void *_RESTRICT_KYWD);
539 struct spwd *getspent(void);
540 struct spwd *getspent_r(struct spwd *, char *, int);
541 struct spwd *fgetspent(FILE *f);
542 struct spwd *fgetspent_r(FILE *, struct spwd *, char *, int);
543 struct spwd *getspnam(const char *name);
544 struct spwd *getspnam_r(const char *, struct spwd *, char *, int);
545 int putspent(const struct spwd *p, FILE *f);
548 int str2spwd(const char *, int, void *, char *, int);
551 int getsubopt(char **optionsp, char *const *tokens, char **valuep);
554 char *gettxt(const char *msg_id, const char *dflt_str);
557 char *getusershell(void);
558 void endusershell(void);
559 void setusershell(void);
562 struct utmp *getutent(void);
563 struct utmp *getutid(const struct utmp *entry);
564 struct utmp *getutline(const struct utmp *entry);
565 struct utmp *pututline(const struct utmp *entry);
568 int utmpname(const char *newfile);
569 void updwtmp(const char *file, struct utmp *ut);
570 void getutmp(const struct utmpx *utx, struct utmp *ut);
571 void getutmpx(const struct utmp *ut, struct utmpx *utx);
572 struct utmp *makeut(struct utmp *utmp);
575 struct utmpx *getutxent(void);
576 struct utmpx *getutxid(const struct utmpx *entry);
577 struct utmpx *getutxline(const struct utmpx *entry);
578 struct utmpx *pututxline(const struct utmpx *entry);
579 void setutxent(void);
580 void endutxent(void);
581 int utmpxname(const char *newfile);
582 void updwtmpx(const char *filex, struct utmpx *utx);
583 struct utmpx *makeutx(const struct utmpx *utmp);
584 struct utmpx *modutx(const struct utmpx *utp);
587 int getvfsspec(FILE *fd, struct vfstab *vp, char *special);
588 int getvfsfile(FILE *fd, struct vfstab *vp, char *mountp);
589 int getvfsany(FILE *fd, struct vfstab *vgetp, struct vfstab *vrefp);
590 int getvfsent(FILE *fd, struct vfstab *vp);
593 char *getwd(char *pathname);
596 void getwidth(eucwidth_t *eucstruct);
599 int hcreate(size_t size);
601 ENTRY *hsearch(ENTRY item, ACTION action);
604 size_t iconv(iconv_t cd, const char **_RESTRICT_KYWD inbuf,
605 size_t *_RESTRICT_KYWD inbytesleft, char **_RESTRICT_KYWD outbuf,
606 size_t *_RESTRICT_KYWD outbytesleft);
607 int iconv_close(iconv_t cd);
608 iconv_t iconv_open(const char *tocode, const char *fromcode);
611 intmax_t imaxabs(intmax_t j);
614 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
617 char *index(const char *sp, int c);
620 int initgroups(const char *uname, gid_t agroup);
623 int innetgr(const char *group, const char *machine, const char *name,
627 void insque(void *elem, void *pred);
628 void remque(void *elem);
631 int isaexec(const char *, char *const *, char *const *);
634 int isastream(int fd);
640 int killpg(pid_t pgrp, int sig);
650 void * lfind(const void *ky, const void *bs, size_t *nelp,
651 size_t width, int (*compar)());
654 struct lconv *localeconv(void);
657 void * lsearch(const void *ky, void *bs, size_t *nelp,
658 size_t width, int (*compar)());
661 int madvise(caddr_t addr, size_t len, int advice);
664 void *malloc(size_t size);
665 void *realloc(void *old, size_t size);
666 void free(void *old);
669 size_t mbstowcs(wchar_t *_RESTRICT_KYWD pwcs, const char *_RESTRICT_KYWD s,
673 int mbtowc(wchar_t *_RESTRICT_KYWD wchar, const char *_RESTRICT_KYWD s,
675 int mblen(const char *s, size_t n);
678 void *memalign(size_t align, size_t nbytes);
681 void *memccpy(void *_RESTRICT_KYWDs, const void *_RESTRICT_KYWD s0, int c,
685 void *memchr(const void *sptr, int c1, size_t n);
688 int memcmp(const void *s1, const void *s2, size_t n);
691 void *memcpy(void *_RESTRICT_KYWD s, const void *_RESTRICT_KYWD s0, size_t n);
694 void *memmove(void *s, const void *s0, size_t n);
697 void *memset(void *sp1, int c, size_t n);
700 dev_t __makedev(const int version, const major_t majdev,
701 const minor_t mindev);
702 major_t __major(const int version, const dev_t devnum);
703 minor_t __minor(const int version, const dev_t devnum);
706 int mkfifo(const char *path, mode_t mode);
709 char *mktemp(char *as);
712 int mlock(caddr_t addr, size_t len);
715 int mlockall(int flags);
718 void monitor(int (*alowpc)(), int (*ahighpc)(), WORD *buffer,
719 size_t bufsize, size_t nfunc);
722 int msync(caddr_t addr, size_t len, int flags);
725 int munlock(caddr_t addr, size_t len);
728 int munlockall(void);
731 void dbm_setdefwrite(DBM *db);
732 int dbm_flush(DBM *db);
733 int dbm_flushpag(DBM *db);
734 DBM *dbm_open(const char *file, int flags, mode_t mode);
735 void dbm_close(DBM *db);
736 int dbm_close_status(DBM *db);
737 datum dbm_fetch(DBM *db, datum key);
738 int dbm_delete(DBM *db, datum key);
739 int dbm_store(DBM *db, datum key, datum dat, int replace);
740 datum dbm_firstkey(DBM *db);
741 datum dbm_nextkey(DBM *db);
742 datum dbm_do_nextkey(DBM *db, datum inkey);
747 int nftw(const char *path, int (*fn)(), int depth, int flags);
750 char *nl_langinfo(nl_item item);
753 DIR *opendir(const char *filename);
758 void perror(const char *s);
764 void psiginfo(const siginfo_t *sip, const char *s);
767 void psignal(int sig, const char *s);
770 char *ptsname(int fd);
771 int unlockpt(int fd);
775 int putenv(char *change);
776 int setenv(const char *envname, const char *envval, int overwrite);
777 int unsetenv(const char *name);
780 int putpwent(const struct passwd *p, FILE *f);
783 void qsort(void *base, size_t n, size_t size, int (*compar)());
789 void srand(unsigned x);
791 int rand_r(unsigned int *);
794 void srandom(unsigned x);
795 char *initstate(unsigned seed, char *arg_state, size_t n);
796 char *setstate(const char *arg_state);
800 int rctl_walk(int (*callback)(const char *, void *), void *walk_data);
801 hrtime_t rctlblk_get_firing_time(rctlblk_t *rblk);
802 uint_t rctlblk_get_global_action(rctlblk_t *rblk);
803 uint_t rctlblk_get_global_flags(rctlblk_t *rblk);
804 uint_t rctlblk_get_local_action(rctlblk_t *rblk, int *signalp);
805 uint_t rctlblk_get_local_flags(rctlblk_t *rblk);
806 id_t rctlblk_get_recipient_pid(rctlblk_t *rblk);
807 rctl_priv_t rctlblk_get_privilege(rctlblk_t *rblk);
808 rctl_qty_t rctlblk_get_value(rctlblk_t *rblk);
809 void rctlblk_set_local_action(rctlblk_t *rblk, uint_t action, int signal);
810 void rctlblk_set_local_flags(rctlblk_t *rblk, uint_t flags);
811 void rctlblk_set_privilege(rctlblk_t *rblk, rctl_priv_t priv);
812 void rctlblk_set_value(rctlblk_t *rblk, rctl_qty_t val);
813 size_t rctlblk_size(void);
816 struct dirent *readdir(DIR *dirp);
819 char *realpath(const char *_RESTRICT_KYWD raw, char *_RESTRICT_KYWD canon);
822 char *re_comp(const char *sp);
823 int re_exec(const char *p1);
826 char *rindex(const char *sp, int c);
829 int remove(const char *filename);
830 int rename(const char *old, const char *new);
834 void rewinddir(DIR *dirp);
837 int alphasort(const struct dirent **, const struct dirent **);
838 int scandir(const char *dirname, struct dirent *(*namelist[]),
839 int (*select)(const struct dirent *),
840 int (*dcomp)(const struct dirent **, const struct dirent **));
843 int scrwidth(wchar_t c);
846 void seekdir(DIR *dirp, long loc);
849 int pselect(int nfds,
850 fd_set *_RESTRICT_KYWD readfds,
851 fd_set *_RESTRICT_KYWD writefds,
852 fd_set *_RESTRICT_KYWD errorfds,
853 const struct timespec *_RESTRICT_KYWD timeout,
854 const sigset_t *_RESTRICT_KYWD sigmask);
856 fd_set *_RESTRICT_KYWD readfds,
857 fd_set *_RESTRICT_KYWD writefds,
858 fd_set *_RESTRICT_KYWD errorfds,
859 struct timeval *_RESTRICT_KYWD timeout);
862 char *setlocale(int cat, const char *loc);
865 int getpriority(int which, id_t who);
866 int setpriority(int which, id_t who, int prio);
869 int settimeofday(struct timeval *tp, void *);
872 int sigflag(int sig, int flag, int on);
877 int sigsend(idtype_t idtype, id_t id, int sig);
880 int sigfillset(sigset_t *set);
881 int sigemptyset(sigset_t *set);
882 int sigaddset(sigset_t *set, int sig);
883 int sigdelset(sigset_t *set, int sig);
884 int sigismember(const sigset_t *set, int sig);
887 unsigned sleep(unsigned sleep_tm);
890 int (*ssignal(int sig, int (*fn)())) ();
891 int gsignal(int sig);
896 int str2sig(const char *s, int *sigp);
897 int sig2str(int i, char *s);
900 char *strcat(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2);
903 char *strchr(const char *sp, int c);
906 int strcmp(const char *s1, const char *s2);
909 char *strcpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2);
912 size_t strcspn(const char *string, const char *charset);
915 char *strdup(const char *s1);
918 char *strerror(int errnum);
919 int strerror_r(int errnum, char *strerrbuf, size_t buflen);
922 size_t strftime(char *_RESTRICT_KYWD s, size_t maxsize,
923 const char *_RESTRICT_KYWD format,
924 const struct tm *_RESTRICT_KYWD tm);
927 size_t strlen(const char *s);
930 char *strncat(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n);
933 int strncmp(const char *s1, const char *s2, size_t n);
936 char *strncpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n);
939 char *strpbrk(const char *string, const char *brkset);
942 char *strrchr(const char *sp, int c);
945 char *strsep(char **stringp, const char *delim);
948 size_t strspn(const char *string, const char *charset);
951 char *strstr(const char *as1, const char *as2);
954 double strtod(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
955 float strtof(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
956 long double strtold(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
959 intmax_t strtoimax(const char *_RESTRICT_KYWD nptr,
960 char **_RESTRICT_KYWD endptr, int base);
963 char *strtok(char *_RESTRICT_KYWD string, const char *_RESTRICT_KYWD sepset);
964 char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
965 char **_RESTRICT_KYWD);
968 long strtol(const char *_RESTRICT_KYWD str, char **_RESTRICT_KYWD nptr,
972 unsigned long strtoul(const char *_RESTRICT_KYWD str,
973 char **_RESTRICT_KYWD nptr, int base);
976 uintmax_t strtoumax(const char *_RESTRICT_KYWD nptr,
977 char **_RESTRICT_KYWD endptr, int base);
980 size_t strxfrm(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2,
982 int strcoll(const char *s1, const char *s2);
985 void swab(const char *_RESTRICT_KYWD from, char *_RESTRICT_KYWD to, ssize_t n);
988 int swapctl(int cmd, void *arg);
991 long sysconf(int name);
995 void syslog(int pri, const char *fmt, ...);
996 void vsyslog(int pri, const char *fmt, va_list ap);
997 void openlog(const char *ident, int logstat, int logfac);
999 int setlogmask(int pmask);
1002 int tcdrain(int fildes);
1005 int tcflow(int fildes, int action);
1008 int tcflush(int fildes, int queue_selector);
1011 int tcgetattr(int fildes, struct termios *termios_p);
1014 pid_t tcgetpgrp(int fd);
1017 pid_t tcgetsid(int fd);
1020 int tcsendbreak(int fildes, int duration);
1023 int tcsetattr(int fildes, int optional_actions,
1024 const struct termios *termios_p);
1027 int tcsetpgrp(int fd, pid_t pgrp);
1033 long telldir(DIR *dirp);
1036 void *tfind(const void *ky, void *const *rtp, int (*compar)());
1039 struct tm *localtime(const time_t *timep);
1040 struct tm *localtime_r(const time_t *_RESTRICT_KYWD, struct tm *_RESTRICT_KYWD);
1041 struct tm *gmtime(const time_t *clock);
1042 struct tm *gmtime_r(const time_t *_RESTRICT_KYWD, struct tm *_RESTRICT_KYWD);
1043 double difftime(time_t time1, time_t time0);
1044 time_t mktime(struct tm *timeptr);
1045 void _ltzset(time_t tim);
1059 int ftruncate(int fildes, off_t len);
1060 int truncate(const char *path, off_t len);
1063 void *tsearch(const void *ky, void **rtp, int (*compar)());
1064 void *tdelete(const void *ky, void **rtp, int (*compar)());
1065 void twalk(const void *rt, void (*action)());
1068 char *ttyname(int f);
1069 char *_ttyname_dev(dev_t rdev, char *buffer, size_t buflen);
1070 char *ttyname_r(int, char *, int);
1076 unsigned ualarm(unsigned usecs, unsigned reload);
1080 long ulimit(int cmd, ...);
1083 int usleep(unsigned n);
1086 void *valloc(size_t size);
1089 pid_t wait(int *stat_loc);
1090 pid_t waitpid(pid_t pid, int *stat_loc, int options);
1091 pid_t wait3(int *status, int options, struct rusage *rp);
1092 pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
1095 size_t wcstombs(char *_RESTRICT_KYWD s, const wchar_t *_RESTRICT_KYWD pwcs,
1099 int wctomb(char *s, wchar_t wchar);
1104 int wisprint(wchar_t c);
1107 void _xgetwidth(void);
1110 * /usr/src/lib/libc/port/intl routines
1114 char *bindtextdomain(const char *domain, const char *binding);
1115 char *dcgettext(const char *domain, const char *msg_id, const int category);
1116 char *dgettext(const char *domain, const char *msg_id);
1117 char *gettext(const char *msg_id);
1118 char *textdomain(const char *domain);
1121 * /usr/src/lib/libc/port/print routines
1126 int fprintf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD format, ...);
1130 int printf(const char *_RESTRICT_KYWD format, ...);
1134 int snprintf(char *_RESTRICT_KYWD string, size_t n,
1135 const char *_RESTRICT_KYWD format, ...);
1139 int sprintf(char *_RESTRICT_KYWD string,
1140 const char *_RESTRICT_KYWD format, ...);
1144 int vfprintf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD format,
1149 int vprintf(const char *_RESTRICT_KYWD format, va_list);
1153 int vsnprintf(char *_RESTRICT_KYWD string, size_t n,
1154 const char *_RESTRICT_KYWD format, va_list);
1158 int vsprintf(char *_RESTRICT_KYWD string, const char *_RESTRICT_KYWD format,
1162 * /usr/src/lib/libc/port/regex routines
1166 extern int glob(const char *restrict pattern, int flags,
1167 int(*errfunc)(const char *epath, int eerrno), glob_t *restrict pglob);
1168 extern void globfree(glob_t *pglob);
1171 char *regex(const char *regexp, const char *stringp, ...);
1178 char *regcmp(const char *regexp, ...);
1185 * /usr/src/lib/libc/port/stdio routines
1189 int _filbuf(FILE *iop);
1192 int _flsbuf(int ch, FILE *iop);
1195 int _wrtchk(FILE *iop);
1198 void clearerr(FILE *iop);
1201 char *ctermid(char *s);
1202 char *ctermid_r(char *s);
1205 char *cuserid(char *s);
1210 int _doscan(FILE *iop, const char *fmt, va_list va_alist);
1213 FILE *fdopen(int fd, const char *type);
1216 int feof(FILE *iop);
1219 int ferror(FILE *iop);
1222 int fgetc(FILE *iop);
1225 char *fgets(char *_RESTRICT_KYWD buf, int size, FILE *_RESTRICT_KYWD iop);
1228 int _fileno(FILE *iop);
1231 void _cleanup(void);
1232 FILE *_findiop(void);
1233 typedef unsigned char Uchar;
1234 void _setbufend(FILE *iop, Uchar *end);
1235 Uchar *_realbufend(FILE *iop);
1236 void _bufsync(FILE *iop, Uchar *bufend);
1237 int _xflsbuf(FILE *iop);
1238 int fflush(FILE *iop);
1239 int fclose(FILE *iop);
1242 FILE *fopen(const char *_RESTRICT_KYWD name, const char *_RESTRICT_KYWD type);
1243 FILE *freopen(const char *_RESTRICT_KYWD name, const char *_RESTRICT_KYWD type,
1244 FILE *_RESTRICT_KYWD iop);
1247 int fgetpos(FILE *_RESTRICT_KYWD stream, fpos_t *_RESTRICT_KYWD pos);
1248 int fsetpos(FILE *stream, const fpos_t *pos);
1251 int fputc(int ch, FILE *iop);
1254 int fputs(const char *_RESTRICT_KYWD ptr, FILE *_RESTRICT_KYWD iop);
1257 size_t fread(void *_RESTRICT_KYWD ptr, size_t size, size_t count,
1258 FILE *_RESTRICT_KYWD iop);
1261 int fseek(FILE *iop, long offset, int ptrname);
1264 long ftell(FILE *iop);
1267 size_t fwrite(const void *_RESTRICT_KYWD ptr1, size_t size, size_t count,
1268 FILE *_RESTRICT_KYWD iop);
1271 int getc(FILE *iop);
1277 char *getpass(const char *prompt);
1280 char *getpassphrase(const char *prompt);
1283 char *gets(char *buf);
1286 int getw(FILE *stream);
1289 FILE *popen(const char *cmd, const char *mode);
1290 int pclose(FILE *ptr);
1293 int putc(int ch, FILE *iop);
1296 int putchar(int ch);
1299 int puts(const char *ptr);
1302 int putw(int w, FILE *stream);
1305 void rewind(FILE *iop);
1309 int scanf(const char *_RESTRICT_KYWD fmt, ...);
1312 int fscanf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD fmt, ...);
1315 int sscanf(const char *_RESTRICT_KYWD str, const char *_RESTRICT_KYWD fmt, ...);
1318 void setbuf(FILE *_RESTRICT_KYWD iop, char *_RESTRICT_KYWD abuf);
1321 int setvbuf(FILE *_RESTRICT_KYWD iop, char *_RESTRICT_KYWD abuf, int type,
1325 int system(const char *s);
1328 char *tempnam(const char *dir, const char *pfx);
1331 FILE *tmpfile(void);
1334 char *tmpnam(char *s);
1335 char *tmpnam_r(char *);
1338 int ungetc(int c, FILE *iop);
1341 * /usr/src/lib/libc/port/sys routines
1345 size_t getacct(idtype_t idtype, id_t id, void *buf, size_t bufsize);
1346 int putacct(idtype_t idtype, id_t id, void *buf, size_t bufsize, int flags);
1347 int wracct(idtype_t idtype, id_t id, int flags);
1351 int execl(const char *name, const char *, ...);
1354 int execle(const char *, const char *file, ...);
1357 int execv(const char *file, char *const *argv);
1360 int lockf(int fildes, int function, off_t size);
1363 int meminfo(const uint64_t *inaddr, int addr_count, const uint_t *info_req,
1364 int info_count, uint64_t *outdata, uint_t *validity);
1367 int msgget(key_t key, int msgflg);
1368 int msgctl(int msqid, int cmd, struct msqid_ds *buf);
1369 ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
1370 int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
1374 int exportfs(char *dir, struct export *ep);
1375 int nfs_getfh(char *path, fhandle_t *fhp);
1380 int pset_create(psetid_t *npset);
1381 int pset_destroy(psetid_t pset);
1382 int pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset);
1383 int pset_assign_forced(psetid_t pset, processorid_t cpu, psetid_t *opset);
1384 int pset_info(psetid_t pset, int *type, u_int *numcpus, processorid_t *cpulist);
1385 int pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset);
1386 int pset_bind_lwp(psetid_t pset, id_t id, pid_t, psetid_t *opset);
1390 int getrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk,
1392 int setrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk,
1394 /* (private functions) */
1395 int setprojrctl(const char *name, rctlblk_t *new_rblk, size_t size, int flags);
1396 int rctlctl(const char *, rctlblk_t *, int);
1397 size_t rctllist(char *, size_t);
1401 int semctl(int semid, int semnum, int cmd, ...);
1402 int semget(key_t key, int nsems, int semflg);
1403 int semop(int semid, struct sembuf *sops, size_t nsops);
1406 void *shmat(int shmid, const void *shmaddr, int shmflg);
1407 int shmctl(int shmid, int cmd, struct shmid_ds *buf);
1408 #if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4)
1409 int shmdt(const void *);
1412 #endif /* defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4) */
1413 int shmget(key_t key, size_t size, int shmflg);
1416 taskid_t settaskid(projid_t project, uint_t flags);
1417 taskid_t gettaskid(void);
1418 projid_t getprojid(void);
1421 * /usr/src/lib/libc/port/widec routines
1425 wchar_t *fgetws(wchar_t *_RESTRICT_KYWD ptr, int size,
1426 FILE *_RESTRICT_KYWD iop);
1429 wint_t fputwc(wint_t wc, FILE *iop);
1430 wint_t putwc(wint_t wc, FILE *iop);
1433 int fputws(const wchar_t *_RESTRICT_KYWD ptr, FILE *_RESTRICT_KYWD iop);
1436 wint_t getwchar(void);
1439 void getwidth(eucwidth_t *eucstruct);
1442 wchar_t *getws(wchar_t *ptr);
1445 int iswctype(wint_t wc, wctype_t charclass);
1446 int iswalpha(wint_t c);
1447 int iswupper(wint_t c);
1448 int iswlower(wint_t c);
1449 int iswdigit(wint_t c);
1450 int iswxdigit(wint_t c);
1451 int iswalnum(wint_t c);
1452 int iswspace(wint_t c);
1453 int iswpunct(wint_t c);
1454 int iswprint(wint_t c);
1455 int iswgraph(wint_t c);
1456 int iswcntrl(wint_t c);
1457 int isphonogram(wint_t c);
1458 int isideogram(wint_t c);
1459 int isenglish(wint_t c);
1460 int isnumber(wint_t c);
1461 int isspecial(wint_t c);
1466 wint_t putwchar(wint_t c);
1469 int putws(const wchar_t *ptr);
1474 wchar_t *strtows(wchar_t *s1, char *s2);
1475 char *wstostr(char *s1, wchar_t *s2);
1478 wint_t towupper(wint_t c);
1479 wint_t towlower(wint_t c);
1482 wint_t ungetwc(wint_t wc, FILE *iop);
1485 size_t wcsxfrm(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1487 int wcscoll(const wchar_t *s1, const wchar_t *s2);
1490 #if !defined(__amd64) /* XX64 - fix me */
1491 size_t wcsftime(wchar_t *wcs, size_t maxsize,
1492 const char *format, const struct tm *timeptr);
1493 #endif /* __amd64 */
1496 wint_t fgetwc(FILE *iop);
1497 wint_t getwc(FILE *iop);
1498 int wcwidth(wchar_t wc);
1499 int wcswidth(const wchar_t *pwcs, size_t n);
1502 wchar_t *wcswcs(const wchar_t *ws1, const wchar_t *ws2);
1504 /* wcsxfrm.c - empty file! */
1506 /* wcsxfrm.xpg4.c */
1509 int wisprint(wchar_t c);
1512 int wscasecmp(const wchar_t *s1, const wchar_t *s2);
1515 wchar_t *wcscat(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2);
1516 wchar_t *wscat(wchar_t *s1, const wchar_t *s2);
1519 wchar_t *wcschr(const wchar_t *sp, wchar_t c);
1520 wchar_t *wschr(const wchar_t *sp, wchar_t c);
1523 int wcscmp(const wchar_t *s1, const wchar_t *s2);
1524 int wscmp(const wchar_t *s1, const wchar_t *s2);
1527 int wscol(const wchar_t *s1);
1530 wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2);
1531 wchar_t *wscpy(wchar_t *s1, const wchar_t *s2);
1534 size_t wcscspn(const wchar_t *string, const wchar_t *charset);
1535 size_t wscspn(const wchar_t *string, const wchar_t *charset);
1538 wchar_t *wsdup(const wchar_t *s1);
1541 size_t wcslen(const wchar_t *s);
1542 size_t wslen(const wchar_t *s);
1545 int wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1548 wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1550 wchar_t *wsncat(wchar_t *s1, const wchar_t *s2, size_t n);
1553 int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1554 int wsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1557 wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1559 wchar_t *wsncpy(wchar_t *s1, const wchar_t *s2, size_t n);
1562 wchar_t *wcspbrk(const wchar_t *string, const wchar_t *brkset);
1563 wchar_t *wspbrk(const wchar_t *string, const wchar_t *brkset);
1566 int wsprintf(wchar_t *wstring, const char *format, ...);
1569 wchar_t *wcsrchr(const wchar_t *sp, wchar_t c);
1570 wchar_t *wsrchr(const wchar_t *sp, wchar_t c);
1573 int wsscanf(wchar_t *s, const char *format, ...);
1578 size_t wcsspn(const wchar_t *string, const wchar_t *charset);
1579 size_t wsspn(const wchar_t *string, const wchar_t *charset);
1582 double wcstod(const wchar_t *_RESTRICT_KYWD cp, wchar_t **_RESTRICT_KYWD ptr);
1583 float wcstof(const wchar_t *_RESTRICT_KYWD cp, wchar_t **_RESTRICT_KYWD ptr);
1584 long double wcstold(const wchar_t *_RESTRICT_KYWD cp,
1585 wchar_t **_RESTRICT_KYWD ptr);
1586 double wstod(const wchar_t *cp, wchar_t **ptr);
1589 #if !defined(__amd64) /* XX64 - fix me */
1590 wchar_t *wcstok(wchar_t *string, const wchar_t *sepset);
1591 wchar_t *wstok(wchar_t *string, const wchar_t *sepset);
1592 #endif /* __amd64 */
1595 long wcstol(const wchar_t *_RESTRICT_KYWD str, wchar_t **_RESTRICT_KYWD ptr,
1597 long long wcstoll(const wchar_t *_RESTRICT_KYWD str,
1598 wchar_t **_RESTRICT_KYWD ptr, int base);
1601 unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD str,
1602 wchar_t **_RESTRICT_KYWD ptr, int base);
1603 unsigned long long wcstoull(const wchar_t *_RESTRICT_KYWD str,
1604 wchar_t **_RESTRICT_KYWD ptr, int base);
1607 intmax_t wcstoimax(const wchar_t *_RESTRICT_KYWD nptr,
1608 wchar_t **_RESTRICT_KYWD endptr, int base);
1609 uintmax_t wcstoumax(const wchar_t *_RESTRICT_KYWD nptr,
1610 wchar_t **_RESTRICT_KYWD endptr, int base);
1613 long wstol(const wchar_t *str, wchar_t **ptr, int base);
1616 long long wstoll(const wchar_t *str, wchar_t **ptr, int base);
1617 long long watoll(const wchar_t *p);
1620 size_t wsxfrm(wchar_t *s1, const wchar_t *s2, size_t n);
1621 int wscoll(const wchar_t *s1, const wchar_t *s2);
1624 * /usr/src/lib/libc/port/gen/event_port.c
1626 int port_dispatch(int port, int flags, int source, int events, uintptr_t object,
1630 * /usr/src/lib/libc/$MACH/gen routines
1635 void *__builtin_alloca(size_t);
1638 * modctl(int arg, ...) and utssys(...) are not available from a header
1639 * file, but our utilities which make use of it should be able to be
1642 int modctl(int arg, ...);
1643 int utssys(void *buf, int arg, int type, void *outbp);
1646 typedef float single;
1647 typedef unsigned extended[3];
1648 typedef long double quadruple;
1649 typedef unsigned fp_exception_field_type;
1651 typedef char decimal_string[512];
1653 enum fp_class_type {
1662 enum fp_direction_type {
1670 enum fp_class_type fpclass;
1684 enum fp_direction_type rd;
1685 enum decimal_form df;
1689 enum decimal_string_form {
1695 fixed_intdotfrac_form,
1697 floating_intdot_form,
1698 floating_dotfrac_form,
1699 floating_intdotfrac_form,
1706 typedef int sigfpe_code_type;
1708 typedef void (*sigfpe_handler_type)();
1710 extern sigfpe_handler_type sigfpe(sigfpe_code_type, sigfpe_handler_type);
1712 extern void single_to_decimal(single *, decimal_mode *, decimal_record *,
1713 fp_exception_field_type *);
1715 extern void double_to_decimal(double *, decimal_mode *, decimal_record *,
1716 fp_exception_field_type *);
1717 extern void extended_to_decimal(extended *, decimal_mode *,
1718 decimal_record *, fp_exception_field_type *);
1719 extern void quadruple_to_decimal(quadruple *, decimal_mode *,
1720 decimal_record *, fp_exception_field_type *);
1721 extern void decimal_to_single(single *, decimal_mode *, decimal_record *,
1722 fp_exception_field_type *);
1723 extern void decimal_to_double(double *, decimal_mode *, decimal_record *,
1724 fp_exception_field_type *);
1725 extern void decimal_to_extended(extended *, decimal_mode *,
1726 decimal_record *, fp_exception_field_type *);
1727 extern void decimal_to_quadruple(quadruple *, decimal_mode *,
1728 decimal_record *, fp_exception_field_type *);
1729 extern void string_to_decimal(char **, int, int, decimal_record *,
1730 enum decimal_string_form *, char **);
1731 extern void func_to_decimal(char **, int, int, decimal_record *,
1732 enum decimal_string_form *, char **,
1733 int (*)(void), int *, int (*)(int));
1734 extern void file_to_decimal(char **, int, int, decimal_record *,
1735 enum decimal_string_form *, char **,
1737 extern char *seconvert(single *, int, int *, int *, char *);
1738 extern char *sfconvert(single *, int, int *, int *, char *);
1739 extern char *sgconvert(single *, int, int, char *);
1740 extern char *econvert(double, int, int *, int *, char *);
1741 extern char *fconvert(double, int, int *, int *, char *);
1742 extern char *gconvert(double, int, int, char *);
1743 extern char *qeconvert(quadruple *, int, int *, int *, char *);
1744 extern char *qfconvert(quadruple *, int, int *, int *, char *);
1745 extern char *qgconvert(quadruple *, int, int, char *);
1747 extern void __assert(const char *, const char *, int);
1749 extern int setjmp(jmp_buf);
1750 extern void longjmp(jmp_buf, int);
1751 extern int sigsetjmp(sigjmp_buf, int);
1752 extern void siglongjmp(sigjmp_buf, int);
1754 int uname(struct utsname *);
1755 int _uname(struct utsname *);
1759 { return (&errno); }
1761 extern int getloadavg(double [], int);
1763 extern long pcsample(uintptr_t [], long);
1765 int fstat(int, struct stat *);
1766 int stat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD);
1767 int lstat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD);
1768 int mknod(const char *, mode_t, dev_t);
1770 extern int __init_daemon_priv(int, uid_t uid, gid_t gid, ...);
1771 extern void __fini_daemon_priv(const char *, ...);
1772 extern int __init_suid_priv(int, ...);
1773 extern int __priv_bracket(priv_op_t);
1774 extern void __priv_relinquish(void);
1775 extern const char * __priv_getsetbynum(const void *, int);
1776 extern char * __priv_set_to_str(void *, const priv_set_t *, char, int);
1778 /* private interface to get the groups list for a certain user */
1779 int _getgroupsbymember(const char *, gid_t[], int, int);
1781 /* private interface for use only by java */
1782 volatile sc_shared_t *volatile *_thr_schedctl(void);
1784 /* private interface to unmount all autofs mounts */
1785 int _autofssys(enum autofssys_op, void *);
1788 extern int is_system_labeled(void);
1790 extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *,
1792 extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int);
1793 extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *,
1795 extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int);
1796 extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
1797 extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
1798 extern int u8_validate(char *, size_t, char **, int, int *);
1799 extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
1800 extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
1803 /* private locale interfaces */
1804 wint_t __nextwctype(wint_t, wctype_t);
1805 int __iswrune(wint_t);