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 (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  */
  29 
  30 /* LINTLIBRARY */
  31 /* PROTOLIB1 */
  32 
  33 #define __EXTENSIONS__
  34 
  35 #include <aio.h>
  36 #include <alloca.h>
  37 #include <attr.h>
  38 #include <atomic.h>
  39 #include <ctype.h>
  40 #include <deflt.h>
  41 #include <dirent.h>
  42 #include <dlfcn.h>
  43 #include <door.h>
  44 #include <err.h>
  45 #include <sys/errno.h>
  46 #include <euc.h>
  47 #include <fcntl.h>
  48 #include <float.h>
  49 #include <fmtmsg.h>
  50 #include <fnmatch.h>
  51 #include <ftw.h>
  52 #include <glob.h>
  53 #include <getwidth.h>
  54 #include <grp.h>
  55 #include <iconv.h>
  56 #include <langinfo.h>
  57 #include <libgen.h>
  58 #include <libw.h>
  59 #include <locale.h>
  60 #include <memory.h>
  61 #include <mon.h>
  62 #include <mqueue.h>
  63 #include <nan.h>
  64 #include <ndbm.h>
  65 #include <limits.h>
  66 #include <nl_types.h>
  67 #include <poll.h>
  68 #include <project.h>
  69 #include <priv.h>
  70 #include <pwd.h>
  71 #include <rctl.h>
  72 #include <regex.h>
  73 #include <rpcsvc/ypclnt.h>
  74 #include <sched.h>
  75 #include <search.h>
  76 #include <semaphore.h>
  77 #include <setjmp.h>
  78 #include <shadow.h>
  79 #include <siginfo.h>
  80 #include <signal.h>
  81 #include <stdarg.h>
  82 #include <ucred.h>
  83 #include <sys/ucred.h>
  84 #include <unistd.h>
  85 #include <ulimit.h>
  86 #include <utime.h>
  87 #include <stddef.h>
  88 #include <stdio.h>
  89 #include <stdlib.h>
  90 #include <string.h>
  91 #include <stropts.h>
  92 #include <synch.h>
  93 #include <sys/acctctl.h>
  94 #include <sys/acl.h>
  95 #include <sys/asynch.h>
  96 #include <sys/byteorder.h>
  97 #include <sys/cladm.h>
  98 #include <sys/corectl.h>
  99 #include <sys/dl.h>
 100 #include <sys/exacct.h>
 101 #include <sys/fcntl.h>
 102 #include <sys/file.h>
 103 #include <sys/fs/namenode.h>
 104 #include <sys/instance.h>
 105 #include <sys/ipc.h>
 106 #include <sys/lwp.h>
 107 #include <sys/mkdev.h>
 108 #include <sys/mman.h>
 109 #include <sys/mnttab.h>
 110 #include <sys/mount.h>
 111 #include <sys/msg.h>
 112 #include <sys/param.h>
 113 #include <sys/priocntl.h>
 114 #include <sys/procset.h>
 115 #include <sys/processor.h>
 116 #include <sys/pset.h>
 117 #include <sys/rctl_impl.h>
 118 #include <sys/sem.h>
 119 #include <sys/shm.h>
 120 #include <sys/sid.h>
 121 #include <sys/signal.h>
 122 #include <sys/stat.h>
 123 #include <sys/statvfs.h>
 124 #include <sys/strlog.h>
 125 #include <sys/stropts.h>
 126 #include <sys/syscall.h>
 127 #include <sys/sysconfig.h>
 128 #include <sys/syslog.h>
 129 #include <sys/systeminfo.h>
 130 #include <sys/task.h>
 131 #include <sys/termio.h>
 132 #include <sys/termios.h>
 133 #include <sys/u8_textprep.h>
 134 #include <sys/time.h>
 135 #include <sys/timeb.h>
 136 #include <sys/times.h>
 137 #include <sys/types.h>
 138 #include <sys/uadmin.h>
 139 #include <sys/utsname.h>
 140 #include <sys/vfstab.h>
 141 #include <sys/sendfile.h>
 142 #include <sys/zone.h>
 143 #include <termio.h>
 144 #include <time.h>
 145 #include <tzfile.h>
 146 #include <ucontext.h>
 147 #include <utmpx.h>
 148 #include <values.h>
 149 #include <wait.h>
 150 #include <wchar.h>
 151 #include <wctype.h>
 152 #include <widec.h>
 153 #include <wordexp.h>
 154 #include <thread.h>
 155 #include <pthread.h>
 156 #include <schedctl.h>
 157 #include <zone.h>
 158 #include <port.h>
 159 #include <spawn.h>
 160 #include <inttypes.h>
 161 #include <getopt.h>
 162 #include <stdio_ext.h>
 163 #if defined(__i386)
 164 #include <sys/sysi86.h>
 165 #endif
 166 #if defined(__amd64)
 167 #include <stack_unwind.h>
 168 #endif
 169 #include <xlocale.h>
 170 
 171 /*
 172  * This really comes from the crt*.s startup modules.
 173  */
 174 char **environ;
 175 
 176 /*
 177  * This is a GNU/Linux/BSD compatibility interface,
 178  * not declared in any header file.
 179  */
 180 const char *__progname;
 181 
 182 /*
 183  * POSIX versions of standard libc routines; these aren't extracted
 184  * from the headers above since we cannot #define _POSIX_C_SOURCE.
 185  */
 186 int __posix_readdir_r(DIR * _RESTRICT_KYWD, struct dirent * _RESTRICT_KYWD,
 187     struct dirent ** _RESTRICT_KYWD);
 188 int __posix_getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
 189 int __posix_getgrnam_r(const char *, struct group *, char *, size_t,
 190     struct group **);
 191 int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
 192     struct passwd **);
 193 int __posix_getpwnam_r(const char *, struct passwd *, char *, size_t,
 194     struct passwd **);
 195 int __posix_sigwait(const sigset_t * _RESTRICT_KYWD, int * _RESTRICT_KYWD);
 196 char *__posix_asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
 197 char *__posix_ctime_r(const time_t *, char *);
 198 int __posix_ttyname_r(int, char *, size_t);
 199 int __posix_getlogin_r(char *, int);
 200 int __posix_getloginx_r(char *, int);
 201 
 202 /*
 203  * XPG4 versions of standard libc routines; these aren't extracted
 204  * from the headers above since we cannot #define _XPG4_2.
 205  */
 206 int __xpg4_putmsg(int, const struct strbuf *, const struct strbuf *, int);
 207 int __xpg4_putpmsg(int, const struct strbuf *, const struct strbuf *, int, int);
 208 
 209 /*
 210  * These aren't extracted from the headers above because:
 211  * - We cannot #define _STRPTIME_DONTZERO
 212  * - We cannot #define _XPG5
 213  */
 214 char *__strptime_dontzero(const char *, const char *, struct tm *);
 215 long __sysconf_xpg5(int);
 216 wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD,
 217         const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
 218 size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t,
 219         const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
 220 wint_t __fgetwc_xpg5(__FILE *);
 221 wint_t __getwc_xpg5(__FILE *);
 222 wint_t __getwchar_xpg5(void);
 223 wint_t __fputwc_xpg5(wint_t, __FILE *);
 224 wint_t __putwc_xpg5(wint_t, __FILE *);
 225 wint_t __putwchar_xpg5(wint_t);
 226 wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD);
 227 int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
 228 wint_t __ungetwc_xpg5(wint_t, __FILE *);
 229 
 230 /*
 231  * /usr/src/lib/libc/port/gen routines
 232  */
 233 
 234 /* _ctype.c */
 235 
 236 /* _loc_data.c */
 237 
 238 /* _locale.c */
 239 
 240 /* _set_tab.c */
 241 int _set_tab(const char *loc, int cat);
 242 
 243 /* _xftw.c */
 244 int _xftw(int ver, const char *path, int (*fn)(), int depth);
 245 
 246 /* a64l.c */
 247 long a64l(const char *);
 248 
 249 /* abort.c */
 250 void abort(void);
 251 
 252 /* abs.c */
 253 int abs(int arg);
 254 long labs(long int arg);
 255 
 256 /* assert.c */
 257 void _assert(const char *assertion, const char *filename, int line_num);
 258 void __assert_c99(const char *assertion, const char *filename, int line_num,
 259     const char *funcname);
 260 
 261 /* atexit.c */
 262 int atexit(void(*func)());
 263 void _exithandle(void);
 264 
 265 /* atof.c */
 266 double atof(const char *p);
 267 
 268 /* atoi.c */
 269 int atoi(const char *p);
 270 
 271 /* atol.c */
 272 long atol(const char *p);
 273 
 274 /* basename.c */
 275 char *basename(char *s);
 276 
 277 /* bcmp.c */
 278 int bcmp(const void *s1, const void *s2, size_t len);
 279 
 280 /* bcopy.c */
 281 void bcopy(const void *s1, void *s2, size_t len);
 282 
 283 /* bsearch.c */
 284 void *bsearch(const void *ky, const void *bs, size_t nel,
 285                 size_t width, int (*compar)());
 286 
 287 /* bzero.c */
 288 void bzero(void *sp, size_t len);
 289 
 290 /* calloc.c */
 291 void *calloc(size_t num, size_t size);
 292 
 293 /* catclose.c */
 294 int catclose(nl_catd catd);
 295 
 296 /* catgets.c */
 297 char *catgets(nl_catd catd, int set_num, int msg_num, const char *s);
 298 
 299 /* catopen.c */
 300 nl_catd catopen(const char *name, int mode);
 301 
 302 /* cfgetispeed.c */
 303 speed_t cfgetispeed(const struct termios *termios_p);
 304 
 305 /* cfgetospeed.c */
 306 speed_t cfgetospeed(const struct termios *termios_p);
 307 
 308 /* cfree.c */
 309 void cfree(void *p, size_t num, size_t size);
 310 
 311 /* cfsetispeed.c */
 312 int cfsetispeed(struct termios *termios_p, speed_t speed);
 313 
 314 /* cfsetospeed.c */
 315 int cfsetospeed(struct termios *termios_p, speed_t speed);
 316 
 317 /* cftime.c */
 318 int cftime(char *buf, char *format, const time_t *t);
 319 int ascftime(char *buf, const char *format, const struct tm *tm);
 320 
 321 /* clock.c */
 322 clock_t clock(void);
 323 
 324 /* closedir.c */
 325 int closedir(DIR *dirp);
 326 
 327 /* confstr.c */
 328 size_t confstr(int name, char *buf, size_t length);
 329 
 330 /* crypt.c */
 331 void setkey(const char *key);
 332 void encrypt(char *block, int fake);
 333 char *crypt(const char *key, const char *salt);
 334 
 335 /* csetlen.c */
 336 int csetlen(int cset);
 337 int csetcol(int cset);
 338 
 339 /* ctime.c */
 340 char *ctime(const time_t *t);
 341 char *ctime_r(const time_t *, char *buf, int);
 342 char *asctime(const struct tm *t);
 343 char *asctime_r(const struct tm *, char *, int);
 344 
 345 /* ctypefcns.c */
 346 int isalpha(int c);
 347 int isupper(int c);
 348 int islower(int c);
 349 int isdigit(int c);
 350 int isxdigit(int c);
 351 int isalnum(int c);
 352 int isspace(int c);
 353 int ispunct(int c);
 354 int isprint(int c);
 355 int isgraph(int c);
 356 int iscntrl(int c);
 357 int isascii(int c);
 358 int _toupper(int c);
 359 int _tolower(int c);
 360 int toascii(int c);
 361 
 362 /* daemon.c */
 363 int daemon(int nochdir, int noclose);
 364 
 365 /* directio.c */
 366 int directio(int filedes, int advice);
 367 
 368 /* dirname.c */
 369 char *dirname(char *s);
 370 
 371 /* div.c */
 372 div_t div(int numer, int denom);
 373 ldiv_t ldiv(long int numer, long int denom);
 374 
 375 /* drand48.c */
 376 double drand48(void);
 377 double erand48(unsigned short *xsubi);
 378 long krand48(unsigned short *xsubi, unsigned int m);
 379 long lrand48(void);
 380 long mrand48(void);
 381 void srand48(long seedval);
 382 unsigned short *seed48(unsigned short seed16v[3]);
 383 void lcong48(unsigned short param[7]);
 384 long nrand48(unsigned short *xsubi);
 385 long jrand48(unsigned short *xsubi);
 386 
 387 /* dup.c */
 388 int dup(int fildes);
 389 int dup2(int fildes, int fildes2);
 390 int dup3(int fildes, int fildes2, int flags);
 391 
 392 /* ecvt.c */
 393 char *ecvt(double value, int ndigit, int *_RESTRICT_KYWD decpt,
 394         int *_RESTRICT_KYWDsign);
 395 char *fcvt(double value, int ndigit, int *_RESTRICT_KYWD decpt,
 396         int *_RESTRICT_KYWD sign);
 397 
 398 /* err.c */
 399 void _errfp(FILE *, int, const char *, ...);
 400 void _verrfp(FILE *, int, const char *, va_list);
 401 void _errxfp(FILE *, int, const char *, ...);
 402 void _verrxfp(FILE *, int, const char *, va_list);
 403 void _warnfp(FILE *, const char *, ...);
 404 void _vwarnfp(FILE *, const char *, va_list);
 405 void _warnxfp(FILE *, const char *, ...);
 406 void _vwarnxfp(FILE *, const char *, va_list);
 407 
 408 /* errlst.c */
 409 
 410 /* euclen.c */
 411 int euccol(const unsigned char *s);
 412 int euclen(const unsigned char *s);
 413 int eucscol(const unsigned char *s);
 414 
 415 /* execvp.c */
 416 /* VARARGS1 */
 417 int execlp(const char *, const char *, ...);
 418 int execvp(const char *name, char *const *argv);
 419 
 420 /* fattach.c */
 421 int fattach(int fildes, const char *path);
 422 
 423 /* fdetach.c */
 424 int fdetach(const char *path);
 425 
 426 /* fexecve.c */
 427 int fexecve(int, char *const argv[], char *const envp[]);
 428 
 429 /* ffs.c */
 430 int ffs(int field);
 431 
 432 /* fmtmsg.c */
 433 int addseverity(int value, const char *string);
 434 int fmtmsg(long class, const char *label, int severity, const char *text,
 435                 const char *action, const char *tag);
 436 
 437 /* ftime.c */
 438 int ftime(struct timeb *tp);
 439 
 440 /* ftok.c */
 441 key_t ftok(const char *path, int id);
 442 
 443 /* gcvt.c */
 444 char *gcvt(double number, int ndigit, char *buf);
 445 
 446 /* getcwd.c */
 447 char *getcwd(char *str, size_t size);
 448 
 449 /* getdate.c */
 450 struct tm *getdate(const char *expression);
 451 #ifdef getdate_err
 452 #undef getdate_err
 453 #endif
 454 int getdate_err;
 455 
 456 /* getdate_data.c */
 457 
 458 /* getdate_gd.c */
 459 
 460 /* getdtblsize.c */
 461 int getdtablesize(void);
 462 
 463 /* getenv.c */
 464 char *getenv(const char *name);
 465 
 466 /* getexecname.c */
 467 const char *getexecname(void);
 468 
 469 /* getgrnam.c */
 470 struct group *getgrnam(const char *name);
 471 struct group *getgrgid(gid_t gid);
 472 struct group *fgetgrent_r(FILE *, struct group *, char *, int);
 473 struct group *getgrent_r(struct group *, char *, int);
 474 struct group *getgrgid_r(gid_t, struct group *, char *, int);
 475 struct group *getgrnam_r(const char *, struct group *, char *, int);
 476 
 477 /* gethostid.c */
 478 long gethostid(void);
 479 
 480 /* gethz.c */
 481 int gethz(void);
 482 
 483 /* getisax.c */
 484 uint_t getisax(uint32_t *, uint_t);
 485 
 486 /* getlogin.c */
 487 char *getloginx(void);
 488 char *getloginx_r(char *, int);
 489 #ifdef  getlogin
 490 #undef  getlogin
 491 #endif  /* getlogin */
 492 char *getlogin(void);
 493 #ifdef  getlogin_r
 494 #undef  getlogin_r
 495 #endif  /* getlogin_r */
 496 char *getlogin_r(char *, int);
 497 
 498 /* getmntent.c */
 499 int getmntany(FILE *fd, struct mnttab *mgetp, struct mnttab *mrefp);
 500 int getmntent(FILE *fd, struct mnttab *mp);
 501 
 502 /* getnetgrent.c */
 503 int setnetgrent(const char *grp);
 504 int endnetgrent(void);
 505 int getnetgrent(char **machinep, char **namep, char **domainp);
 506 
 507 /* getopt.c */
 508 int getopt(int argc, char *const *argv, const char *opts);
 509 
 510 /* getopt_long.c */
 511 int getopt_clip(int argc, char *const *argv, const char *optstring,
 512                 const struct option *long_options, int *long_index);
 513 int getopt_long(int argc, char *const *argv, const char *optstring,
 514                 const struct option *long_options, int *long_index);
 515 int getopt_long_only(int argc, char *const *argv, const char *optstring,
 516                 const struct option *long_options, int *long_index);
 517 
 518 /* getpagesize.c */
 519 int getpagesize(void);
 520 
 521 /* getpw.c */
 522 int getpw(uid_t uid, char *buf);
 523 
 524 /* getpwnam.c */
 525 struct passwd *getpwnam(const char *name);
 526 struct passwd *getpwuid(uid_t uid);
 527 struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int);
 528 struct passwd *getpwent_r(struct passwd *, char *, int);
 529 struct passwd *getpwnam_r(const char *, struct passwd *, char *, int);
 530 struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
 531 
 532 /* getrusage.c */
 533 int getrusage(int who, struct rusage *rusage);
 534 
 535 /* gettimeofday.c */
 536 int gettimeofday(struct timeval *_RESTRICT_KYWD tp, void *_RESTRICT_KYWD);
 537 
 538 /* getspent.c */
 539 void setspent(void);
 540 void endspent(void);
 541 struct spwd *getspent(void);
 542 struct spwd *getspent_r(struct spwd *, char *, int);
 543 struct spwd *fgetspent(FILE *f);
 544 struct spwd *fgetspent_r(FILE *, struct spwd *, char *, int);
 545 struct spwd *getspnam(const char *name);
 546 struct spwd *getspnam_r(const char *, struct spwd *, char *, int);
 547 int putspent(const struct spwd *p, FILE *f);
 548 
 549 /* getspent_r.c */
 550 int str2spwd(const char *, int, void *, char *, int);
 551 
 552 /* getsubopt.c */
 553 int getsubopt(char **optionsp, char *const *tokens, char **valuep);
 554 
 555 /* gettxt.c */
 556 char *gettxt(const char *msg_id, const char *dflt_str);
 557 
 558 /* getusershell.c */
 559 char *getusershell(void);
 560 void endusershell(void);
 561 void setusershell(void);
 562 
 563 /* getut.c */
 564 struct utmp *getutent(void);
 565 struct utmp *getutid(const struct utmp *entry);
 566 struct utmp *getutline(const struct utmp *entry);
 567 struct utmp *pututline(const struct utmp *entry);
 568 void setutent(void);
 569 void endutent(void);
 570 int utmpname(const char *newfile);
 571 void updwtmp(const char *file, struct utmp *ut);
 572 void getutmp(const struct utmpx *utx, struct utmp *ut);
 573 void getutmpx(const struct utmp *ut, struct utmpx *utx);
 574 struct utmp *makeut(struct utmp *utmp);
 575 
 576 /* getutx.c */
 577 struct utmpx *getutxent(void);
 578 struct utmpx *getutxid(const struct utmpx *entry);
 579 struct utmpx *getutxline(const struct utmpx *entry);
 580 struct utmpx *pututxline(const struct utmpx *entry);
 581 void setutxent(void);
 582 void endutxent(void);
 583 int utmpxname(const char *newfile);
 584 void updwtmpx(const char *filex, struct utmpx *utx);
 585 struct utmpx *makeutx(const struct utmpx *utmp);
 586 struct utmpx *modutx(const struct utmpx *utp);
 587 
 588 /* getvfsent.c */
 589 int getvfsspec(FILE *fd, struct vfstab *vp, char *special);
 590 int getvfsfile(FILE *fd, struct vfstab *vp, char *mountp);
 591 int getvfsany(FILE *fd, struct vfstab *vgetp, struct vfstab *vrefp);
 592 int getvfsent(FILE *fd, struct vfstab *vp);
 593 
 594 /* getwd.c */
 595 char *getwd(char *pathname);
 596 
 597 /* getwidth.c */
 598 void getwidth(eucwidth_t *eucstruct);
 599 
 600 /* hsearch.c */
 601 int hcreate(size_t size);
 602 void hdestroy(void);
 603 ENTRY *hsearch(ENTRY item, ACTION action);
 604 
 605 /* iconv.c  */
 606 size_t iconv(iconv_t cd, const char **_RESTRICT_KYWD inbuf,
 607     size_t *_RESTRICT_KYWD inbytesleft, char **_RESTRICT_KYWD outbuf,
 608     size_t *_RESTRICT_KYWD outbytesleft);
 609 int iconv_close(iconv_t cd);
 610 iconv_t iconv_open(const char *tocode, const char *fromcode);
 611 
 612 /* imaxabs.c */
 613 intmax_t imaxabs(intmax_t j);
 614 
 615 /* imaxdiv.c */
 616 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
 617 
 618 /* index.c */
 619 char *index(const char *sp, int c);
 620 
 621 /* initgroups.c */
 622 int initgroups(const char *uname, gid_t agroup);
 623 
 624 /* innetgr.c */
 625 int innetgr(const char *group, const char *machine, const char *name,
 626     const char *domain);
 627 
 628 /* insque.c */
 629 void insque(void *elem, void *pred);
 630 void remque(void *elem);
 631 
 632 /* isaexec.c */
 633 int isaexec(const char *, char *const *, char *const *);
 634 
 635 /* isastream.c */
 636 int isastream(int fd);
 637 
 638 /* isatty.c */
 639 int isatty(int f);
 640 
 641 /* killpg.c */
 642 int killpg(pid_t pgrp, int sig);
 643 
 644 /* l64a.c */
 645 char *l64a(long lg);
 646 
 647 /* lckpwdf.c */
 648 int lckpwdf(void);
 649 int ulckpwdf(void);
 650 
 651 /* lfind.c */
 652 void * lfind(const void *ky, const void *bs, size_t *nelp,
 653                 size_t width, int (*compar)());
 654 
 655 /* localeconv.c */
 656 struct lconv *localeconv(void);
 657 
 658 /* lsearch.c */
 659 void * lsearch(const void *ky, void *bs, size_t *nelp,
 660                 size_t width, int (*compar)());
 661 
 662 /* madvise.c */
 663 int madvise(caddr_t addr, size_t len, int advice);
 664 
 665 /* malloc.c */
 666 void *malloc(size_t size);
 667 void *realloc(void *old, size_t size);
 668 void free(void *old);
 669 
 670 /* mbstowcs.c */
 671 size_t mbstowcs(wchar_t *_RESTRICT_KYWD pwcs, const char *_RESTRICT_KYWD s,
 672         size_t n);
 673 
 674 /* mbtowc.c */
 675 int mbtowc(wchar_t *_RESTRICT_KYWD wchar, const char *_RESTRICT_KYWD s,
 676         size_t n);
 677 int mblen(const char *s, size_t n);
 678 
 679 /* memalign.c */
 680 void *memalign(size_t align, size_t nbytes);
 681 
 682 /* memccpy.c */
 683 void *memccpy(void *_RESTRICT_KYWDs, const void *_RESTRICT_KYWD s0, int c,
 684         size_t n);
 685 
 686 /* memchr.c */
 687 void *memchr(const void *sptr, int c1, size_t n);
 688 
 689 /* memcmp.c */
 690 int memcmp(const void *s1, const void *s2, size_t n);
 691 
 692 /* memcpy.c */
 693 void *memcpy(void *_RESTRICT_KYWD s, const void *_RESTRICT_KYWD s0, size_t n);
 694 
 695 /* memmove.c */
 696 void *memmove(void *s, const void *s0, size_t n);
 697 
 698 /* memset.c */
 699 void *memset(void *sp1, int c, size_t n);
 700 
 701 /* mkdev.c */
 702 dev_t __makedev(const int version, const major_t majdev,
 703                 const minor_t mindev);
 704 major_t __major(const int version, const dev_t devnum);
 705 minor_t __minor(const int version, const dev_t devnum);
 706 
 707 /* mkfifo.c */
 708 int mkfifo(const char *path, mode_t mode);
 709 
 710 /* mktemp.c */
 711 char *mktemp(char *as);
 712 
 713 /* mlock.c */
 714 int mlock(caddr_t addr, size_t len);
 715 
 716 /* mlockall.c */
 717 int mlockall(int flags);
 718 
 719 /* mon.c */
 720 void monitor(int (*alowpc)(), int (*ahighpc)(), WORD *buffer,
 721                 size_t bufsize, size_t nfunc);
 722 
 723 /* msync.c */
 724 int msync(caddr_t addr, size_t len, int flags);
 725 
 726 /* munlock.c */
 727 int munlock(caddr_t addr, size_t len);
 728 
 729 /* munlockall.c */
 730 int munlockall(void);
 731 
 732 /* ndbm.c */
 733 void dbm_setdefwrite(DBM *db);
 734 int dbm_flush(DBM *db);
 735 int dbm_flushpag(DBM *db);
 736 DBM *dbm_open(const char *file, int flags, mode_t mode);
 737 void dbm_close(DBM *db);
 738 int dbm_close_status(DBM *db);
 739 datum dbm_fetch(DBM *db, datum key);
 740 int dbm_delete(DBM *db, datum key);
 741 int dbm_store(DBM *db, datum key, datum dat, int replace);
 742 datum dbm_firstkey(DBM *db);
 743 datum dbm_nextkey(DBM *db);
 744 datum dbm_do_nextkey(DBM *db, datum inkey);
 745 
 746 /* new_list.c */
 747 
 748 /* nftw.c */
 749 int nftw(const char *path, int (*fn)(), int depth, int flags);
 750 
 751 /* nl_langinfo.c */
 752 char *nl_langinfo(nl_item item);
 753 
 754 /* opendir.c */
 755 DIR *opendir(const char *filename);
 756 
 757 /* opt_data.c */
 758 
 759 /* perror.c */
 760 void perror(const char *s);
 761 
 762 /* pipe.c */
 763 int pipe(int *fds);
 764 
 765 /* psiginfo.c */
 766 void psiginfo(siginfo_t *sip, char *s);
 767 
 768 /* psignal.c */
 769 void psignal(int sig, const char *s);
 770 
 771 /* pt.c */
 772 char *ptsname(int fd);
 773 int unlockpt(int fd);
 774 int grantpt(int fd);
 775 
 776 /* putenv.c */
 777 int putenv(char *change);
 778 int setenv(const char *envname, const char *envval, int overwrite);
 779 int unsetenv(const char *name);
 780 
 781 /* putpwent.c */
 782 int putpwent(const struct passwd *p, FILE *f);
 783 
 784 /* qsort.c */
 785 void qsort(void *base, size_t n, size_t size, int (*compar)());
 786 
 787 /* raise.c */
 788 int raise(int sig);
 789 
 790 /* rand.c */
 791 void srand(unsigned x);
 792 int rand(void);
 793 int rand_r(unsigned int *);
 794 
 795 /* random.c */
 796 void srandom(unsigned x);
 797 char *initstate(unsigned seed, char *arg_state, size_t n);
 798 char *setstate(const char *arg_state);
 799 long random(void);
 800 
 801 /* rctlops.c */
 802 int rctl_walk(int (*callback)(const char *, void *), void *walk_data);
 803 hrtime_t rctlblk_get_firing_time(rctlblk_t *rblk);
 804 uint_t rctlblk_get_global_action(rctlblk_t *rblk);
 805 uint_t rctlblk_get_global_flags(rctlblk_t *rblk);
 806 uint_t rctlblk_get_local_action(rctlblk_t *rblk, int *signalp);
 807 uint_t rctlblk_get_local_flags(rctlblk_t *rblk);
 808 id_t rctlblk_get_recipient_pid(rctlblk_t *rblk);
 809 rctl_priv_t rctlblk_get_privilege(rctlblk_t *rblk);
 810 rctl_qty_t rctlblk_get_value(rctlblk_t *rblk);
 811 void rctlblk_set_local_action(rctlblk_t *rblk, uint_t action, int signal);
 812 void rctlblk_set_local_flags(rctlblk_t *rblk, uint_t flags);
 813 void rctlblk_set_privilege(rctlblk_t *rblk, rctl_priv_t priv);
 814 void rctlblk_set_value(rctlblk_t *rblk, rctl_qty_t val);
 815 size_t rctlblk_size(void);
 816 
 817 /* readdir.c */
 818 struct dirent *readdir(DIR *dirp);
 819 
 820 /* realpath.c */
 821 char *realpath(const char *_RESTRICT_KYWD raw, char *_RESTRICT_KYWD canon);
 822 
 823 /* regexpr.c */
 824 char *re_comp(const char *sp);
 825 int re_exec(const char *p1);
 826 
 827 /* rindex.c */
 828 char *rindex(const char *sp, int c);
 829 
 830 /* rename.c */
 831 int remove(const char *filename);
 832 int rename(const char *old, const char *new);
 833 
 834 /* rewinddir.c */
 835 #undef rewinddir
 836 void rewinddir(DIR *dirp);
 837 
 838 /* scandir.c */
 839 int alphasort(const struct dirent **, const struct dirent **);
 840 int scandir(const char *dirname, struct dirent *(*namelist[]),
 841         int (*select)(const struct dirent *),
 842         int (*dcomp)(const struct dirent **, const struct dirent **));
 843 
 844 /* scrwidth.c */
 845 int scrwidth(wchar_t c);
 846 
 847 /* seekdir.c */
 848 void seekdir(DIR *dirp, long loc);
 849 
 850 /* select.c */
 851 int pselect(int nfds,
 852         fd_set *_RESTRICT_KYWD readfds,
 853         fd_set *_RESTRICT_KYWD writefds,
 854         fd_set *_RESTRICT_KYWD errorfds,
 855         const struct timespec *_RESTRICT_KYWD timeout,
 856         const sigset_t *_RESTRICT_KYWD sigmask);
 857 int select(int nfds,
 858         fd_set *_RESTRICT_KYWD readfds,
 859         fd_set *_RESTRICT_KYWD writefds,
 860         fd_set *_RESTRICT_KYWD errorfds,
 861         struct timeval *_RESTRICT_KYWD timeout);
 862 
 863 /* setlocale.c */
 864 char *setlocale(int cat, const char *loc);
 865 
 866 /* setpriority.c */
 867 int getpriority(int which, id_t who);
 868 int setpriority(int which, id_t who, int prio);
 869 
 870 /* settimeofday.c */
 871 int settimeofday(struct timeval *tp, void *);
 872 
 873 /* sigflag.c */
 874 int sigflag(int sig, int flag, int on);
 875 
 876 /* siglist.c */
 877 
 878 /* sigsend.c */
 879 int sigsend(idtype_t idtype, id_t id, int sig);
 880 
 881 /* sigsetops.c */
 882 int sigfillset(sigset_t *set);
 883 int sigemptyset(sigset_t *set);
 884 int sigaddset(sigset_t *set, int sig);
 885 int sigdelset(sigset_t *set, int sig);
 886 int sigismember(const sigset_t *set, int sig);
 887 
 888 /* scalls.c */
 889 unsigned sleep(unsigned sleep_tm);
 890 
 891 /* ssignal.c */
 892 int (*ssignal(int sig, int (*fn)())) ();
 893 int gsignal(int sig);
 894 
 895 /* str2id.c */
 896 
 897 /* str2sig.c */
 898 int str2sig(const char *s, int *sigp);
 899 int sig2str(int i, char *s);
 900 
 901 /* strcat.c */
 902 char *strcat(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2);
 903 
 904 /* strchr.c */
 905 char *strchr(const char *sp, int c);
 906 
 907 /* strcmp.c */
 908 int strcmp(const char *s1, const char *s2);
 909 
 910 /* strcpy.c */
 911 char *strcpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2);
 912 
 913 /* strcspn.c */
 914 size_t strcspn(const char *string, const char *charset);
 915 
 916 /* strdup.c */
 917 char *strdup(const char *s1);
 918 
 919 /* strerror.c */
 920 char *strerror(int errnum);
 921 int strerror_r(int errnum, char *strerrbuf, size_t buflen);
 922 
 923 /* strftime.c */
 924 size_t strftime(char *_RESTRICT_KYWD s, size_t maxsize,
 925                 const char *_RESTRICT_KYWD format,
 926                 const struct tm *_RESTRICT_KYWD tm);
 927 
 928 /* strlen.c */
 929 size_t strlen(const char *s);
 930 
 931 /* strncat.c */
 932 char *strncat(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n);
 933 
 934 /* strncmp.c */
 935 int strncmp(const char *s1, const char *s2, size_t n);
 936 
 937 /* strncpy.c */
 938 char *strncpy(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2, size_t n);
 939 
 940 /* strpbrk.c */
 941 char *strpbrk(const char *string, const char *brkset);
 942 
 943 /* strrchr.c */
 944 char *strrchr(const char *sp, int c);
 945 
 946 /* strsep.c */
 947 char *strsep(char **stringp, const char *delim);
 948 
 949 /* strspn.c */
 950 size_t strspn(const char *string, const char *charset);
 951 
 952 /* strstr.c */
 953 char *strstr(const char *as1, const char *as2);
 954 
 955 /* strtod.c */
 956 double strtod(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
 957 float strtof(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
 958 long double strtold(const char *_RESTRICT_KYWD cp, char **_RESTRICT_KYWD ptr);
 959 
 960 /* strtoimax.c */
 961 intmax_t strtoimax(const char *_RESTRICT_KYWD nptr,
 962         char **_RESTRICT_KYWD endptr, int base);
 963 
 964 /* strtok.c */
 965 char *strtok(char *_RESTRICT_KYWD string, const char *_RESTRICT_KYWD sepset);
 966 char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
 967         char **_RESTRICT_KYWD);
 968 
 969 /* strtol.c */
 970 long strtol(const char *_RESTRICT_KYWD str, char **_RESTRICT_KYWD nptr,
 971         int base);
 972 
 973 /* strtoul.c */
 974 unsigned long strtoul(const char *_RESTRICT_KYWD str,
 975         char **_RESTRICT_KYWD nptr, int base);
 976 
 977 /* strtoumax.c */
 978 uintmax_t strtoumax(const char *_RESTRICT_KYWD nptr,
 979                     char **_RESTRICT_KYWD endptr, int base);
 980 
 981 /* strxfrm.c */
 982 size_t strxfrm(char *_RESTRICT_KYWD s1, const char *_RESTRICT_KYWD s2,
 983         size_t n);
 984 int strcoll(const char *s1, const char *s2);
 985 
 986 /* swab.c */
 987 void swab(const char *_RESTRICT_KYWD from, char *_RESTRICT_KYWD to, ssize_t n);
 988 
 989 /* swapctl.c */
 990 int swapctl(int cmd, void *arg);
 991 
 992 /* sysconf.c */
 993 long sysconf(int name);
 994 
 995 /* syslog.c */
 996 /* VARARGS2 */
 997 void syslog(int pri, const char *fmt, ...);
 998 void vsyslog(int pri, const char *fmt, va_list ap);
 999 void openlog(const char *ident, int logstat, int logfac);
1000 void closelog(void);
1001 int setlogmask(int pmask);
1002 
1003 /* tcdrain.c */
1004 int tcdrain(int fildes);
1005 
1006 /* tcflow.c */
1007 int tcflow(int fildes, int action);
1008 
1009 /* tcflush.c */
1010 int tcflush(int fildes, int queue_selector);
1011 
1012 /* tcgetattr.c */
1013 int tcgetattr(int fildes, struct termios *termios_p);
1014 
1015 /* tcgetpgrp.c */
1016 pid_t tcgetpgrp(int fd);
1017 
1018 /* tcgetsid.c */
1019 pid_t tcgetsid(int fd);
1020 
1021 /* tcsendbreak.c */
1022 int tcsendbreak(int fildes, int duration);
1023 
1024 /* tcsetattr.c */
1025 int tcsetattr(int fildes, int optional_actions,
1026         const struct termios *termios_p);
1027 
1028 /* tcsetpgrp.c */
1029 int tcsetpgrp(int fd, pid_t pgrp);
1030 
1031 /* tell.c */
1032 long tell(int f);
1033 
1034 /* telldir.c */
1035 long telldir(DIR *dirp);
1036 
1037 /* tfind.c */
1038 void *tfind(const void *ky, void *const *rtp, int (*compar)());
1039 
1040 /* time_comm.c */
1041 struct tm *localtime(const time_t *timep);
1042 struct tm *localtime_r(const time_t *_RESTRICT_KYWD, struct tm *_RESTRICT_KYWD);
1043 struct tm *gmtime(const time_t *clock);
1044 struct tm *gmtime_r(const time_t *_RESTRICT_KYWD, struct tm *_RESTRICT_KYWD);
1045 double difftime(time_t time1, time_t time0);
1046 time_t mktime(struct tm *timeptr);
1047 void _ltzset(time_t tim);
1048 void tzset(void);
1049 
1050 /* time_data.c */
1051 
1052 /* time_gdata.c */
1053 
1054 /* tolower.c */
1055 int tolower(int c);
1056 
1057 /* toupper.c */
1058 int toupper(int c);
1059 
1060 /* truncate.c */
1061 int ftruncate(int fildes, off_t len);
1062 int truncate(const char *path, off_t len);
1063 
1064 /* tsearch.c */
1065 void *tsearch(const void *ky, void **rtp, int (*compar)());
1066 void *tdelete(const void *ky, void **rtp, int (*compar)());
1067 void twalk(const void *rt, void (*action)());
1068 
1069 /* ttyname.c */
1070 char *ttyname(int f);
1071 char *_ttyname_dev(dev_t rdev, char *buffer, size_t buflen);
1072 char *ttyname_r(int, char *, int);
1073 
1074 /* ttyslot.c */
1075 int ttyslot(void);
1076 
1077 /* ualarm.c */
1078 unsigned ualarm(unsigned usecs, unsigned reload);
1079 
1080 /* ulimit.c */
1081 /* VARARGS1 */
1082 long ulimit(int cmd, ...);
1083 
1084 /* scalls.c */
1085 int usleep(unsigned n);
1086 
1087 /* valloc.c */
1088 void *valloc(size_t size);
1089 
1090 /* waitpid.c */
1091 pid_t wait(int *stat_loc);
1092 pid_t waitpid(pid_t pid, int *stat_loc, int options);
1093 pid_t wait3(int *status, int options, struct rusage *rp);
1094 pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
1095 
1096 /* wcstombs.c */
1097 size_t wcstombs(char *_RESTRICT_KYWD s, const wchar_t *_RESTRICT_KYWD pwcs,
1098         size_t n);
1099 
1100 /* wctomb.c */
1101 int wctomb(char *s, wchar_t wchar);
1102 
1103 /* wdata.c */
1104 
1105 /* wisprint.c */
1106 int wisprint(wchar_t c);
1107 
1108 /* xgetwidth.c */
1109 void _xgetwidth(void);
1110 
1111 /*
1112  * /usr/src/lib/libc/port/intl routines
1113  */
1114 
1115 /* gettext.c */
1116 char *bindtextdomain(const char *domain, const char *binding);
1117 char *dcgettext(const char *domain, const char *msg_id, const int category);
1118 char *dgettext(const char *domain, const char *msg_id);
1119 char *gettext(const char *msg_id);
1120 char *textdomain(const char *domain);
1121 
1122 /*
1123  * /usr/src/lib/libc/port/print routines
1124  */
1125 
1126 /* fprintf.c */
1127 /* VARARGS2 */
1128 int fprintf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD format, ...);
1129 
1130 /* printf.c */
1131 /* VARARGS1 */
1132 int printf(const char *_RESTRICT_KYWD format, ...);
1133 
1134 /* snprintf.c */
1135 /* VARARGS2 */
1136 int snprintf(char *_RESTRICT_KYWD string, size_t n,
1137                 const char *_RESTRICT_KYWD format, ...);
1138 
1139 /* sprintf.c */
1140 /* VARARGS2 */
1141 int sprintf(char *_RESTRICT_KYWD string,
1142                 const char *_RESTRICT_KYWD format, ...);
1143 
1144 /* vfprintf.c */
1145 /* VARARGS2 */
1146 int vfprintf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD format,
1147                 va_list);
1148 
1149 /* vprintf.c */
1150 /* VARARGS1 */
1151 int vprintf(const char *_RESTRICT_KYWD format, va_list);
1152 
1153 /* vsnprintf.c */
1154 /* VARARGS2 */
1155 int vsnprintf(char *_RESTRICT_KYWD string, size_t n,
1156                 const char *_RESTRICT_KYWD format, va_list);
1157 
1158 /* vsprintf.c */
1159 /* VARARGS2 */
1160 int vsprintf(char *_RESTRICT_KYWD string, const char *_RESTRICT_KYWD format,
1161         va_list);
1162 
1163 /*
1164  * /usr/src/lib/libc/port/regex routines
1165  */
1166 
1167 /* glob.c */
1168 extern int glob(const char *restrict pattern, int flags,
1169     int(*errfunc)(const char *epath, int eerrno), glob_t *restrict pglob);
1170 extern void globfree(glob_t *pglob);
1171 
1172 /* regex.c */
1173 char *regex(const char *regexp, const char *stringp, ...);
1174 #ifdef __loc1
1175 #undef __loc1
1176 #endif
1177 char *__loc1;
1178 
1179 /* regcmp.c */
1180 char *regcmp(const char *regexp, ...);
1181 #ifdef __i_size
1182 #undef __i_size
1183 #endif
1184 int __i_size;
1185 
1186 /*
1187  * /usr/src/lib/libc/port/stdio routines
1188  */
1189 
1190 /* _filbuf.c */
1191 int _filbuf(FILE *iop);
1192 
1193 /* _flsbuf.c */
1194 int _flsbuf(int ch, FILE *iop);
1195 
1196 /* _wrtchk.c */
1197 int _wrtchk(FILE *iop);
1198 
1199 /* clearerr.c */
1200 void clearerr(FILE *iop);
1201 
1202 /* ctermid.c */
1203 char *ctermid(char *s);
1204 char *ctermid_r(char *s);
1205 
1206 /* cuserid.c */
1207 char *cuserid(char *s);
1208 
1209 /* data.c */
1210 
1211 /* doscan.c */
1212 int _doscan(FILE *iop, const char *fmt, va_list va_alist);
1213 
1214 /* fdopen.c */
1215 FILE *fdopen(int fd, const char *type);
1216 
1217 /* feof.c */
1218 int feof(FILE *iop);
1219 
1220 /* ferror.c */
1221 int ferror(FILE *iop);
1222 
1223 /* fgetc.c */
1224 int fgetc(FILE *iop);
1225 
1226 /* fgets.c */
1227 char *fgets(char *_RESTRICT_KYWD buf, int size, FILE *_RESTRICT_KYWD iop);
1228 
1229 /* fileno.c */
1230 int _fileno(FILE *iop);
1231 
1232 /* flush.c */
1233 void _cleanup(void);
1234 FILE *_findiop(void);
1235 typedef unsigned char Uchar;
1236 void _setbufend(FILE *iop, Uchar *end);
1237 Uchar *_realbufend(FILE *iop);
1238 void _bufsync(FILE *iop, Uchar *bufend);
1239 int _xflsbuf(FILE *iop);
1240 int fflush(FILE *iop);
1241 int fclose(FILE *iop);
1242 
1243 /* fopen.c */
1244 FILE *fopen(const char *_RESTRICT_KYWD name, const char *_RESTRICT_KYWD type);
1245 FILE *freopen(const char *_RESTRICT_KYWD name, const char *_RESTRICT_KYWD type,
1246                 FILE *_RESTRICT_KYWD iop);
1247 
1248 /* fpos.c */
1249 int fgetpos(FILE *_RESTRICT_KYWD stream, fpos_t *_RESTRICT_KYWD pos);
1250 int fsetpos(FILE *stream, const fpos_t *pos);
1251 
1252 /* fputc.c */
1253 int fputc(int ch, FILE *iop);
1254 
1255 /* fputs.c */
1256 int fputs(const char *_RESTRICT_KYWD ptr, FILE *_RESTRICT_KYWD iop);
1257 
1258 /* fread.c */
1259 size_t fread(void *_RESTRICT_KYWD ptr, size_t size, size_t count,
1260         FILE *_RESTRICT_KYWD iop);
1261 
1262 /* fseek.c */
1263 int fseek(FILE *iop, long offset, int ptrname);
1264 
1265 /* ftell.c */
1266 long ftell(FILE *iop);
1267 
1268 /* fwrite.c */
1269 size_t fwrite(const void *_RESTRICT_KYWD ptr1, size_t size, size_t count,
1270         FILE *_RESTRICT_KYWD iop);
1271 
1272 /* getc.c */
1273 int getc(FILE *iop);
1274 
1275 /* getchar.c */
1276 int getchar(void);
1277 
1278 /* getpass.c */
1279 char *getpass(const char *prompt);
1280 
1281 /* getpass.c */
1282 char *getpassphrase(const char *prompt);
1283 
1284 /* gets.c */
1285 char *gets(char *buf);
1286 
1287 /* getw.c */
1288 int getw(FILE *stream);
1289 
1290 /* popen.c */
1291 FILE *popen(const char *cmd, const char *mode);
1292 int pclose(FILE *ptr);
1293 
1294 /* putc.c */
1295 int putc(int ch, FILE *iop);
1296 
1297 /* putchar.c */
1298 int putchar(int ch);
1299 
1300 /* puts.c */
1301 int puts(const char *ptr);
1302 
1303 /* putw.c */
1304 int putw(int w, FILE *stream);
1305 
1306 /* rewind.c */
1307 void rewind(FILE *iop);
1308 
1309 /* scanf.c */
1310 /* VARARGS1 */
1311 int scanf(const char *_RESTRICT_KYWD fmt, ...);
1312 
1313 /* VARARGS2 */
1314 int fscanf(FILE *_RESTRICT_KYWD iop, const char *_RESTRICT_KYWD fmt, ...);
1315 
1316 /* VARARGS2 */
1317 int sscanf(const char *_RESTRICT_KYWD str, const char *_RESTRICT_KYWD fmt, ...);
1318 
1319 /* setbuf.c */
1320 void setbuf(FILE *_RESTRICT_KYWD iop, char *_RESTRICT_KYWD abuf);
1321 
1322 /* setvbuf.c */
1323 int setvbuf(FILE *_RESTRICT_KYWD iop, char *_RESTRICT_KYWD abuf, int type,
1324                 size_t size);
1325 
1326 /* system.c */
1327 int system(const char *s);
1328 
1329 /* tempnam.c */
1330 char *tempnam(const char *dir, const char *pfx);
1331 
1332 /* tmpfile.c */
1333 FILE *tmpfile(void);
1334 
1335 /* tmpnam.c */
1336 char *tmpnam(char *s);
1337 char *tmpnam_r(char *);
1338 
1339 /* ungetc.c */
1340 int ungetc(int c, FILE *iop);
1341 
1342 /*
1343  * /usr/src/lib/libc/port/sys routines
1344  */
1345 
1346 /* exacctsys.c */
1347 size_t getacct(idtype_t idtype, id_t id, void *buf, size_t bufsize);
1348 int putacct(idtype_t idtype, id_t id, void *buf, size_t bufsize, int flags);
1349 int wracct(idtype_t idtype, id_t id, int flags);
1350 
1351 /* execl.c */
1352 /* VARARGS1 */
1353 int execl(const char *name, const char *, ...);
1354 
1355 /* execle.c */
1356 int execle(const char *, const char *file, ...);
1357 
1358 /* execv.c */
1359 int execv(const char *file, char *const *argv);
1360 
1361 /* lockf.c */
1362 int lockf(int fildes, int function, off_t size);
1363 
1364 /* meminfosys.c */
1365 int meminfo(const uint64_t *inaddr, int addr_count, const uint_t *info_req,
1366         int info_count, uint64_t *outdata, uint_t *validity);
1367 
1368 /* msgsys.c */
1369 int msgget(key_t key, int msgflg);
1370 int msgctl(int msqid, int cmd, struct msqid_ds *buf);
1371 ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
1372 int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
1373 
1374 /* nfssys.c */
1375 /*
1376 int exportfs(char *dir, struct export *ep);
1377 int nfs_getfh(char *path, fhandle_t *fhp);
1378 int nfssvc(int fd);
1379 */
1380 
1381 /* psetsys.c */
1382 int pset_create(psetid_t *npset);
1383 int pset_destroy(psetid_t pset);
1384 int pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset);
1385 int pset_assign_forced(psetid_t pset, processorid_t cpu, psetid_t *opset);
1386 int pset_info(psetid_t pset, int *type, u_int *numcpus, processorid_t *cpulist);
1387 int pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset);
1388 int pset_bind_lwp(psetid_t pset, id_t id, pid_t, psetid_t *opset);
1389   
1390 
1391 /* rctlsys.c */
1392 int getrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk,
1393     int flags);
1394 int setrctl(const char *name, rctlblk_t *old_rblk, rctlblk_t *new_rblk,
1395     int flags);
1396 /* (private functions) */
1397 int setprojrctl(const char *name, rctlblk_t *new_rblk, size_t size, int flags);
1398 int rctlctl(const char *, rctlblk_t *, int);
1399 size_t rctllist(char *, size_t);
1400 
1401 
1402 /* semsys.c */
1403 int semctl(int semid, int semnum, int cmd, ...);
1404 int semget(key_t key, int nsems, int semflg);
1405 int semop(int semid, struct sembuf *sops, size_t nsops);
1406 
1407 /* shmsys.c */
1408 void *shmat(int shmid, const void *shmaddr, int shmflg);
1409 int shmctl(int shmid, int cmd, struct shmid_ds *buf);
1410 #if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4)
1411 int shmdt(const void *);
1412 #else
1413 int shmdt(char *);
1414 #endif /* defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4) */
1415 int shmget(key_t key, size_t size, int shmflg);
1416 
1417 /* tasksys.c */
1418 taskid_t settaskid(projid_t project, uint_t flags);
1419 taskid_t gettaskid(void);
1420 projid_t getprojid(void);
1421 
1422 /*
1423  * /usr/src/lib/libc/port/widec routines
1424  */
1425 
1426 /* fgetws.c */
1427 wchar_t *fgetws(wchar_t *_RESTRICT_KYWD ptr, int  size,
1428         FILE *_RESTRICT_KYWD iop);
1429 
1430 /* fputwc.c */
1431 wint_t fputwc(wint_t wc, FILE *iop);
1432 wint_t putwc(wint_t wc, FILE *iop);
1433 
1434 /* fputws.c */
1435 int fputws(const wchar_t *_RESTRICT_KYWD ptr, FILE *_RESTRICT_KYWD iop);
1436 
1437 /* getwchar.c */
1438 wint_t getwchar(void);
1439 
1440 /* getwidth.c */
1441 void getwidth(eucwidth_t *eucstruct);
1442 
1443 /* getws.c */
1444 wchar_t *getws(wchar_t *ptr);
1445 
1446 /* iswctype.c */
1447 int iswctype(wint_t wc, wctype_t charclass);
1448 int iswalpha(wint_t c);
1449 int iswupper(wint_t c);
1450 int iswlower(wint_t c);
1451 int iswdigit(wint_t c);
1452 int iswxdigit(wint_t c);
1453 int iswalnum(wint_t c);
1454 int iswspace(wint_t c);
1455 int iswpunct(wint_t c);
1456 int iswprint(wint_t c);
1457 int iswgraph(wint_t c);
1458 int iswcntrl(wint_t c);
1459 int isphonogram(wint_t c);
1460 int isideogram(wint_t c);
1461 int isenglish(wint_t c);
1462 int isnumber(wint_t c);
1463 int isspecial(wint_t c);
1464 
1465 /* libwcollate.c */
1466 
1467 /* putwchar.c */
1468 wint_t putwchar(wint_t c);
1469 
1470 /* putws.c */
1471 int putws(const wchar_t *ptr);
1472 
1473 /* scrwidth.c */
1474 
1475 /* strtows.c */
1476 wchar_t *strtows(wchar_t *s1, char *s2);
1477 char *wstostr(char *s1, wchar_t *s2);
1478 
1479 /* trwctype.c */
1480 wint_t towupper(wint_t c);
1481 wint_t towlower(wint_t c);
1482 
1483 /* ungetwc.c */
1484 wint_t ungetwc(wint_t wc, FILE *iop);
1485 
1486 /* wcollate.c */
1487 size_t wcsxfrm(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1488         size_t n);
1489 int wcscoll(const wchar_t *s1, const wchar_t *s2);
1490 
1491 /* wcsftime.c */
1492 #if !defined(__amd64)           /* XX64 - fix me */
1493 size_t wcsftime(wchar_t *wcs, size_t maxsize,
1494         const char *format, const struct tm *timeptr);
1495 #endif  /* __amd64 */
1496 
1497 /* wcstring.c */
1498 wint_t fgetwc(FILE *iop);
1499 wint_t getwc(FILE *iop);
1500 int wcwidth(wchar_t wc);
1501 int wcswidth(const wchar_t *pwcs, size_t n);
1502 
1503 /* wcswcs.c */
1504 wchar_t *wcswcs(const wchar_t *ws1, const wchar_t *ws2);
1505 
1506 /* wcsxfrm.c - empty file! */
1507 
1508 /* wcsxfrm.xpg4.c */
1509 
1510 /* wisprint.c */
1511 int wisprint(wchar_t c);
1512 
1513 /* wscasecmp.c */
1514 int wscasecmp(const wchar_t *s1, const wchar_t *s2);
1515 
1516 /* wscat.c */
1517 wchar_t *wcscat(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2);
1518 wchar_t *wscat(wchar_t *s1, const wchar_t *s2);
1519 
1520 /* wschr.c */
1521 wchar_t *wcschr(const wchar_t *sp, wchar_t c);
1522 wchar_t *wschr(const wchar_t *sp, wchar_t c);
1523 
1524 /* wscmp.c */
1525 int wcscmp(const wchar_t *s1, const wchar_t *s2);
1526 int wscmp(const wchar_t *s1, const wchar_t *s2);
1527 
1528 /* wscol.c */
1529 int wscol(const wchar_t *s1);
1530 
1531 /* wscpy.c */
1532 wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2);
1533 wchar_t *wscpy(wchar_t *s1, const wchar_t *s2);
1534 
1535 /* wscspn.c */
1536 size_t wcscspn(const wchar_t *string, const wchar_t *charset);
1537 size_t wscspn(const wchar_t *string, const wchar_t *charset);
1538 
1539 /* wsdup.c */
1540 wchar_t *wsdup(const wchar_t *s1);
1541 
1542 /* wslen.c */
1543 size_t wcslen(const wchar_t *s);
1544 size_t wslen(const wchar_t *s);
1545 
1546 /* wsncasecmp.c */
1547 int wsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1548 
1549 /* wsncat.c */
1550 wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1551         size_t n);
1552 wchar_t *wsncat(wchar_t *s1, const wchar_t *s2, size_t n);
1553 
1554 /* wsncmp.c */
1555 int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1556 int wsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);
1557 
1558 /* wsncpy.c */
1559 wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD s1, const wchar_t *_RESTRICT_KYWD s2,
1560         size_t n);
1561 wchar_t *wsncpy(wchar_t *s1, const wchar_t *s2, size_t n);
1562 
1563 /* wspbrk.c */
1564 wchar_t *wcspbrk(const wchar_t *string, const wchar_t *brkset);
1565 wchar_t *wspbrk(const wchar_t *string, const wchar_t *brkset);
1566 
1567 /* wsprintf.c */
1568 int wsprintf(wchar_t *wstring, const char *format, ...);
1569 
1570 /* wsrchr.c */
1571 wchar_t *wcsrchr(const wchar_t *sp, wchar_t c);
1572 wchar_t *wsrchr(const wchar_t *sp, wchar_t c);
1573 
1574 /* wsscanf.c */
1575 int wsscanf(wchar_t *s, const char *format, ...);
1576 
1577 /* wssize.c */
1578 
1579 /* wsspn.c */
1580 size_t wcsspn(const wchar_t *string, const wchar_t *charset);
1581 size_t wsspn(const wchar_t *string, const wchar_t *charset);
1582 
1583 /* wstod.c */
1584 double wcstod(const wchar_t *_RESTRICT_KYWD cp, wchar_t **_RESTRICT_KYWD ptr);
1585 float wcstof(const wchar_t *_RESTRICT_KYWD cp, wchar_t **_RESTRICT_KYWD ptr);
1586 long double wcstold(const wchar_t *_RESTRICT_KYWD cp,
1587         wchar_t **_RESTRICT_KYWD ptr);
1588 double wstod(const wchar_t *cp, wchar_t **ptr);
1589 
1590 /* wstok.c */
1591 #if !defined(__amd64)           /* XX64 - fix me */
1592 wchar_t *wcstok(wchar_t *string, const wchar_t *sepset);
1593 wchar_t *wstok(wchar_t *string, const wchar_t *sepset);
1594 #endif  /* __amd64 */
1595 
1596 /* wcstol.c */
1597 long wcstol(const wchar_t *_RESTRICT_KYWD str, wchar_t **_RESTRICT_KYWD ptr,
1598         int base);
1599 long long wcstoll(const wchar_t *_RESTRICT_KYWD str,
1600         wchar_t **_RESTRICT_KYWD ptr, int base);
1601 
1602 /* wcstoul.c */
1603 unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD str,
1604         wchar_t **_RESTRICT_KYWD ptr, int base);
1605 unsigned long long wcstoull(const wchar_t *_RESTRICT_KYWD str,
1606         wchar_t **_RESTRICT_KYWD ptr, int base);
1607 
1608 /* wcstoimax.c */
1609 intmax_t wcstoimax(const wchar_t *_RESTRICT_KYWD nptr,
1610         wchar_t **_RESTRICT_KYWD endptr, int base);
1611 uintmax_t wcstoumax(const wchar_t *_RESTRICT_KYWD nptr,
1612         wchar_t **_RESTRICT_KYWD endptr, int base);
1613 
1614 /* wstol.c */
1615 long wstol(const wchar_t *str, wchar_t **ptr, int base);
1616 
1617 /* wstoll.c */
1618 long long wstoll(const wchar_t *str, wchar_t **ptr, int base);
1619 long long watoll(const wchar_t *p);
1620 
1621 /* wsxfrm.c */
1622 size_t wsxfrm(wchar_t *s1, const wchar_t *s2, size_t n);
1623 int wscoll(const wchar_t *s1, const wchar_t *s2);
1624 
1625 /*
1626  * /usr/src/lib/libc/port/gen/event_port.c
1627  */
1628 int port_dispatch(int port, int flags, int source, int events, uintptr_t object,
1629     void *user);
1630 
1631 /*
1632  * /usr/src/lib/libc/$MACH/gen routines
1633  */
1634 
1635 /* alloca.s */
1636 
1637 void *__builtin_alloca(size_t);
1638 
1639 /*
1640  * modctl(int arg, ...) and utssys(...) are not available from a header
1641  * file, but our utilities which make use of it should be able to be
1642  * lint clean.
1643  */
1644 int modctl(int arg, ...);
1645 int utssys(void *buf, int arg, int type, void *outbp);
1646 
1647 
1648 typedef float single;
1649 typedef unsigned extended[3];
1650 typedef long double quadruple;
1651 typedef unsigned fp_exception_field_type;
1652 
1653 typedef char decimal_string[512];
1654 
1655 enum fp_class_type {
1656         fp_zero  = 0,
1657         fp_subnormal    = 1,
1658         fp_normal       = 2,
1659         fp_infinity     = 3,
1660         fp_quiet        = 4,
1661         fp_signaling    = 5
1662 };
1663 
1664 enum fp_direction_type {
1665         fp_nearest      = 0,
1666         fp_tozero       = 1,
1667         fp_positive     = 2,
1668         fp_negative     = 3
1669 };
1670 
1671 typedef struct {
1672         enum fp_class_type fpclass;
1673         int sign;
1674         int exponent;
1675         decimal_string ds;
1676         int more;
1677         int ndigits;
1678 } decimal_record;
1679 
1680 enum decimal_form {
1681         fixed_form,
1682         floating_form
1683 };
1684 
1685 typedef struct {
1686         enum fp_direction_type rd;
1687         enum decimal_form df;
1688         int ndigits;
1689 } decimal_mode;
1690 
1691 enum decimal_string_form {
1692         invalid_form,
1693         whitespace_form,
1694         fixed_int_form,
1695         fixed_intdot_form,
1696         fixed_dotfrac_form,
1697         fixed_intdotfrac_form,
1698         floating_int_form,
1699         floating_intdot_form,
1700         floating_dotfrac_form,
1701         floating_intdotfrac_form,
1702         inf_form,
1703         infinity_form,
1704         nan_form,
1705         nanstring_form
1706 };
1707 
1708 typedef int sigfpe_code_type;
1709 
1710 typedef void (*sigfpe_handler_type)();
1711 
1712 extern sigfpe_handler_type sigfpe(sigfpe_code_type, sigfpe_handler_type);
1713 
1714 extern void single_to_decimal(single *, decimal_mode *, decimal_record *,
1715                                 fp_exception_field_type *);
1716 
1717 extern void double_to_decimal(double *, decimal_mode *, decimal_record *,
1718                                 fp_exception_field_type *);
1719 extern void extended_to_decimal(extended *, decimal_mode *,
1720                                 decimal_record *, fp_exception_field_type *);
1721 extern void quadruple_to_decimal(quadruple *, decimal_mode *,
1722                                 decimal_record *, fp_exception_field_type *);
1723 extern void decimal_to_single(single *, decimal_mode *, decimal_record *,
1724                                 fp_exception_field_type *);
1725 extern void decimal_to_double(double *, decimal_mode *, decimal_record *,
1726                                 fp_exception_field_type *);
1727 extern void decimal_to_extended(extended *, decimal_mode *,
1728                                 decimal_record *, fp_exception_field_type *);
1729 extern void decimal_to_quadruple(quadruple *, decimal_mode *,
1730                                 decimal_record *, fp_exception_field_type *);
1731 extern void string_to_decimal(char **, int, int, decimal_record *,
1732                                 enum decimal_string_form *, char **);
1733 extern void func_to_decimal(char **, int, int, decimal_record *,
1734                                 enum decimal_string_form *, char **,
1735                                 int (*)(void), int *, int (*)(int));
1736 extern void file_to_decimal(char **, int, int, decimal_record *,
1737                                 enum decimal_string_form *, char **,
1738                                 FILE *, int *);
1739 extern char *seconvert(single *, int, int *, int *, char *);
1740 extern char *sfconvert(single *, int, int *, int *, char *);
1741 extern char *sgconvert(single *, int, int, char *);
1742 extern char *econvert(double, int, int *, int *, char *);
1743 extern char *fconvert(double, int, int *, int *, char *);
1744 extern char *gconvert(double, int, int, char *);
1745 extern char *qeconvert(quadruple *, int, int *, int *, char *);
1746 extern char *qfconvert(quadruple *, int, int *, int *, char *);
1747 extern char *qgconvert(quadruple *, int, int, char *);
1748 
1749 extern void __assert(const char *, const char *, int);
1750 
1751 extern int setjmp(jmp_buf);
1752 extern void longjmp(jmp_buf, int);
1753 extern int sigsetjmp(sigjmp_buf, int);
1754 extern void siglongjmp(sigjmp_buf, int);
1755 
1756 int uname(struct utsname *);
1757 int _uname(struct utsname *);
1758 
1759 int errno;
1760 int *___errno()
1761 { return (&errno); }
1762 
1763 extern int getloadavg(double [], int);
1764 
1765 extern long pcsample(uintptr_t [], long);
1766 
1767 int fstat(int, struct stat *);
1768 int stat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD);
1769 int lstat(const char *_RESTRICT_KYWD, struct stat *_RESTRICT_KYWD);
1770 int mknod(const char *, mode_t, dev_t);
1771 
1772 extern int __init_daemon_priv(int, uid_t uid, gid_t gid, ...);
1773 extern void __fini_daemon_priv(const char *, ...);
1774 extern int __init_suid_priv(int, ...);
1775 extern int __priv_bracket(priv_op_t);
1776 extern void __priv_relinquish(void);
1777 extern const char * __priv_getsetbynum(const void *, int);
1778 extern char * __priv_set_to_str(void *, const priv_set_t *, char, int);
1779 
1780 /* private interface to get the groups list for a certain user */
1781 int _getgroupsbymember(const char *, gid_t[], int, int);
1782 
1783 /* private interface for use only by java */
1784 volatile sc_shared_t *volatile *_thr_schedctl(void);
1785 
1786 /* private interface to unmount all autofs mounts */
1787 int _autofssys(enum autofssys_op, void *);
1788 
1789 /* label.c */
1790 extern int is_system_labeled(void);
1791 
1792 extern int uconv_u16tou32(const uint16_t *, size_t *, uint32_t *, size_t *,
1793         int);
1794 extern int uconv_u16tou8(const uint16_t *, size_t *, uchar_t *, size_t *, int);
1795 extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *,
1796         int);
1797 extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int);
1798 extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
1799 extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
1800 extern int u8_validate(char *, size_t, char **, int, int *);
1801 extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
1802 extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
1803         int *);
1804 
1805 /* private locale interfaces */
1806 wint_t __nextwctype(wint_t, wctype_t);
1807 int __iswrune(wint_t);