10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51885Sraf * Common Development and Distribution License (the "License"). 61885Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211111Sraf 220Sstevel@tonic-gate /* 233512Sraf * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include "lint.h" 300Sstevel@tonic-gate #include "thr_uberdata.h" 310Sstevel@tonic-gate #include <stdarg.h> 320Sstevel@tonic-gate #include <poll.h> 330Sstevel@tonic-gate #include <stropts.h> 340Sstevel@tonic-gate #include <dlfcn.h> 350Sstevel@tonic-gate #include <sys/uio.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* 38*4843Sraf * fork_lock_enter() does triple-duty. Not only does it (and atfork_lock) 39*4843Sraf * serialize calls to fork() and forkall(), but it also serializes calls to 40*4843Sraf * thr_suspend() and thr_continue() (fork() and forkall() also suspend other 41*4843Sraf * threads), and furthermore it serializes I18N calls to functions in other 420Sstevel@tonic-gate * dlopen()ed L10N objects that might be calling malloc()/free(). 430Sstevel@tonic-gate */ 44*4843Sraf void 45*4843Sraf fork_lock_enter(void) 460Sstevel@tonic-gate { 470Sstevel@tonic-gate ulwp_t *self = curthread; 480Sstevel@tonic-gate 490Sstevel@tonic-gate ASSERT(self->ul_critical == 0); 50*4843Sraf (void) _private_mutex_lock(&self->ul_uberdata->fork_lock); 510Sstevel@tonic-gate } 520Sstevel@tonic-gate 530Sstevel@tonic-gate void 540Sstevel@tonic-gate fork_lock_exit(void) 550Sstevel@tonic-gate { 560Sstevel@tonic-gate ulwp_t *self = curthread; 570Sstevel@tonic-gate 580Sstevel@tonic-gate ASSERT(self->ul_critical == 0); 59*4843Sraf (void) _private_mutex_unlock(&self->ul_uberdata->fork_lock); 600Sstevel@tonic-gate } 610Sstevel@tonic-gate 623235Sraf #pragma weak forkx = _private_forkx 633235Sraf #pragma weak _forkx = _private_forkx 644292Sab196087 pid_t 653235Sraf _private_forkx(int flags) 660Sstevel@tonic-gate { 670Sstevel@tonic-gate ulwp_t *self = curthread; 680Sstevel@tonic-gate uberdata_t *udp = self->ul_uberdata; 690Sstevel@tonic-gate pid_t pid; 700Sstevel@tonic-gate 710Sstevel@tonic-gate if (self->ul_vfork) { 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * We are a child of vfork(); omit all of the fork 740Sstevel@tonic-gate * logic and go straight to the system call trap. 750Sstevel@tonic-gate * A vfork() child of a multithreaded parent 760Sstevel@tonic-gate * must never call fork(). 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate if (udp->uberflags.uf_mt) { 790Sstevel@tonic-gate errno = ENOTSUP; 800Sstevel@tonic-gate return (-1); 810Sstevel@tonic-gate } 823235Sraf pid = __forkx(flags); 830Sstevel@tonic-gate if (pid == 0) { /* child */ 840Sstevel@tonic-gate udp->pid = _private_getpid(); 850Sstevel@tonic-gate self->ul_vfork = 0; 860Sstevel@tonic-gate } 870Sstevel@tonic-gate return (pid); 880Sstevel@tonic-gate } 890Sstevel@tonic-gate 90*4843Sraf sigoff(self); 91*4843Sraf if (self->ul_fork) { 920Sstevel@tonic-gate /* 930Sstevel@tonic-gate * Cannot call fork() from a fork handler. 940Sstevel@tonic-gate */ 95*4843Sraf sigon(self); 96*4843Sraf errno = EDEADLK; 970Sstevel@tonic-gate return (-1); 980Sstevel@tonic-gate } 990Sstevel@tonic-gate self->ul_fork = 1; 100*4843Sraf (void) _private_mutex_lock(&udp->atfork_lock); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * The functions registered by pthread_atfork() are defined by 1040Sstevel@tonic-gate * the application and its libraries and we must not hold any 105*4843Sraf * internal lmutex_lock()-acquired locks while invoking them. 106*4843Sraf * We hold only udp->atfork_lock to protect the atfork linkages. 107*4843Sraf * If one of these pthread_atfork() functions attempts to fork 108*4843Sraf * or to call pthread_atfork(), it will detect the error and 109*4843Sraf * fail with EDEADLK. Otherwise, the pthread_atfork() functions 1100Sstevel@tonic-gate * are free to do anything they please (except they will not 1110Sstevel@tonic-gate * receive any signals). 1120Sstevel@tonic-gate */ 1130Sstevel@tonic-gate _prefork_handler(); 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* 116*4843Sraf * Block every other thread attempting thr_suspend() or thr_continue(). 117*4843Sraf * This also blocks every other thread attempting calls to I18N 118*4843Sraf * functions in dlopen()ed L10N objects, but this is benign; 119*4843Sraf * the other threads will soon be suspended anyway. 120*4843Sraf */ 121*4843Sraf fork_lock_enter(); 122*4843Sraf 123*4843Sraf /* 1240Sstevel@tonic-gate * Block all signals. 125*4843Sraf * Just deferring them via sigoff() is not enough. 1260Sstevel@tonic-gate * We have to avoid taking a deferred signal in the child 1273235Sraf * that was actually sent to the parent before __forkx(). 1280Sstevel@tonic-gate */ 1290Sstevel@tonic-gate block_all_signals(self); 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * This suspends all threads but this one, leaving them 1330Sstevel@tonic-gate * suspended outside of any critical regions in the library. 1340Sstevel@tonic-gate * Thus, we are assured that no library locks are held 1353235Sraf * while we invoke fork() from the current thread. 1360Sstevel@tonic-gate */ 1370Sstevel@tonic-gate suspend_fork(); 1380Sstevel@tonic-gate 1393235Sraf pid = __forkx(flags); 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate if (pid == 0) { /* child */ 1420Sstevel@tonic-gate /* 1430Sstevel@tonic-gate * Clear our schedctl pointer. 1440Sstevel@tonic-gate * Discard any deferred signal that was sent to the parent. 1453235Sraf * Because we blocked all signals before __forkx(), a 1460Sstevel@tonic-gate * deferred signal cannot have been taken by the child. 1470Sstevel@tonic-gate */ 1480Sstevel@tonic-gate self->ul_schedctl_called = NULL; 1490Sstevel@tonic-gate self->ul_schedctl = NULL; 1500Sstevel@tonic-gate self->ul_cursig = 0; 1510Sstevel@tonic-gate self->ul_siginfo.si_signo = 0; 1520Sstevel@tonic-gate udp->pid = _private_getpid(); 1530Sstevel@tonic-gate /* reset the library's data structures to reflect one thread */ 1544574Sraf unregister_locks(); 1552248Sraf postfork1_child(); 1560Sstevel@tonic-gate restore_signals(self); 157*4843Sraf fork_lock_exit(); 1580Sstevel@tonic-gate _postfork_child_handler(); 1590Sstevel@tonic-gate } else { 1603235Sraf /* restart all threads that were suspended for fork() */ 1610Sstevel@tonic-gate continue_fork(0); 1620Sstevel@tonic-gate restore_signals(self); 163*4843Sraf fork_lock_exit(); 1640Sstevel@tonic-gate _postfork_parent_handler(); 1650Sstevel@tonic-gate } 1660Sstevel@tonic-gate 167*4843Sraf (void) _private_mutex_unlock(&udp->atfork_lock); 1680Sstevel@tonic-gate self->ul_fork = 0; 169*4843Sraf sigon(self); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate return (pid); 1720Sstevel@tonic-gate } 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* 1753235Sraf * fork() is fork1() for both Posix threads and Solaris threads. 1763235Sraf * The forkall() interface exists for applications that require 1773235Sraf * the semantics of replicating all threads. 1780Sstevel@tonic-gate */ 1793235Sraf #pragma weak fork1 = _fork 1803235Sraf #pragma weak _fork1 = _fork 1813235Sraf #pragma weak fork = _fork 1820Sstevel@tonic-gate pid_t 1833235Sraf _fork(void) 1843235Sraf { 1853235Sraf return (_private_forkx(0)); 1863235Sraf } 1873235Sraf 1883235Sraf /* 1893235Sraf * Much of the logic here is the same as in forkx(). 1903235Sraf * See the comments in forkx(), above. 1913235Sraf */ 1923235Sraf #pragma weak forkallx = _private_forkallx 1933235Sraf #pragma weak _forkallx = _private_forkallx 1944292Sab196087 pid_t 1953235Sraf _private_forkallx(int flags) 1960Sstevel@tonic-gate { 1970Sstevel@tonic-gate ulwp_t *self = curthread; 1980Sstevel@tonic-gate uberdata_t *udp = self->ul_uberdata; 1990Sstevel@tonic-gate pid_t pid; 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate if (self->ul_vfork) { 2020Sstevel@tonic-gate if (udp->uberflags.uf_mt) { 2030Sstevel@tonic-gate errno = ENOTSUP; 2040Sstevel@tonic-gate return (-1); 2050Sstevel@tonic-gate } 2063235Sraf pid = __forkallx(flags); 2070Sstevel@tonic-gate if (pid == 0) { /* child */ 2080Sstevel@tonic-gate udp->pid = _private_getpid(); 2090Sstevel@tonic-gate self->ul_vfork = 0; 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate return (pid); 2120Sstevel@tonic-gate } 2130Sstevel@tonic-gate 214*4843Sraf sigoff(self); 215*4843Sraf if (self->ul_fork) { 216*4843Sraf sigon(self); 217*4843Sraf errno = EDEADLK; 2180Sstevel@tonic-gate return (-1); 2190Sstevel@tonic-gate } 2200Sstevel@tonic-gate self->ul_fork = 1; 221*4843Sraf 222*4843Sraf fork_lock_enter(); 2230Sstevel@tonic-gate block_all_signals(self); 2240Sstevel@tonic-gate suspend_fork(); 2250Sstevel@tonic-gate 2263235Sraf pid = __forkallx(flags); 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate if (pid == 0) { 2290Sstevel@tonic-gate self->ul_schedctl_called = NULL; 2300Sstevel@tonic-gate self->ul_schedctl = NULL; 2310Sstevel@tonic-gate self->ul_cursig = 0; 2320Sstevel@tonic-gate self->ul_siginfo.si_signo = 0; 2330Sstevel@tonic-gate udp->pid = _private_getpid(); 2344574Sraf unregister_locks(); 2350Sstevel@tonic-gate continue_fork(1); 2360Sstevel@tonic-gate } else { 2370Sstevel@tonic-gate continue_fork(0); 2380Sstevel@tonic-gate } 2390Sstevel@tonic-gate restore_signals(self); 240*4843Sraf fork_lock_exit(); 2410Sstevel@tonic-gate self->ul_fork = 0; 242*4843Sraf sigon(self); 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate return (pid); 2450Sstevel@tonic-gate } 2460Sstevel@tonic-gate 2473235Sraf #pragma weak forkall = _forkall 2483235Sraf pid_t 2493235Sraf _forkall(void) 2503235Sraf { 2513235Sraf return (_private_forkallx(0)); 2523235Sraf } 2533235Sraf 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate * Hacks for system calls to provide cancellation 2560Sstevel@tonic-gate * and improve java garbage collection. 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate #define PROLOGUE \ 2590Sstevel@tonic-gate { \ 2600Sstevel@tonic-gate ulwp_t *self = curthread; \ 2610Sstevel@tonic-gate int nocancel = (self->ul_vfork | self->ul_nocancel); \ 2620Sstevel@tonic-gate if (nocancel == 0) { \ 2630Sstevel@tonic-gate self->ul_save_async = self->ul_cancel_async; \ 2640Sstevel@tonic-gate if (!self->ul_cancel_disabled) { \ 2650Sstevel@tonic-gate self->ul_cancel_async = 1; \ 2660Sstevel@tonic-gate if (self->ul_cancel_pending) \ 2670Sstevel@tonic-gate _pthread_exit(PTHREAD_CANCELED); \ 2680Sstevel@tonic-gate } \ 2690Sstevel@tonic-gate self->ul_sp = stkptr(); \ 2700Sstevel@tonic-gate } 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate #define EPILOGUE \ 2730Sstevel@tonic-gate if (nocancel == 0) { \ 2740Sstevel@tonic-gate self->ul_sp = 0; \ 2750Sstevel@tonic-gate self->ul_cancel_async = self->ul_save_async; \ 2760Sstevel@tonic-gate } \ 2770Sstevel@tonic-gate } 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate /* 2800Sstevel@tonic-gate * Perform the body of the action required by most of the cancelable 2810Sstevel@tonic-gate * function calls. The return(function_call) part is to allow the 2820Sstevel@tonic-gate * compiler to make the call be executed with tail recursion, which 2830Sstevel@tonic-gate * saves a register window on sparc and slightly (not much) improves 2840Sstevel@tonic-gate * the code for x86/x64 compilations. 2850Sstevel@tonic-gate */ 2860Sstevel@tonic-gate #define PERFORM(function_call) \ 2870Sstevel@tonic-gate PROLOGUE \ 2880Sstevel@tonic-gate if (nocancel) \ 2890Sstevel@tonic-gate return (function_call); \ 2900Sstevel@tonic-gate rv = function_call; \ 2910Sstevel@tonic-gate EPILOGUE \ 2920Sstevel@tonic-gate return (rv); 2930Sstevel@tonic-gate 2940Sstevel@tonic-gate /* 2950Sstevel@tonic-gate * Specialized prologue for sigsuspend() and pollsys(). 2960Sstevel@tonic-gate * These system calls pass a signal mask to the kernel. 2970Sstevel@tonic-gate * The kernel replaces the thread's signal mask with the 2980Sstevel@tonic-gate * temporary mask before the thread goes to sleep. If 2990Sstevel@tonic-gate * a signal is received, the signal handler will execute 3000Sstevel@tonic-gate * with the temporary mask, as modified by the sigaction 3010Sstevel@tonic-gate * for the particular signal. 3020Sstevel@tonic-gate * 3030Sstevel@tonic-gate * We block all signals until we reach the kernel with the 3040Sstevel@tonic-gate * temporary mask. This eliminates race conditions with 3050Sstevel@tonic-gate * setting the signal mask while signals are being posted. 3060Sstevel@tonic-gate */ 3070Sstevel@tonic-gate #define PROLOGUE_MASK(sigmask) \ 3080Sstevel@tonic-gate { \ 3090Sstevel@tonic-gate ulwp_t *self = curthread; \ 3100Sstevel@tonic-gate int nocancel = (self->ul_vfork | self->ul_nocancel); \ 3110Sstevel@tonic-gate if (!self->ul_vfork) { \ 3120Sstevel@tonic-gate if (sigmask) { \ 3130Sstevel@tonic-gate block_all_signals(self); \ 3141111Sraf self->ul_tmpmask.__sigbits[0] = sigmask->__sigbits[0]; \ 3151111Sraf self->ul_tmpmask.__sigbits[1] = sigmask->__sigbits[1]; \ 3160Sstevel@tonic-gate delete_reserved_signals(&self->ul_tmpmask); \ 3170Sstevel@tonic-gate self->ul_sigsuspend = 1; \ 3180Sstevel@tonic-gate } \ 3190Sstevel@tonic-gate if (nocancel == 0) { \ 3200Sstevel@tonic-gate self->ul_save_async = self->ul_cancel_async; \ 3210Sstevel@tonic-gate if (!self->ul_cancel_disabled) { \ 3220Sstevel@tonic-gate self->ul_cancel_async = 1; \ 3230Sstevel@tonic-gate if (self->ul_cancel_pending) { \ 3240Sstevel@tonic-gate if (self->ul_sigsuspend) { \ 3250Sstevel@tonic-gate self->ul_sigsuspend = 0;\ 3260Sstevel@tonic-gate restore_signals(self); \ 3270Sstevel@tonic-gate } \ 3280Sstevel@tonic-gate _pthread_exit(PTHREAD_CANCELED);\ 3290Sstevel@tonic-gate } \ 3300Sstevel@tonic-gate } \ 3310Sstevel@tonic-gate self->ul_sp = stkptr(); \ 3320Sstevel@tonic-gate } \ 3330Sstevel@tonic-gate } 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate /* 3360Sstevel@tonic-gate * If a signal is taken, we return from the system call wrapper with 3370Sstevel@tonic-gate * our original signal mask restored (see code in call_user_handler()). 3380Sstevel@tonic-gate * If not (self->ul_sigsuspend is still non-zero), we must restore our 3390Sstevel@tonic-gate * original signal mask ourself. 3400Sstevel@tonic-gate */ 3410Sstevel@tonic-gate #define EPILOGUE_MASK \ 3420Sstevel@tonic-gate if (nocancel == 0) { \ 3430Sstevel@tonic-gate self->ul_sp = 0; \ 3440Sstevel@tonic-gate self->ul_cancel_async = self->ul_save_async; \ 3450Sstevel@tonic-gate } \ 3460Sstevel@tonic-gate if (self->ul_sigsuspend) { \ 3470Sstevel@tonic-gate self->ul_sigsuspend = 0; \ 3480Sstevel@tonic-gate restore_signals(self); \ 3490Sstevel@tonic-gate } \ 3500Sstevel@tonic-gate } 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate /* 3532248Sraf * Cancellation prologue and epilogue functions, 3542248Sraf * for cancellation points too complex to include here. 3551885Sraf */ 3561885Sraf void 3571885Sraf _cancel_prologue(void) 3581885Sraf { 3591885Sraf ulwp_t *self = curthread; 3601885Sraf 3611885Sraf self->ul_cancel_prologue = (self->ul_vfork | self->ul_nocancel); 3621885Sraf if (self->ul_cancel_prologue == 0) { 3631885Sraf self->ul_save_async = self->ul_cancel_async; 3641885Sraf if (!self->ul_cancel_disabled) { 3651885Sraf self->ul_cancel_async = 1; 3661885Sraf if (self->ul_cancel_pending) 3671885Sraf _pthread_exit(PTHREAD_CANCELED); 3681885Sraf } 3691885Sraf self->ul_sp = stkptr(); 3701885Sraf } 3711885Sraf } 3721885Sraf 3731885Sraf void 3741885Sraf _cancel_epilogue(void) 3751885Sraf { 3761885Sraf ulwp_t *self = curthread; 3771885Sraf 3781885Sraf if (self->ul_cancel_prologue == 0) { 3791885Sraf self->ul_sp = 0; 3801885Sraf self->ul_cancel_async = self->ul_save_async; 3811885Sraf } 3821885Sraf } 3831885Sraf 3841885Sraf /* 3850Sstevel@tonic-gate * Called from _thrp_join() (thr_join() is a cancellation point) 3860Sstevel@tonic-gate */ 3870Sstevel@tonic-gate int 3880Sstevel@tonic-gate lwp_wait(thread_t tid, thread_t *found) 3890Sstevel@tonic-gate { 3900Sstevel@tonic-gate int error; 3910Sstevel@tonic-gate 3920Sstevel@tonic-gate PROLOGUE 3930Sstevel@tonic-gate while ((error = __lwp_wait(tid, found)) == EINTR) 3940Sstevel@tonic-gate ; 3950Sstevel@tonic-gate EPILOGUE 3960Sstevel@tonic-gate return (error); 3970Sstevel@tonic-gate } 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate ssize_t 4000Sstevel@tonic-gate read(int fd, void *buf, size_t size) 4010Sstevel@tonic-gate { 4020Sstevel@tonic-gate extern ssize_t _read(int, void *, size_t); 4030Sstevel@tonic-gate ssize_t rv; 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate PERFORM(_read(fd, buf, size)) 4060Sstevel@tonic-gate } 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate ssize_t 4090Sstevel@tonic-gate write(int fd, const void *buf, size_t size) 4100Sstevel@tonic-gate { 4110Sstevel@tonic-gate extern ssize_t _write(int, const void *, size_t); 4120Sstevel@tonic-gate ssize_t rv; 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate PERFORM(_write(fd, buf, size)) 4150Sstevel@tonic-gate } 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate int 4180Sstevel@tonic-gate getmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, 4190Sstevel@tonic-gate int *flagsp) 4200Sstevel@tonic-gate { 4210Sstevel@tonic-gate extern int _getmsg(int, struct strbuf *, struct strbuf *, int *); 4220Sstevel@tonic-gate int rv; 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate PERFORM(_getmsg(fd, ctlptr, dataptr, flagsp)) 4250Sstevel@tonic-gate } 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate int 4280Sstevel@tonic-gate getpmsg(int fd, struct strbuf *ctlptr, struct strbuf *dataptr, 4290Sstevel@tonic-gate int *bandp, int *flagsp) 4300Sstevel@tonic-gate { 4310Sstevel@tonic-gate extern int _getpmsg(int, struct strbuf *, struct strbuf *, 432*4843Sraf int *, int *); 4330Sstevel@tonic-gate int rv; 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate PERFORM(_getpmsg(fd, ctlptr, dataptr, bandp, flagsp)) 4360Sstevel@tonic-gate } 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate int 4390Sstevel@tonic-gate putmsg(int fd, const struct strbuf *ctlptr, 4400Sstevel@tonic-gate const struct strbuf *dataptr, int flags) 4410Sstevel@tonic-gate { 4420Sstevel@tonic-gate extern int _putmsg(int, const struct strbuf *, 443*4843Sraf const struct strbuf *, int); 4440Sstevel@tonic-gate int rv; 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate PERFORM(_putmsg(fd, ctlptr, dataptr, flags)) 4470Sstevel@tonic-gate } 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate int 4500Sstevel@tonic-gate __xpg4_putmsg(int fd, const struct strbuf *ctlptr, 4510Sstevel@tonic-gate const struct strbuf *dataptr, int flags) 4520Sstevel@tonic-gate { 4530Sstevel@tonic-gate extern int _putmsg(int, const struct strbuf *, 454*4843Sraf const struct strbuf *, int); 4550Sstevel@tonic-gate int rv; 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate PERFORM(_putmsg(fd, ctlptr, dataptr, flags|MSG_XPG4)) 4580Sstevel@tonic-gate } 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate int 4610Sstevel@tonic-gate putpmsg(int fd, const struct strbuf *ctlptr, 4620Sstevel@tonic-gate const struct strbuf *dataptr, int band, int flags) 4630Sstevel@tonic-gate { 4640Sstevel@tonic-gate extern int _putpmsg(int, const struct strbuf *, 465*4843Sraf const struct strbuf *, int, int); 4660Sstevel@tonic-gate int rv; 4670Sstevel@tonic-gate 4680Sstevel@tonic-gate PERFORM(_putpmsg(fd, ctlptr, dataptr, band, flags)) 4690Sstevel@tonic-gate } 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate int 4720Sstevel@tonic-gate __xpg4_putpmsg(int fd, const struct strbuf *ctlptr, 4730Sstevel@tonic-gate const struct strbuf *dataptr, int band, int flags) 4740Sstevel@tonic-gate { 4750Sstevel@tonic-gate extern int _putpmsg(int, const struct strbuf *, 476*4843Sraf const struct strbuf *, int, int); 4770Sstevel@tonic-gate int rv; 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate PERFORM(_putpmsg(fd, ctlptr, dataptr, band, flags|MSG_XPG4)) 4800Sstevel@tonic-gate } 4810Sstevel@tonic-gate 4822248Sraf #pragma weak nanosleep = _nanosleep 4830Sstevel@tonic-gate int 4842248Sraf _nanosleep(const timespec_t *rqtp, timespec_t *rmtp) 4850Sstevel@tonic-gate { 4860Sstevel@tonic-gate int error; 4870Sstevel@tonic-gate 4880Sstevel@tonic-gate PROLOGUE 4892248Sraf error = __nanosleep(rqtp, rmtp); 4900Sstevel@tonic-gate EPILOGUE 4910Sstevel@tonic-gate if (error) { 4920Sstevel@tonic-gate errno = error; 4930Sstevel@tonic-gate return (-1); 4940Sstevel@tonic-gate } 4950Sstevel@tonic-gate return (0); 4960Sstevel@tonic-gate } 4970Sstevel@tonic-gate 4982248Sraf #pragma weak clock_nanosleep = _clock_nanosleep 4990Sstevel@tonic-gate int 5002248Sraf _clock_nanosleep(clockid_t clock_id, int flags, 5010Sstevel@tonic-gate const timespec_t *rqtp, timespec_t *rmtp) 5020Sstevel@tonic-gate { 5030Sstevel@tonic-gate timespec_t reltime; 5040Sstevel@tonic-gate hrtime_t start; 5050Sstevel@tonic-gate hrtime_t rqlapse; 5060Sstevel@tonic-gate hrtime_t lapse; 5070Sstevel@tonic-gate int error; 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate switch (clock_id) { 5100Sstevel@tonic-gate case CLOCK_VIRTUAL: 5110Sstevel@tonic-gate case CLOCK_PROCESS_CPUTIME_ID: 5120Sstevel@tonic-gate case CLOCK_THREAD_CPUTIME_ID: 5130Sstevel@tonic-gate return (ENOTSUP); 5140Sstevel@tonic-gate case CLOCK_REALTIME: 5150Sstevel@tonic-gate case CLOCK_HIGHRES: 5160Sstevel@tonic-gate break; 5170Sstevel@tonic-gate default: 5180Sstevel@tonic-gate return (EINVAL); 5190Sstevel@tonic-gate } 5200Sstevel@tonic-gate if (flags & TIMER_ABSTIME) { 5210Sstevel@tonic-gate abstime_to_reltime(clock_id, rqtp, &reltime); 5220Sstevel@tonic-gate rmtp = NULL; 5230Sstevel@tonic-gate } else { 5240Sstevel@tonic-gate reltime = *rqtp; 5250Sstevel@tonic-gate if (clock_id == CLOCK_HIGHRES) 5260Sstevel@tonic-gate start = gethrtime(); 5270Sstevel@tonic-gate } 5280Sstevel@tonic-gate restart: 5290Sstevel@tonic-gate PROLOGUE 5302248Sraf error = __nanosleep(&reltime, rmtp); 5310Sstevel@tonic-gate EPILOGUE 5320Sstevel@tonic-gate if (error == 0 && clock_id == CLOCK_HIGHRES) { 5330Sstevel@tonic-gate /* 5340Sstevel@tonic-gate * Don't return yet if we didn't really get a timeout. 5350Sstevel@tonic-gate * This can happen if we return because someone resets 5360Sstevel@tonic-gate * the system clock. 5370Sstevel@tonic-gate */ 5380Sstevel@tonic-gate if (flags & TIMER_ABSTIME) { 5390Sstevel@tonic-gate if ((hrtime_t)(uint32_t)rqtp->tv_sec * NANOSEC + 5400Sstevel@tonic-gate rqtp->tv_nsec > gethrtime()) { 5410Sstevel@tonic-gate abstime_to_reltime(clock_id, rqtp, &reltime); 5420Sstevel@tonic-gate goto restart; 5430Sstevel@tonic-gate } 5440Sstevel@tonic-gate } else { 5450Sstevel@tonic-gate rqlapse = (hrtime_t)(uint32_t)rqtp->tv_sec * NANOSEC + 546*4843Sraf rqtp->tv_nsec; 5470Sstevel@tonic-gate lapse = gethrtime() - start; 5480Sstevel@tonic-gate if (rqlapse > lapse) { 5490Sstevel@tonic-gate hrt2ts(rqlapse - lapse, &reltime); 5500Sstevel@tonic-gate goto restart; 5510Sstevel@tonic-gate } 5520Sstevel@tonic-gate } 5530Sstevel@tonic-gate } 5540Sstevel@tonic-gate if (error == 0 && clock_id == CLOCK_REALTIME && 5550Sstevel@tonic-gate (flags & TIMER_ABSTIME)) { 5560Sstevel@tonic-gate /* 5570Sstevel@tonic-gate * Don't return yet just because someone reset the 5580Sstevel@tonic-gate * system clock. Recompute the new relative time 5590Sstevel@tonic-gate * and reissue the nanosleep() call if necessary. 5600Sstevel@tonic-gate * 5610Sstevel@tonic-gate * Resetting the system clock causes all sorts of 5620Sstevel@tonic-gate * problems and the SUSV3 standards body should 5630Sstevel@tonic-gate * have made the behavior of clock_nanosleep() be 5640Sstevel@tonic-gate * implementation-defined in such a case rather than 5650Sstevel@tonic-gate * being specific about honoring the new system time. 5660Sstevel@tonic-gate * Standards bodies are filled with fools and idiots. 5670Sstevel@tonic-gate */ 5680Sstevel@tonic-gate abstime_to_reltime(clock_id, rqtp, &reltime); 5690Sstevel@tonic-gate if (reltime.tv_sec != 0 || reltime.tv_nsec != 0) 5700Sstevel@tonic-gate goto restart; 5710Sstevel@tonic-gate } 5720Sstevel@tonic-gate return (error); 5730Sstevel@tonic-gate } 5740Sstevel@tonic-gate 5750Sstevel@tonic-gate #pragma weak sleep = _sleep 5760Sstevel@tonic-gate unsigned int 5770Sstevel@tonic-gate _sleep(unsigned int sec) 5780Sstevel@tonic-gate { 5790Sstevel@tonic-gate unsigned int rem = 0; 5800Sstevel@tonic-gate int error; 5810Sstevel@tonic-gate timespec_t ts; 5820Sstevel@tonic-gate timespec_t tsr; 5830Sstevel@tonic-gate 5840Sstevel@tonic-gate ts.tv_sec = (time_t)sec; 5850Sstevel@tonic-gate ts.tv_nsec = 0; 5860Sstevel@tonic-gate PROLOGUE 5872248Sraf error = __nanosleep(&ts, &tsr); 5880Sstevel@tonic-gate EPILOGUE 5890Sstevel@tonic-gate if (error == EINTR) { 5900Sstevel@tonic-gate rem = (unsigned int)tsr.tv_sec; 5910Sstevel@tonic-gate if (tsr.tv_nsec >= NANOSEC / 2) 5920Sstevel@tonic-gate rem++; 5930Sstevel@tonic-gate } 5940Sstevel@tonic-gate return (rem); 5950Sstevel@tonic-gate } 5960Sstevel@tonic-gate 5970Sstevel@tonic-gate #pragma weak usleep = _usleep 5980Sstevel@tonic-gate int 5990Sstevel@tonic-gate _usleep(useconds_t usec) 6000Sstevel@tonic-gate { 6010Sstevel@tonic-gate timespec_t ts; 6020Sstevel@tonic-gate 6030Sstevel@tonic-gate ts.tv_sec = usec / MICROSEC; 6040Sstevel@tonic-gate ts.tv_nsec = (long)(usec % MICROSEC) * 1000; 6050Sstevel@tonic-gate PROLOGUE 6062248Sraf (void) __nanosleep(&ts, NULL); 6070Sstevel@tonic-gate EPILOGUE 6080Sstevel@tonic-gate return (0); 6090Sstevel@tonic-gate } 6100Sstevel@tonic-gate 6110Sstevel@tonic-gate int 6120Sstevel@tonic-gate close(int fildes) 6130Sstevel@tonic-gate { 6142248Sraf extern void _aio_close(int); 6150Sstevel@tonic-gate extern int _close(int); 6160Sstevel@tonic-gate int rv; 6170Sstevel@tonic-gate 6182248Sraf _aio_close(fildes); 6190Sstevel@tonic-gate PERFORM(_close(fildes)) 6200Sstevel@tonic-gate } 6210Sstevel@tonic-gate 6220Sstevel@tonic-gate int 6230Sstevel@tonic-gate creat(const char *path, mode_t mode) 6240Sstevel@tonic-gate { 6250Sstevel@tonic-gate extern int _creat(const char *, mode_t); 6260Sstevel@tonic-gate int rv; 6270Sstevel@tonic-gate 6280Sstevel@tonic-gate PERFORM(_creat(path, mode)) 6290Sstevel@tonic-gate } 6300Sstevel@tonic-gate 6310Sstevel@tonic-gate #if !defined(_LP64) 6320Sstevel@tonic-gate int 6330Sstevel@tonic-gate creat64(const char *path, mode_t mode) 6340Sstevel@tonic-gate { 6350Sstevel@tonic-gate extern int _creat64(const char *, mode_t); 6360Sstevel@tonic-gate int rv; 6370Sstevel@tonic-gate 6380Sstevel@tonic-gate PERFORM(_creat64(path, mode)) 6390Sstevel@tonic-gate } 6400Sstevel@tonic-gate #endif /* !_LP64 */ 6410Sstevel@tonic-gate 6420Sstevel@tonic-gate int 6430Sstevel@tonic-gate fcntl(int fildes, int cmd, ...) 6440Sstevel@tonic-gate { 6450Sstevel@tonic-gate extern int _fcntl(int, int, ...); 6460Sstevel@tonic-gate intptr_t arg; 6470Sstevel@tonic-gate int rv; 6480Sstevel@tonic-gate va_list ap; 6490Sstevel@tonic-gate 6500Sstevel@tonic-gate va_start(ap, cmd); 6510Sstevel@tonic-gate arg = va_arg(ap, intptr_t); 6520Sstevel@tonic-gate va_end(ap); 6530Sstevel@tonic-gate if (cmd != F_SETLKW) 6540Sstevel@tonic-gate return (_fcntl(fildes, cmd, arg)); 6550Sstevel@tonic-gate PERFORM(_fcntl(fildes, cmd, arg)) 6560Sstevel@tonic-gate } 6570Sstevel@tonic-gate 6580Sstevel@tonic-gate int 6594722Sraf fdatasync(int fildes) 6604722Sraf { 6614722Sraf extern int _fdatasync(int); 6624722Sraf int rv; 6634722Sraf 6644722Sraf PERFORM(_fdatasync(fildes)) 6654722Sraf } 6664722Sraf 6674722Sraf int 6680Sstevel@tonic-gate fsync(int fildes) 6690Sstevel@tonic-gate { 6700Sstevel@tonic-gate extern int _fsync(int); 6710Sstevel@tonic-gate int rv; 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate PERFORM(_fsync(fildes)) 6740Sstevel@tonic-gate } 6750Sstevel@tonic-gate 6760Sstevel@tonic-gate int 6770Sstevel@tonic-gate lockf(int fildes, int function, off_t size) 6780Sstevel@tonic-gate { 6790Sstevel@tonic-gate extern int _lockf(int, int, off_t); 6800Sstevel@tonic-gate int rv; 6810Sstevel@tonic-gate 6820Sstevel@tonic-gate PERFORM(_lockf(fildes, function, size)) 6830Sstevel@tonic-gate } 6840Sstevel@tonic-gate 6850Sstevel@tonic-gate #if !defined(_LP64) 6860Sstevel@tonic-gate int 6870Sstevel@tonic-gate lockf64(int fildes, int function, off64_t size) 6880Sstevel@tonic-gate { 6890Sstevel@tonic-gate extern int _lockf64(int, int, off64_t); 6900Sstevel@tonic-gate int rv; 6910Sstevel@tonic-gate 6920Sstevel@tonic-gate PERFORM(_lockf64(fildes, function, size)) 6930Sstevel@tonic-gate } 6940Sstevel@tonic-gate #endif /* !_LP64 */ 6950Sstevel@tonic-gate 6960Sstevel@tonic-gate ssize_t 6970Sstevel@tonic-gate msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) 6980Sstevel@tonic-gate { 6990Sstevel@tonic-gate extern ssize_t _msgrcv(int, void *, size_t, long, int); 7000Sstevel@tonic-gate ssize_t rv; 7010Sstevel@tonic-gate 7020Sstevel@tonic-gate PERFORM(_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)) 7030Sstevel@tonic-gate } 7040Sstevel@tonic-gate 7050Sstevel@tonic-gate int 7060Sstevel@tonic-gate msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) 7070Sstevel@tonic-gate { 7080Sstevel@tonic-gate extern int _msgsnd(int, const void *, size_t, int); 7090Sstevel@tonic-gate int rv; 7100Sstevel@tonic-gate 7110Sstevel@tonic-gate PERFORM(_msgsnd(msqid, msgp, msgsz, msgflg)) 7120Sstevel@tonic-gate } 7130Sstevel@tonic-gate 7140Sstevel@tonic-gate int 7150Sstevel@tonic-gate msync(caddr_t addr, size_t len, int flags) 7160Sstevel@tonic-gate { 7170Sstevel@tonic-gate extern int _msync(caddr_t, size_t, int); 7180Sstevel@tonic-gate int rv; 7190Sstevel@tonic-gate 7200Sstevel@tonic-gate PERFORM(_msync(addr, len, flags)) 7210Sstevel@tonic-gate } 7220Sstevel@tonic-gate 7230Sstevel@tonic-gate int 7240Sstevel@tonic-gate open(const char *path, int oflag, ...) 7250Sstevel@tonic-gate { 7260Sstevel@tonic-gate extern int _open(const char *, int, ...); 7270Sstevel@tonic-gate mode_t mode; 7280Sstevel@tonic-gate int rv; 7290Sstevel@tonic-gate va_list ap; 7300Sstevel@tonic-gate 7310Sstevel@tonic-gate va_start(ap, oflag); 7320Sstevel@tonic-gate mode = va_arg(ap, mode_t); 7330Sstevel@tonic-gate va_end(ap); 7340Sstevel@tonic-gate PERFORM(_open(path, oflag, mode)) 7350Sstevel@tonic-gate } 7360Sstevel@tonic-gate 7370Sstevel@tonic-gate #if !defined(_LP64) 7380Sstevel@tonic-gate int 7390Sstevel@tonic-gate open64(const char *path, int oflag, ...) 7400Sstevel@tonic-gate { 7410Sstevel@tonic-gate extern int _open64(const char *, int, ...); 7420Sstevel@tonic-gate mode_t mode; 7430Sstevel@tonic-gate int rv; 7440Sstevel@tonic-gate va_list ap; 7450Sstevel@tonic-gate 7460Sstevel@tonic-gate va_start(ap, oflag); 7470Sstevel@tonic-gate mode = va_arg(ap, mode_t); 7480Sstevel@tonic-gate va_end(ap); 7490Sstevel@tonic-gate PERFORM(_open64(path, oflag, mode)) 7500Sstevel@tonic-gate } 7510Sstevel@tonic-gate #endif /* !_LP64 */ 7520Sstevel@tonic-gate 7530Sstevel@tonic-gate int 7540Sstevel@tonic-gate pause(void) 7550Sstevel@tonic-gate { 7560Sstevel@tonic-gate extern int _pause(void); 7570Sstevel@tonic-gate int rv; 7580Sstevel@tonic-gate 7590Sstevel@tonic-gate PERFORM(_pause()) 7600Sstevel@tonic-gate } 7610Sstevel@tonic-gate 7620Sstevel@tonic-gate ssize_t 7630Sstevel@tonic-gate pread(int fildes, void *buf, size_t nbyte, off_t offset) 7640Sstevel@tonic-gate { 7650Sstevel@tonic-gate extern ssize_t _pread(int, void *, size_t, off_t); 7660Sstevel@tonic-gate ssize_t rv; 7670Sstevel@tonic-gate 7680Sstevel@tonic-gate PERFORM(_pread(fildes, buf, nbyte, offset)) 7690Sstevel@tonic-gate } 7700Sstevel@tonic-gate 7710Sstevel@tonic-gate #if !defined(_LP64) 7720Sstevel@tonic-gate ssize_t 7730Sstevel@tonic-gate pread64(int fildes, void *buf, size_t nbyte, off64_t offset) 7740Sstevel@tonic-gate { 7750Sstevel@tonic-gate extern ssize_t _pread64(int, void *, size_t, off64_t); 7760Sstevel@tonic-gate ssize_t rv; 7770Sstevel@tonic-gate 7780Sstevel@tonic-gate PERFORM(_pread64(fildes, buf, nbyte, offset)) 7790Sstevel@tonic-gate } 7800Sstevel@tonic-gate #endif /* !_LP64 */ 7810Sstevel@tonic-gate 7820Sstevel@tonic-gate ssize_t 7830Sstevel@tonic-gate pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) 7840Sstevel@tonic-gate { 7850Sstevel@tonic-gate extern ssize_t _pwrite(int, const void *, size_t, off_t); 7860Sstevel@tonic-gate ssize_t rv; 7870Sstevel@tonic-gate 7880Sstevel@tonic-gate PERFORM(_pwrite(fildes, buf, nbyte, offset)) 7890Sstevel@tonic-gate } 7900Sstevel@tonic-gate 7910Sstevel@tonic-gate #if !defined(_LP64) 7920Sstevel@tonic-gate ssize_t 7930Sstevel@tonic-gate pwrite64(int fildes, const void *buf, size_t nbyte, off64_t offset) 7940Sstevel@tonic-gate { 7950Sstevel@tonic-gate extern ssize_t _pwrite64(int, const void *, size_t, off64_t); 7960Sstevel@tonic-gate ssize_t rv; 7970Sstevel@tonic-gate 7980Sstevel@tonic-gate PERFORM(_pwrite64(fildes, buf, nbyte, offset)) 7990Sstevel@tonic-gate } 8000Sstevel@tonic-gate #endif /* !_LP64 */ 8010Sstevel@tonic-gate 8020Sstevel@tonic-gate ssize_t 8030Sstevel@tonic-gate readv(int fildes, const struct iovec *iov, int iovcnt) 8040Sstevel@tonic-gate { 8050Sstevel@tonic-gate extern ssize_t _readv(int, const struct iovec *, int); 8060Sstevel@tonic-gate ssize_t rv; 8070Sstevel@tonic-gate 8080Sstevel@tonic-gate PERFORM(_readv(fildes, iov, iovcnt)) 8090Sstevel@tonic-gate } 8100Sstevel@tonic-gate 8110Sstevel@tonic-gate int 8120Sstevel@tonic-gate sigpause(int sig) 8130Sstevel@tonic-gate { 8140Sstevel@tonic-gate extern int _sigpause(int); 8150Sstevel@tonic-gate int rv; 8160Sstevel@tonic-gate 8170Sstevel@tonic-gate PERFORM(_sigpause(sig)) 8180Sstevel@tonic-gate } 8190Sstevel@tonic-gate 8200Sstevel@tonic-gate #pragma weak sigsuspend = _sigsuspend 8210Sstevel@tonic-gate int 8220Sstevel@tonic-gate _sigsuspend(const sigset_t *set) 8230Sstevel@tonic-gate { 8240Sstevel@tonic-gate extern int __sigsuspend(const sigset_t *); 8250Sstevel@tonic-gate int rv; 8260Sstevel@tonic-gate 8270Sstevel@tonic-gate PROLOGUE_MASK(set) 8280Sstevel@tonic-gate rv = __sigsuspend(set); 8290Sstevel@tonic-gate EPILOGUE_MASK 8300Sstevel@tonic-gate return (rv); 8310Sstevel@tonic-gate } 8320Sstevel@tonic-gate 8330Sstevel@tonic-gate int 8340Sstevel@tonic-gate _pollsys(struct pollfd *fds, nfds_t nfd, const timespec_t *timeout, 8350Sstevel@tonic-gate const sigset_t *sigmask) 8360Sstevel@tonic-gate { 8370Sstevel@tonic-gate extern int __pollsys(struct pollfd *, nfds_t, const timespec_t *, 838*4843Sraf const sigset_t *); 8390Sstevel@tonic-gate int rv; 8400Sstevel@tonic-gate 8410Sstevel@tonic-gate PROLOGUE_MASK(sigmask) 8420Sstevel@tonic-gate rv = __pollsys(fds, nfd, timeout, sigmask); 8430Sstevel@tonic-gate EPILOGUE_MASK 8440Sstevel@tonic-gate return (rv); 8450Sstevel@tonic-gate } 8460Sstevel@tonic-gate 8472248Sraf #pragma weak sigtimedwait = _sigtimedwait 8480Sstevel@tonic-gate int 8492248Sraf _sigtimedwait(const sigset_t *set, siginfo_t *infop, const timespec_t *timeout) 8500Sstevel@tonic-gate { 8512248Sraf extern int __sigtimedwait(const sigset_t *, siginfo_t *, 852*4843Sraf const timespec_t *); 8530Sstevel@tonic-gate siginfo_t info; 8540Sstevel@tonic-gate int sig; 8550Sstevel@tonic-gate 8560Sstevel@tonic-gate PROLOGUE 8572248Sraf sig = __sigtimedwait(set, &info, timeout); 8580Sstevel@tonic-gate if (sig == SIGCANCEL && 8590Sstevel@tonic-gate (SI_FROMKERNEL(&info) || info.si_code == SI_LWP)) { 8600Sstevel@tonic-gate do_sigcancel(); 8610Sstevel@tonic-gate errno = EINTR; 8620Sstevel@tonic-gate sig = -1; 8630Sstevel@tonic-gate } 8640Sstevel@tonic-gate EPILOGUE 8650Sstevel@tonic-gate if (sig != -1 && infop) 8661111Sraf (void) _private_memcpy(infop, &info, sizeof (*infop)); 8670Sstevel@tonic-gate return (sig); 8680Sstevel@tonic-gate } 8690Sstevel@tonic-gate 8700Sstevel@tonic-gate #pragma weak sigwait = _sigwait 8710Sstevel@tonic-gate int 8720Sstevel@tonic-gate _sigwait(sigset_t *set) 8730Sstevel@tonic-gate { 8742248Sraf return (_sigtimedwait(set, NULL, NULL)); 8752248Sraf } 8762248Sraf 8772248Sraf #pragma weak sigwaitinfo = _sigwaitinfo 8782248Sraf int 8792248Sraf _sigwaitinfo(const sigset_t *set, siginfo_t *info) 8802248Sraf { 8812248Sraf return (_sigtimedwait(set, info, NULL)); 8822248Sraf } 8832248Sraf 8842248Sraf #pragma weak sigqueue = _sigqueue 8852248Sraf int 8862248Sraf _sigqueue(pid_t pid, int signo, const union sigval value) 8872248Sraf { 8882248Sraf extern int __sigqueue(pid_t pid, int signo, 889*4843Sraf /* const union sigval */ void *value, int si_code, int block); 8902248Sraf return (__sigqueue(pid, signo, value.sival_ptr, SI_QUEUE, 0)); 8910Sstevel@tonic-gate } 8920Sstevel@tonic-gate 8930Sstevel@tonic-gate int 8940Sstevel@tonic-gate tcdrain(int fildes) 8950Sstevel@tonic-gate { 8960Sstevel@tonic-gate extern int _tcdrain(int); 8970Sstevel@tonic-gate int rv; 8980Sstevel@tonic-gate 8990Sstevel@tonic-gate PERFORM(_tcdrain(fildes)) 9000Sstevel@tonic-gate } 9010Sstevel@tonic-gate 9020Sstevel@tonic-gate pid_t 9030Sstevel@tonic-gate wait(int *stat_loc) 9040Sstevel@tonic-gate { 9050Sstevel@tonic-gate extern pid_t _wait(int *); 9060Sstevel@tonic-gate pid_t rv; 9070Sstevel@tonic-gate 9080Sstevel@tonic-gate PERFORM(_wait(stat_loc)) 9090Sstevel@tonic-gate } 9100Sstevel@tonic-gate 9110Sstevel@tonic-gate pid_t 9120Sstevel@tonic-gate wait3(int *statusp, int options, struct rusage *rusage) 9130Sstevel@tonic-gate { 9140Sstevel@tonic-gate extern pid_t _wait3(int *, int, struct rusage *); 9150Sstevel@tonic-gate pid_t rv; 9160Sstevel@tonic-gate 9170Sstevel@tonic-gate PERFORM(_wait3(statusp, options, rusage)) 9180Sstevel@tonic-gate } 9190Sstevel@tonic-gate 9200Sstevel@tonic-gate int 9210Sstevel@tonic-gate waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) 9220Sstevel@tonic-gate { 9230Sstevel@tonic-gate extern int _waitid(idtype_t, id_t, siginfo_t *, int); 9240Sstevel@tonic-gate int rv; 9250Sstevel@tonic-gate 9260Sstevel@tonic-gate PERFORM(_waitid(idtype, id, infop, options)) 9270Sstevel@tonic-gate } 9280Sstevel@tonic-gate 9291219Sraf /* 9301219Sraf * waitpid_cancel() is a libc-private symbol for internal use 9311219Sraf * where cancellation semantics is desired (see system()). 9321219Sraf */ 9331219Sraf #pragma weak waitpid_cancel = waitpid 9340Sstevel@tonic-gate pid_t 9350Sstevel@tonic-gate waitpid(pid_t pid, int *stat_loc, int options) 9360Sstevel@tonic-gate { 9370Sstevel@tonic-gate extern pid_t _waitpid(pid_t, int *, int); 9380Sstevel@tonic-gate pid_t rv; 9390Sstevel@tonic-gate 9400Sstevel@tonic-gate PERFORM(_waitpid(pid, stat_loc, options)) 9410Sstevel@tonic-gate } 9420Sstevel@tonic-gate 9430Sstevel@tonic-gate ssize_t 9440Sstevel@tonic-gate writev(int fildes, const struct iovec *iov, int iovcnt) 9450Sstevel@tonic-gate { 9460Sstevel@tonic-gate extern ssize_t _writev(int, const struct iovec *, int); 9470Sstevel@tonic-gate ssize_t rv; 9480Sstevel@tonic-gate 9490Sstevel@tonic-gate PERFORM(_writev(fildes, iov, iovcnt)) 9500Sstevel@tonic-gate } 951