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 2017 Nexenta Systems, Inc.
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.
29 * Copyright 2015 Joyent, Inc.
35 #define __EXTENSIONS__
47 #include <sys/errno.h>
76 #include <rpcsvc/ypclnt.h>
79 #include <semaphore.h>
86 #include <sys/ucred.h>
96 #include <sys/acctctl.h>
98 #include <sys/asynch.h>
99 #include <sys/byteorder.h>
100 #include <sys/cladm.h>
101 #include <sys/corectl.h>
103 #include <sys/epoll.h>
104 #include <sys/exacct.h>
105 #include <sys/fcntl.h>
106 #include <sys/file.h>
107 #include <sys/fs/namenode.h>
108 #include <sys/instance.h>
111 #include <sys/mkdev.h>
112 #include <sys/mman.h>
113 #include <sys/mnttab.h>
114 #include <sys/mount.h>
116 #include <sys/param.h>
117 #include <sys/priocntl.h>
118 #include <sys/procset.h>
119 #include <sys/processor.h>
120 #include <sys/pset.h>
121 #include <sys/rctl_impl.h>
125 #include <sys/signal.h>
126 #include <sys/stat.h>
127 #include <sys/statvfs.h>
128 #include <sys/strlog.h>
129 #include <sys/stropts.h>
130 #include <sys/syscall.h>
131 #include <sys/sysconfig.h>
132 #include <sys/syslog.h>
133 #include <sys/systeminfo.h>
134 #include <sys/task.h>
135 #include <sys/termio.h>
136 #include <sys/termios.h>
137 #include <sys/u8_textprep.h>
138 #include <sys/time.h>
139 #include <sys/timeb.h>
140 #include <sys/times.h>
141 #include <sys/types.h>
142 #include <sys/uadmin.h>
143 #include <sys/utsname.h>
144 #include <sys/vfstab.h>
145 #include <sys/sendfile.h>
146 #include <sys/zone.h>
150 #include <ucontext.h>
160 #include <schedctl.h>
164 #include <inttypes.h>
166 #include <stdio_ext.h>
168 #include <sys/sysi86.h>
171 #include <stack_unwind.h>
176 * This really comes from the crt*.s startup modules.
181 * This is a GNU/Linux/BSD compatibility interface,
182 * not declared in any header file.
184 const char *__progname;
187 * POSIX versions of standard libc routines; these aren't extracted
188 * from the headers above since we cannot #define _POSIX_C_SOURCE.
190 int __posix_readdir_r(DIR * _RESTRICT_KYWD, struct dirent * _RESTRICT_KYWD,
191 struct dirent ** _RESTRICT_KYWD);
192 int __posix_getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
193 int __posix_getgrnam_r(const char *, struct group *, char *, size_t,
195 int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
197 int __posix_getpwnam_r(const char *, struct passwd *, char *, size_t,
199 int __posix_sigwait(const sigset_t * _RESTRICT_KYWD, int * _RESTRICT_KYWD);
200 char *__posix_asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
201 char *__posix_ctime_r(const time_t *, char *);
202 int __posix_ttyname_r(int, char *, size_t);
203 int __posix_getlogin_r(char *, int);
204 int __posix_getloginx_r(char *, int);
207 * XPG4 versions of standard libc routines; these aren't extracted
208 * from the headers above since we cannot #define _XPG4_2.
210 int __xpg4_putmsg(int, const struct strbuf *, const struct strbuf *, int);
211 int __xpg4_putpmsg(int, const struct strbuf *, const struct strbuf *, int, int);
214 * These aren't extracted from the headers above because:
215 * - We cannot #define _STRPTIME_DONTZERO
216 * - We cannot #define _XPG5
218 char *__strptime_dontzero(const char *, const char *, struct tm *);
219 long __sysconf_xpg5(int);
220 wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD,
221 const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
222 size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t,
223 const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
224 wint_t __fgetwc_xpg5(__FILE *);
225 wint_t __getwc_xpg5(__FILE *);
226 wint_t __getwchar_xpg5(void);
227 wint_t __fputwc_xpg5(wint_t, __FILE *);
228 wint_t __putwc_xpg5(wint_t, __FILE *);
229 wint_t __putwchar_xpg5(wint_t);
230 wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD);
231 int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
232 wint_t __ungetwc_xpg5(wint_t, __FILE *);
235 * /usr/src/lib/libc/port/gen routines
245 int _set_tab(const char *loc, int cat);
248 int _xftw(int ver, const char *path, int (*fn)(), int depth);
251 long a64l(const char *);
258 long labs(long int arg);
261 void _assert(const char *assertion, const char *filename, int line_num);
262 void __assert_c99(const char *assertion, const char *filename, int line_num,
263 const char *funcname);
266 int atexit(void(*func)());
267 void _exithandle(void);
270 double atof(const char *p);
273 int atoi(const char *p);
276 long atol(const char *p);
279 char *basename(char *s);
282 int bcmp(const void *s1, const void *s2, size_t len);
285 void bcopy(const void *s1, void *s2, size_t len);
288 void *bsearch(const void *ky, const void *bs, size_t nel,
289 size_t width, int (*compar)());
292 void bzero(void *sp, size_t len);
295 void *calloc(size_t num, size_t size);
298 int catclose(nl_catd catd);
301 char *catgets(nl_catd catd, int set_num, int msg_num, const char *s);
304 nl_catd catopen(const char *name, int mode);
307 speed_t cfgetispeed(const struct termios *termios_p);
310 speed_t cfgetospeed(const struct termios *termios_p);
313 void cfree(void *p, size_t num, size_t size);
316 int cfsetispeed(struct termios *termios_p, speed_t speed);
319 int cfsetospeed(struct termios *termios_p, speed_t speed);
322 int cftime(char *buf, char *format, const time_t *t);
323 int ascftime(char *buf, const char *format, const struct tm *tm);
329 int closedir(DIR *dirp);
332 size_t confstr(int name, char *buf, size_t length);
335 void setkey(const char *key);
336 void encrypt(char *block, int fake);
337 char *crypt(const char *key, const char *salt);
340 int csetlen(int cset);
341 int csetcol(int cset);
344 char *ctime(const time_t *t);
345 char *ctime_r(const time_t *, char *buf, int);
346 char *asctime(const struct tm *t);
347 char *asctime_r(const struct tm *, char *, int);
367 int daemon(int nochdir, int noclose);
370 int directio(int filedes, int advice);
373 char *dirname(char *s);
376 div_t div(int numer, int denom);
377 ldiv_t ldiv(long int numer, long int denom);
380 double drand48(void);
381 double erand48(unsigned short *xsubi);
382 long krand48(unsigned short *xsubi, unsigned int m);
385 void srand48(long seedval);
386 unsigned short *seed48(unsigned short seed16v[3]);
387 void lcong48(unsigned short param[7]);
388 long nrand48(unsigned short *xsubi);
389 long jrand48(unsigned short *xsubi);
393 int dup2(int fildes, int fildes2);
394 int dup3(int fildes, int fildes2, int flags);
397 char *ecvt(double value, int ndigit, int *_RESTRICT_KYWD decpt,
398 int *_RESTRICT_KYWDsign);
399 char *fcvt(double value, int ndigit, int *_RESTRICT_KYWD decpt,
400 int *_RESTRICT_KYWD sign);
403 void _errfp(FILE *, int, const char *, ...);
404 void _verrfp(FILE *, int, const char *, va_list);
405 void _errxfp(FILE *, int, const char *, ...);
406 void _verrxfp(FILE *, int, const char *, va_list);
407 void _warnfp(FILE *, const char *, ...);
408 void _vwarnfp(FILE *, const char *, va_list);
409 void _warnxfp(FILE *, const char *, ...);
410 void _vwarnxfp(FILE *, const char *, va_list);
415 int euccol(const unsigned char *s);
416 int euclen(const unsigned char *s);
417 int eucscol(const unsigned char *s);
421 int execlp(const char *, const char *, ...);
422 int execvp(const char *name, char *const *argv);
425 int fattach(int fildes, const char *path);
428 int fdetach(const char *path);
434 int flock(int filedes, int operation);
437 int addseverity(int value, const char *string);
438 int fmtmsg(long class, const char *label, int severity, const char *text,
439 const char *action, const char *tag);
442 int ftime(struct timeb *tp);
445 key_t ftok(const char *path, int id);
448 FTSENT *fts_children(FTS *, int);
449 int fts_close(FTS *);
450 FTS *fts_open(char * const *, int, int (*)(const FTSENT **, const FTSENT **));
451 FTSENT *fts_read(FTS *);
452 int fts_set(FTS *, FTSENT *, int);
455 char *gcvt(double number, int ndigit, char *buf);
458 char *getcwd(char *str, size_t size);
461 struct tm *getdate(const char *expression);
472 int getdtablesize(void);
475 char *getenv(const char *name);
478 const char *getexecname(void);
481 struct group *getgrnam(const char *name);
482 struct group *getgrgid(gid_t gid);
483 struct group *fgetgrent_r(FILE *, struct group *, char *, int);
484 struct group *getgrent_r(struct group *, char *, int);
485 struct group *getgrgid_r(gid_t, struct group *, char *, int);
486 struct group *getgrnam_r(const char *, struct group *, char *, int);
489 long gethostid(void);
495 uint_t getisax(uint32_t *, uint_t);
498 char *getloginx(void);
499 char *getloginx_r(char *, int);
502 #endif /* getlogin */
503 char *getlogin(void);
506 #endif /* getlogin_r */
507 char *getlogin_r(char *, int);
510 int getmntany(FILE *fd, struct mnttab *mgetp, struct mnttab *mrefp);
511 int getmntent(FILE *fd, struct mnttab *mp);
514 int setnetgrent(const char *grp);
515 int endnetgrent(void);
516 int getnetgrent(char **machinep, char **namep, char **domainp);
519 int getopt(int argc, char *const *argv, const char *opts);
522 int getopt_clip(int argc, char *const *argv, const char *optstring,
523 const struct option *long_options, int *long_index);
524 int getopt_long(int argc, char *const *argv, const char *optstring,
525 const struct option *long_options, int *long_index);
526 int getopt_long_only(int argc, char *const *argv, const char *optstring,
527 const struct option *long_options, int *long_index);
530 int getpagesize(void);
533 int getpw(uid_t uid, char *buf);
536 struct passwd *getpwnam(const char *name);
537 struct passwd *getpwuid(uid_t uid);
538 struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int);
539 struct passwd *getpwent_r(struct passwd *, char *, int);
540 struct passwd *getpwnam_r(const char *, struct passwd *, char *, int);
541 struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
544 int getrusage(int who, struct rusage *rusage);
547 int gettimeofday(struct timeval *_RESTRICT_KYWD tp, void *_RESTRICT_KYWD);
552 struct spwd *getspent(void);
553 struct spwd *getspent_r(struct spwd *, char *, int);
554 struct spwd *fgetspent(FILE *f);
555 struct spwd *fgetspent_r(FILE *, struct spwd *, char *, int);
556 struct spwd *getspnam(const char *name);
557 struct spwd *getspnam_r(const char *, struct spwd *, char *, int);
558 int putspent(const struct spwd *p, FILE *f);
561 int str2spwd(const char *, int, void *, char *, int);
564 int getsubopt(char **optionsp, char *const *tokens, char **valuep);
567 char *gettxt(const char *msg_id, const char *dflt_str);
570 char *getusershell(void);
571 void endusershell(void);
572 void setusershell(void);
575 struct utmp *getutent(void);
576 struct utmp *getutid(const struct utmp *entry);
577 struct utmp *getutline(const struct utmp *entry);
578 struct utmp *pututline(const struct utmp *entry);
581 int utmpname(const char *newfile);
582 void updwtmp(const char *file, struct utmp *ut);
583 void getutmp(const struct utmpx *utx, struct utmp *ut);
584 void getutmpx(const struct utmp *ut, struct utmpx *utx);
585 struct utmp *makeut(struct utmp *utmp);
588 struct utmpx *getutxent(void);
589 struct utmpx *getutxid(const struct utmpx *entry);
590 struct utmpx *getutxline(const struct utmpx *entry);
591 struct utmpx *pututxline(const struct utmpx *entry);
592 void setutxent(void);
593 void endutxent(void);
594 int utmpxname(const char *newfile);
595 void updwtmpx(const char *filex, struct utmpx *utx);
596 struct utmpx *makeutx(const struct utmpx *utmp);
597 struct utmpx *modutx(const struct utmpx *utp);
600 int getvfsspec(FILE *fd, struct vfstab *vp, char *special);
601 int getvfsfile(FILE *fd, struct vfstab *vp, char *mountp);
602 int getvfsany(FILE *fd, struct vfstab *vgetp, struct vfstab *vrefp);
603 int getvfsent(FILE *fd, struct vfstab *vp);
606 char *getwd(char *pathname);
609 void getwidth(eucwidth_t *eucstruct);
612 int hcreate(size_t size);
614 ENTRY *hsearch(ENTRY item, ACTION action);
617 size_t iconv(iconv_t cd, const char **_RESTRICT_KYWD inbuf,
618 size_t *_RESTRICT_KYWD inbytesleft, char **_RESTRICT_KYWD outbuf,
619 size_t *_RESTRICT_KYWD outbytesleft);
620 int iconv_close(iconv_t cd);
621 iconv_t iconv_open(const char *tocode, const char *fromcode);
624 intmax_t imaxabs(intmax_t j);
627 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
630 char *index(const char *sp, int c);
633 int initgroups(const char *uname, gid_t agroup);
636 int innetgr(const char *group, const char *machine, const char *name,
640 void insque(void *elem, void *pred);
641 void remque(void *elem);
644 int isaexec(const char *, char *const *, char *const *);
647 int isastream(int fd);
653 int killpg(pid_t pgrp, int sig);
663 void * lfind(const void *ky, const void *bs, size_t *nelp,
664 size_t width, int (*compar)());
667 struct lconv *localeconv(void);
670 void * lsearch(const void *ky, void *bs, size_t *nelp,
671 size_t width, int (*compar)());
674 int madvise(caddr_t addr, size_t len, int advice);
677 void *malloc(size_t size);
678 void *realloc(void *old, size_t size);
679 void free(void *old);
682 size_t mbstowcs(wchar_t *_RESTRICT_KYWD pwcs, const char *_RESTRICT_KYWD s,
686 int mbtowc(wchar_t *_RESTRICT_KYWD wchar, const char *_RESTRICT_KYWD s,
688 int mblen(const char *s, size_t n);
691 void *memalign(size_t align, size_t nbytes);
694 void *memccpy(void *_RESTRICT_KYWDs, const void *_RESTRICT_KYWD s0, int c,
698 void *memchr(const void *sptr, int c1, size_t n);
701 int memcmp(const void *s1, const void *s2, size_t n);
704 void *memcpy(void *_RESTRICT_KYWD s, const void *_RESTRICT_KYWD s0, size_t n);
707 void *memmove(void *s, const void *s0, size_t n);
710 void *memset(void *sp1, int c, size_t n);
713 dev_t __makedev(const int version, const major_t majdev,
714 const minor_t mindev);
715 major_t __major(const int version, const dev_t devnum);
716 minor_t __minor(const int version, const dev_t devnum);
719 int mkfifo(const char *path, mode_t mode);
722 char *mktemp(char *as);
725 int mlock(caddr_t addr, size_t len);
728 int mlockall(int flags);
731 void monitor(int (*alowpc)(), int (*ahighpc)(), WORD *buffer,
732 size_t bufsize, size_t nfunc);
735 int msync(caddr_t addr, size_t len, int flags);
738 int munlock(caddr_t addr, size_t len);
741 int munlockall(void);
744 void dbm_setdefwrite(DBM *db);
745 int dbm_flush(DBM *db);
746 int dbm_flushpag(DBM *db);
747 DBM *dbm_open(const char *file, int flags, mode_t mode);
748 void dbm_close(DBM *db);
749 int dbm_close_status(DBM *db);
750 datum dbm_fetch(DBM *db, datum key);
751 int dbm_delete(DBM *db, datum key);
752 int dbm_store(DBM *db, datum key, datum dat, int replace);
753 datum dbm_firstkey(DBM *db);
754 datum dbm_nextkey(DBM *db);
755 datum dbm_do_nextkey(DBM *db, datum inkey);
760 int nftw(const char *path, int (*fn)(), int depth, int flags);
763 char *nl_langinfo(nl_item item);
766 DIR *opendir(const char *filename);
771 void perror(const char *s);
777 void psiginfo(const siginfo_t *sip, const char *s);
780 void psignal(int sig, const char *s);
783 char *ptsname(int fd);
784 int unlockpt(int fd);
788 int putenv(char *change);
789 int setenv(const char *envname, const char *envval, int overwrite);
790 int unsetenv(const char *name);
793 int putpwent(const struct passwd *p, FILE *f);
796 void qsort(void *base, size_t n, size_t size, int (*compar)());
802 void srand(unsigned x);
804 int rand_r(unsigned int *);
807 void srandom(unsigned x);
808 char *initstate(unsigned seed, char *arg_state, size_t n);
809 char *setstate(const char *arg_state);
813 int rctl_walk(int (*callback)(const char *, void *), void *walk_data);
814 hrtime_t rctlblk_get_firing_time(rctlblk_t *rblk);
815 uint_t rctlblk_get_global_action(rctlblk_t *rblk);
816 uint_t rctlblk_get_global_flags(rctlblk_t *rblk);
817 uint_t rctlblk_get_local_action(rctlblk_t *rblk, int *signalp);
818 uint_t rctlblk_get_local_flags(rctlblk_t *rblk);
819 id_t rctlblk_get_recipient_pid(rctlblk_t *rblk);
820 rctl_priv_t rctlblk_get_privilege(rctlblk_t *rblk);
821 rctl_qty_t rctlblk_get_value(rctlblk_t *rblk);
822 void rctlblk_set_local_action(rctlblk_t *rblk, uint_t action, int signal);
823 void rctlblk_set_local_flags(rctlblk_t *rblk, uint_t flags);
824 void rctlblk_set_privilege(rctlblk_t *rblk, rctl_priv_t priv);
825 void rctlblk_set_value(rctlblk_t *rblk, rctl_qty_t val);
826 size_t rctlblk_size(void);
829 struct dirent *readdir(DIR *dirp);
832 void *reallocarray(void *, size_t, size_t);
835 char *realpath(const char *_RESTRICT_KYWD raw, char *_RESTRICT_KYWD canon);
838 char *re_comp(const char *sp);
839 int re_exec(const char *p1);
842 char *rindex(const char *sp, int c);
845 int remove(const char *filename);
846 int rename(const char *old, const char *new);
850 void rewinddir(DIR *dirp);
853 int alphasort(const struct dirent **, const struct dirent **);
854 int scandir(const char *dirname, struct dirent *(*namelist[]),
855 int (*select)(const struct dirent *),
856 int (*dcomp)(const struct dirent **, const struct dirent **));
859 int scrwidth(wchar_t c);
862 void seekdir(DIR *dirp, long loc);
865 int pselect(int nfds,
866 fd_set *_RESTRICT_KYWD readfds,
867 fd_set *_RESTRICT_KYWD writefds,
868 fd_set *_RESTRICT_KYWD errorfds,
869 const struct timespec *_RESTRICT_KYWD timeout,
870 const sigset_t *_RESTRICT_KYWD sigmask);
872 fd_set *_RESTRICT_KYWD readfds,
873 fd_set *_RESTRICT_KYWD writefds,
874 fd_set *_RESTRICT_KYWD errorfds,
875 struct timeval *_RESTRICT_KYWD timeout);
878 char *setlocale(int cat, const char *loc);
881 int getpriority(int which, id_t who);
882 int setpriority(int which, id_t who, int prio);
885 int settimeofday(struct timeval *tp, void *);
888 int sigflag(int sig, int flag, int on);
893 int sigsend(idtype_t idtype, id_t id, int sig);
896 int sigfillset(sigset_t *set);
897 int sigemptyset(sigset_t *set);
898 int sigaddset(sigset_t *set, int sig);
899 int sigdelset(sigset_t *set, int sig);
900 int sigismember(const sigset_t *set, int sig);
903 unsigned sleep(unsigned sleep_tm);
906 int (*ssignal(int sig, int (*fn)())) ();
907 int gsignal(int sig);
912 int str2sig(const char *s, int *sigp);
913 int sig2str(int i, char *s);
916 char *strcat(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2);
919 char *strchr(const char *sp, int c);
922 int strcmp(const char *s1, const char *s2);
925 char *strcpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2);
928 size_t strcspn(const char *string, const char *charset);
931 char *strdup(const char *s1);
934 char *strerror(int errnum);
935 int strerror_r(int errnum, char *strerrbuf, size_t buflen);
938 size_t strftime(char *_RESTRICT_KYWD s, size_t maxsize,
939 const char *_RESTRICT_KYWD format,
940 const struct tm *_RESTRICT_KYWD tm);
943 size_t strlen(const char *s);
946 char *strncat(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n);
949 int strncmp(const char *s1, const char *s2, size_t n);
952 char *strncpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n);
955 char *strpbrk(const char *string, const char *brkset);
958 char *strrchr(const char *sp, int c);
961 char *strsep(char **stringp, const char *delim);
964 size_t strspn(const char *string, const char *charset);
967 char *strstr(const char *as1, const char *as2);
970 double strtod(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
971 float strtof(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
972 long double strtold(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
975 intmax_t strtoimax(const char *_RESTRICT_KYWD nptr,
976 char **_RESTRICT_KYWD endptr, int base);
979 char *strtok(char *_RESTRICT_KYWD string, const char *_RESTRICT_KYWD sepset);
980 char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
981 char **_RESTRICT_KYWD);
984 long strtol(const char *_RESTRICT_KYWD str, char **_RESTRICT_KYWD nptr,
988 long long strtonum(const char *, long long, long long, const char **);
991 unsigned long strtoul(const char *_RESTRICT_KYWD str,
992 char **_RESTRICT_KYWD nptr, int base);
995 uintmax_t strtoumax(const char *_RESTRICT_KYWD nptr,
996 char **_RESTRICT_KYWD endptr, int base);
999 size_t strxfrm(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2,
1001 int strcoll(const char *s1, const char *s2);
1004 void swab(const char *_RESTRICT_KYWD from, char *_RESTRICT_KYWD to, ssize_t n);
1007 int swapctl(int cmd, void *arg);
1010 long sysconf(int name);
1014 void syslog(int pri, const char *fmt, ...);
1015 void vsyslog(int pri, const char *fmt, va_list ap);
1016 void openlog(const char *ident, int logstat, int logfac);
1017 void closelog(void);
1018 int setlogmask(int pmask);
1021 int tcdrain(int fildes);
1024 int tcflow(int fildes, int action);
1027 int tcflush(int fildes, int queue_selector);
1030 int tcgetattr(int fildes, struct termios *termios_p);
1033 pid_t tcgetpgrp(int fd);
1036 pid_t tcgetsid(int fd);
1039 int tcsendbreak(int fildes, int duration);
1042 int tcsetattr(int fildes, int optional_actions,
1043 const struct termios *termios_p);
1046 int tcsetpgrp(int fd, pid_t pgrp);
1052 long telldir(DIR *dirp);
1055 void *tfind(const void *ky, void *const *rtp, int (*compar)());
1058 struct tm *localtime(const time_t *timep);
1059 struct tm *localtime_r(const time_t *_RESTRICT_KYWD, struct tm *_RESTRICT_KYWD);
1060 struct tm *gmtime(const time_t *clock);
1061 struct tm *gmtime_r(const time_t *_RESTRICT_KYWD, struct tm *_RESTRICT_KYWD);
1062 double difftime(time_t time1, time_t time0);
1063 time_t mktime(struct tm *timeptr);
1064 void _ltzset(time_t tim);
1078 int ftruncate(int fildes, off_t len);
1079 int truncate(const char *path, off_t len);
1082 void *tsearch(const void *ky, void **rtp, int (*compar)());
1083 void *tdelete(const void *ky, void **rtp, int (*compar)());
1084 void twalk(const void *rt, void (*action)());
1087 char *ttyname(int f);
1088 char *_ttyname_dev(dev_t rdev, char *buffer, size_t buflen);
1089 char *ttyname_r(int, char *, int);
1095 unsigned ualarm(unsigned usecs, unsigned reload);
1099 long ulimit(int cmd, ...);
1102 int usleep(unsigned n);
1105 void *valloc(size_t size);
1108 pid_t wait(int *stat_loc);
1109 pid_t waitpid(pid_t pid, int *stat_loc, int options);
1110 pid_t wait3(int *status, int options, struct rusage *rp);
1111 pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
1114 size_t wcstombs(char *_RESTRICT_KYWD s, const wchar_t *_RESTRICT_KYWD pwcs,
1118 int wctomb(char *s, wchar_t wchar);
1123 int wisprint(wchar_t c);
1126 void _xgetwidth(void);
1129 * /usr/src/lib/libc/port/intl routines
1133 char *bindtextdomain(const char *domain, const char *binding);
1134 char *dcgettext(const char *domain, const char *msg_id, const int category);
1135 char *dgettext(const char *domain, const char *msg_id);
1136 char *gettext(const char *msg_id);
1137 char *textdomain(const char *domain);
1140 * /usr/src/lib/libc/port/print routines
1145 int fprintf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD format, ...);
1149 int printf(const char *_RESTRICT_KYWD format, ...);
1153 int snprintf(char *_RESTRICT_KYWD string, size_t n,
1154 const char *_RESTRICT_KYWD format, ...);
1158 int sprintf(char *_RESTRICT_KYWD string,
1159 const char *_RESTRICT_KYWD format, ...);
1163 int vfprintf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD format,
1168 int vprintf(const char *_RESTRICT_KYWD format, va_list);
1172 int vsnprintf(char *_RESTRICT_KYWD string, size_t n,
1173 const char *_RESTRICT_KYWD format, va_list);
1177 int vsprintf(char *_RESTRICT_KYWD string, const char *_RESTRICT_KYWD format,
1181 * /usr/src/lib/libc/port/regex routines
1185 extern int glob(const char *restrict pattern, int flags,
1186 int(*errfunc)(const char *epath, int eerrno), glob_t *restrict pglob);
1187 extern void globfree(glob_t *pglob);
1190 char *regex(const char *regexp, const char *stringp, ...);
1197 char *regcmp(const char *regexp, ...);
1204 * /usr/src/lib/libc/port/stdio routines
1208 int _filbuf(FILE *iop);
1211 int _flsbuf(int ch, FILE *iop);
1214 int _wrtchk(FILE *iop);
1217 void clearerr(FILE *iop);
1220 char *ctermid(char *s);
1221 char *ctermid_r(char *s);
1224 char *cuserid(char *s);
1229 int _doscan(FILE *iop, const char *fmt, va_list va_alist);
1232 FILE *fdopen(int fd, const char *type);
1235 int feof(FILE *iop);
1238 int ferror(FILE *iop);
1241 int fgetc(FILE *iop);
1244 char *fgets(char *_RESTRICT_KYWD buf, int size, FILE *_RESTRICT_KYWD iop);
1247 int _fileno(FILE *iop);
1250 void _cleanup(void);
1251 FILE *_findiop(void);
1252 typedef unsigned char Uchar;
1253 void _setbufend(FILE *iop, Uchar *end);
1254 Uchar *_realbufend(FILE *iop);
1255 void _bufsync(FILE *iop, Uchar *bufend);
1256 int _xflsbuf(FILE *iop);
1257 int fflush(FILE *iop);
1258 int fclose(FILE *iop);
1261 FILE *fopen(const char *_RESTRICT_KYWD name, const char *_RESTRICT_KYWD type);
1262 FILE *freopen(const char *_RESTRICT_KYWD name, const char *_RESTRICT_KYWD type,
1263 FILE *_RESTRICT_KYWD iop);
1266 int fgetpos(FILE *_RESTRICT_KYWD stream, fpos_t *_RESTRICT_KYWD pos);
1267 int fsetpos(FILE *stream, const fpos_t *pos);
1270 int fputc(int ch, FILE *iop);
1273 int fputs(const char *_RESTRICT_KYWD ptr, FILE *_RESTRICT_KYWD iop);
1276 size_t fread(void *_RESTRICT_KYWD ptr, size_t size, size_t count,
1277 FILE *_RESTRICT_KYWD iop);
1280 int fseek(FILE *iop, long offset, int ptrname);
1283 long ftell(FILE *iop);
1286 size_t fwrite(const void *_RESTRICT_KYWD ptr1, size_t size, size_t count,
1287 FILE *_RESTRICT_KYWD iop);
1290 int getc(FILE *iop);
1296 char *getpass(const char *prompt);
1299 char *getpassphrase(const char *prompt);
1302 char *gets(char *buf);
1305 int getw(FILE *stream);
1308 FILE *popen(const char *cmd, const char *mode);
1309 int pclose(FILE *ptr);
1312 int putc(int ch, FILE *iop);
1315 int putchar(int ch);
1318 int puts(const char *ptr);
1321 int putw(int w, FILE *stream);
1324 void rewind(FILE *iop);
1328 int scanf(const char *_RESTRICT_KYWD fmt, ...);
1331 int fscanf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD fmt, ...);
1334 int sscanf(const char *_RESTRICT_KYWD str, const char *_RESTRICT_KYWD fmt, ...);
1337 void setbuf(FILE *_RESTRICT_KYWD iop, char *_RESTRICT_KYWD abuf);
1340 int setvbuf(FILE *_RESTRICT_KYWD iop, char *_RESTRICT_KYWD abuf, int type,
1344 int system(const char *s);
1347 char *tempnam(const char *dir, const char *pfx);
1350 FILE *tmpfile(void);
1353 char *tmpnam(char *s);
1354 char *tmpnam_r(char *);
1357 int ungetc(int c, FILE *iop);
1360 * /usr/src/lib/libc/port/sys routines
1364 size_t getacct(idtype_t idtype, id_t id, void *buf, size_t bufsize);
1365 int putacct(idtype_t idtype, id_t id, void *buf, size_t bufsize, int flags);
1366 int wracct(idtype_t idtype, id_t id, int flags);
1370 int execl(const char *name, const char *, ...);
1373 int execle(const char *, const char *file, ...);
1376 int execv(const char *file, char *const *argv);
1379 int lockf(int fildes, int function, off_t size);
1382 int meminfo(const uint64_t *inaddr, int addr_count, const uint_t *info_req,
1383 int info_count, uint64_t *outdata, uint_t *validity);
1386 int msgget(key_t key, int msgflg);
1387 int msgctl(int msqid, int cmd, struct msqid_ds *buf);
1388 ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
1389 int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
1393 int exportfs(char *dir, struct export *ep);
1394 int nfs_getfh(char *path, fhandle_t *fhp);
1399 int pset_create(psetid_t *npset);
1400 int pset_destroy(psetid_t pset);
1401 int pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset);
1402 int pset_assign_forced(psetid_t pset, processorid_t cpu, psetid_t *opset);
1403 int pset_info(psetid_t pset, int *type, u_int *numcpus, processorid_t *cpulist);
1404 int pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset);
1405 int pset_bind_lwp(psetid_t pset, id_t id, pid_t, psetid_t *opset);
1409 int getrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk,
1411 int setrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk,
1413 /* (private functions) */
1414 int setprojrctl(const char *name, rctlblk_t *new_rblk, size_t size, int flags);
1415 int rctlctl(const char *, rctlblk_t *, int);
1416 size_t rctllist(char *, size_t);
1420 int semctl(int semid, int semnum, int cmd, ...);
1421 int semget(key_t key, int nsems, int semflg);
1422 int semop(int semid, struct sembuf *sops, size_t nsops);
1425 void *shmat(int shmid, const void *shmaddr, int shmflg);
1426 int shmctl(int shmid, int cmd, struct shmid_ds *buf);
1427 #if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4)
1428 int shmdt(const void *);
1431 #endif /* defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4) */
1432 int shmget(key_t key, size_t size, int shmflg);
1435 taskid_t settaskid(projid_t project, uint_t flags);
1436 taskid_t gettaskid(void);
1437 projid_t getprojid(void);
1440 * /usr/src/lib/libc/port/widec routines
1444 wchar_t *fgetws(wchar_t *_RESTRICT_KYWD ptr, int size,
1445 FILE *_RESTRICT_KYWD iop);
1448 wint_t fputwc(wint_t wc, FILE *iop);
1449 wint_t putwc(wint_t wc, FILE *iop);
1452 int fputws(const wchar_t *_RESTRICT_KYWD ptr, FILE *_RESTRICT_KYWD iop);
1455 wint_t getwchar(void);
1458 void getwidth(eucwidth_t *eucstruct);
1461 wchar_t *getws(wchar_t *ptr);
1464 int iswctype(wint_t wc, wctype_t charclass);
1465 int iswalpha(wint_t c);
1466 int iswupper(wint_t c);
1467 int iswlower(wint_t c);
1468 int iswdigit(wint_t c);
1469 int iswxdigit(wint_t c);
1470 int iswalnum(wint_t c);
1471 int iswspace(wint_t c);
1472 int iswpunct(wint_t c);
1473 int iswprint(wint_t c);
1474 int iswgraph(wint_t c);
1475 int iswcntrl(wint_t c);
1476 int isphonogram(wint_t c);
1477 int isideogram(wint_t c);
1478 int isenglish(wint_t c);
1479 int isnumber(wint_t c);
1480 int isspecial(wint_t c);
1485 wint_t putwchar(wint_t c);
1488 int putws(const wchar_t *ptr);
1493 wchar_t *strtows(wchar_t *s1, char *s2);
1494 char *wstostr(char *s1, wchar_t *s2);
1497 wint_t towupper(wint_t c);
1498 wint_t towlower(wint_t c);
1501 wint_t ungetwc(wint_t wc, FILE *iop);
1504 size_t wcsxfrm(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1506 int wcscoll(const wchar_t *s1, const wchar_t *s2);
1509 #if !defined(__amd64) /* XX64 - fix me */
1510 size_t wcsftime(wchar_t *wcs, size_t maxsize,
1511 const char *format, const struct tm *timeptr);
1512 #endif /* __amd64 */
1515 wint_t fgetwc(FILE *iop);
1516 wint_t getwc(FILE *iop);
1517 int wcwidth(wchar_t wc);
1518 int wcswidth(const wchar_t *pwcs, size_t n);
1521 wchar_t *wcswcs(const wchar_t *ws1, const wchar_t *ws2);
1523 /* wcsxfrm.c - empty file! */
1525 /* wcsxfrm.xpg4.c */
1528 int wisprint(wchar_t c);
1531 int wscasecmp(const wchar_t *s1, const wchar_t *s2);
1534 wchar_t *wcscat(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2);
1535 wchar_t *wscat(wchar_t *s1, const wchar_t *s2);
1538 wchar_t *wcschr(const wchar_t *sp, wchar_t c);
1539 wchar_t *wschr(const wchar_t *sp, wchar_t c);
1542 int wcscmp(const wchar_t *s1, const wchar_t *s2);
1543 int wscmp(const wchar_t *s1, const wchar_t *s2);
1546 int wscol(const wchar_t *s1);
1549 wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2);
1550 wchar_t *wscpy(wchar_t *s1, const wchar_t *s2);
1553 size_t wcscspn(const wchar_t *string, const wchar_t *charset);
1554 size_t wscspn(const wchar_t *string, const wchar_t *charset);
1557 wchar_t *wsdup(const wchar_t *s1);
1560 size_t wcslen(const wchar_t *s);
1561 size_t wslen(const wchar_t *s);
1564 int wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1567 wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1569 wchar_t *wsncat(wchar_t *s1, const wchar_t *s2, size_t n);
1572 int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1573 int wsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1576 wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1578 wchar_t *wsncpy(wchar_t *s1, const wchar_t *s2, size_t n);
1581 wchar_t *wcspbrk(const wchar_t *string, const wchar_t *brkset);
1582 wchar_t *wspbrk(const wchar_t *string, const wchar_t *brkset);
1585 int wsprintf(wchar_t *wstring, const char *format, ...);
1588 wchar_t *wcsrchr(const wchar_t *sp, wchar_t c);
1589 wchar_t *wsrchr(const wchar_t *sp, wchar_t c);
1592 int wsscanf(wchar_t *s, const char *format, ...);
1597 size_t wcsspn(const wchar_t *string, const wchar_t *charset);
1598 size_t wsspn(const wchar_t *string, const wchar_t *charset);
1601 double wcstod(const wchar_t *_RESTRICT_KYWD cp, wchar_t **_RESTRICT_KYWD ptr);
1602 float wcstof(const wchar_t *_RESTRICT_KYWD cp, wchar_t **_RESTRICT_KYWD ptr);
1603 long double wcstold(const wchar_t *_RESTRICT_KYWD cp,
1604 wchar_t **_RESTRICT_KYWD ptr);
1605 double wstod(const wchar_t *cp, wchar_t **ptr);
1608 #if !defined(__amd64) /* XX64 - fix me */
1609 wchar_t *wcstok(wchar_t *string, const wchar_t *sepset);
1610 wchar_t *wstok(wchar_t *string, const wchar_t *sepset);
1611 #endif /* __amd64 */
1614 long wcstol(const wchar_t *_RESTRICT_KYWD str, wchar_t **_RESTRICT_KYWD ptr,
1616 long long wcstoll(const wchar_t *_RESTRICT_KYWD str,
1617 wchar_t **_RESTRICT_KYWD ptr, int base);
1620 unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD str,
1621 wchar_t **_RESTRICT_KYWD ptr, int base);
1622 unsigned long long wcstoull(const wchar_t *_RESTRICT_KYWD str,
1623 wchar_t **_RESTRICT_KYWD ptr, int base);
1626 intmax_t wcstoimax(const wchar_t *_RESTRICT_KYWD nptr,
1627 wchar_t **_RESTRICT_KYWD endptr, int base);
1628 uintmax_t wcstoumax(const wchar_t *_RESTRICT_KYWD nptr,
1629 wchar_t **_RESTRICT_KYWD endptr, int base);
1632 long wstol(const wchar_t *str, wchar_t **ptr, int base);
1635 long long wstoll(const wchar_t *str, wchar_t **ptr, int base);
1636 long long watoll(const wchar_t *p);
1639 size_t wsxfrm(wchar_t *s1, const wchar_t *s2, size_t n);
1640 int wscoll(const wchar_t *s1, const wchar_t *s2);
1643 * /usr/src/lib/libc/port/gen/event_port.c
1645 int port_dispatch(int port, int flags, int source, int events, uintptr_t object,
1649 * /usr/src/lib/libc/$MACH/gen routines
1654 void *__builtin_alloca(size_t);
1657 * modctl(int arg, ...) and utssys(...) are not available from a header
1658 * file, but our utilities which make use of it should be able to be
1661 int modctl(int arg, ...);
1662 int utssys(void *buf, int arg, int type, void *outbp);
1665 typedef float single;
1666 typedef unsigned extended[3];
1667 typedef long double quadruple;
1668 typedef unsigned fp_exception_field_type;
1670 typedef char decimal_string[512];
1672 enum fp_class_type {
1681 enum fp_direction_type {
1689 enum fp_class_type fpclass;
1703 enum fp_direction_type rd;
1704 enum decimal_form df;
1708 enum decimal_string_form {
1714 fixed_intdotfrac_form,
1716 floating_intdot_form,
1717 floating_dotfrac_form,
1718 floating_intdotfrac_form,
1725 typedef int sigfpe_code_type;
1727 typedef void (*sigfpe_handler_type)();
1729 extern sigfpe_handler_type sigfpe(sigfpe_code_type, sigfpe_handler_type);
1731 extern void single_to_decimal(single *, decimal_mode *, decimal_record *,
1732 fp_exception_field_type *);
1734 extern void double_to_decimal(double *, decimal_mode *, decimal_record *,
1735 fp_exception_field_type *);
1736 extern void extended_to_decimal(extended *, decimal_mode *,
1737 decimal_record *, fp_exception_field_type *);
1738 extern void quadruple_to_decimal(quadruple *, decimal_mode *,
1739 decimal_record *, fp_exception_field_type *);
1740 extern void decimal_to_single(single *, decimal_mode *, decimal_record *,
1741 fp_exception_field_type *);
1742 extern void decimal_to_double(double *, decimal_mode *, decimal_record *,
1743 fp_exception_field_type *);
1744 extern void decimal_to_extended(extended *, decimal_mode *,
1745 decimal_record *, fp_exception_field_type *);
1746 extern void decimal_to_quadruple(quadruple *, decimal_mode *,
1747 decimal_record *, fp_exception_field_type *);
1748 extern void string_to_decimal(char **, int, int, decimal_record *,
1749 enum decimal_string_form *, char **);
1750 extern void func_to_decimal(char **, int, int, decimal_record *,
1751 enum decimal_string_form *, char **,
1752 int (*)(void), int *, int (*)(int));
1753 extern void file_to_decimal(char **, int, int, decimal_record *,
1754 enum decimal_string_form *, char **,
1756 extern char *seconvert(single *, int, int *, int *, char *);
1757 extern char *sfconvert(single *, int, int *, int *, char *);
1758 extern char *sgconvert(single *, int, int, char *);
1759 extern char *econvert(double, int, int *, int *, char *);
1760 extern char *fconvert(double, int, int *, int *, char *);
1761 extern char *gconvert(double, int, int, char *);
1762 extern char *qeconvert(quadruple *, int, int *, int *, char *);
1763 extern char *qfconvert(quadruple *, int, int *, int *, char *);
1764 extern char *qgconvert(quadruple *, int, int, char *);
1766 extern void __assert(const char *, const char *, int);
1768 extern int setjmp(jmp_buf);
1769 extern void longjmp(jmp_buf, int);
1770 extern int sigsetjmp(sigjmp_buf, int);
1771 extern void siglongjmp(sigjmp_buf, int);
1773 int uname(struct utsname *);
1774 int _uname(struct utsname *);
1778 { return (&errno); }
1780 extern int getloadavg(double [], int);
1782 extern long pcsample(uintptr_t [], long);
1784 int fstat(int, struct stat *);
1785 int stat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD);
1786 int lstat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD);
1787 int mknod(const char *, mode_t, dev_t);
1789 extern int __init_daemon_priv(int, uid_t uid, gid_t gid, ...);
1790 extern void __fini_daemon_priv(const char *, ...);
1791 extern int __init_suid_priv(int, ...);
1792 extern int __priv_bracket(priv_op_t);
1793 extern void __priv_relinquish(void);
1794 extern const char * __priv_getsetbynum(const void *, int);
1795 extern char * __priv_set_to_str(void *, const priv_set_t *, char, int);
1797 /* private interface to get the groups list for a certain user */
1798 int _getgroupsbymember(const char *, gid_t[], int, int);
1800 /* private interface for use only by java */
1801 volatile sc_shared_t *volatile *_thr_schedctl(void);
1803 /* private interface to unmount all autofs mounts */
1804 int _autofssys(enum autofssys_op, void *);
1807 extern int is_system_labeled(void);
1809 extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *,
1811 extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int);
1812 extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *,
1814 extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int);
1815 extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
1816 extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
1817 extern int u8_validate(char *, size_t, char **, int, int *);
1818 extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
1819 extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
1822 /* private locale interfaces */
1823 wint_t __nextwctype(wint_t, wctype_t);
1824 int __iswrune(wint_t);