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