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