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