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