xref: /illumos-gate/usr/src/lib/libnsl/rpc/rpc_mt.h (revision 1da57d55)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21e8031f0aSraf 
227c478bd9Sstevel@tonic-gate /*
23e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  *	Contains the mt libraries include definitions
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef	_RPC_MT_H
327c478bd9Sstevel@tonic-gate #define	_RPC_MT_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
3645916cd2Sjpk #include <netconfig.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * declaration to private interfaces in rpc library
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate extern int svc_npollfds;
477c478bd9Sstevel@tonic-gate extern int svc_npollfds_set;
487c478bd9Sstevel@tonic-gate extern int svc_pollfd_allocd;
497c478bd9Sstevel@tonic-gate extern rwlock_t svc_fd_lock;
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * macros to handle pollfd array; ***** Note that the macro takes
537c478bd9Sstevel@tonic-gate  * address of the array ( &array[0] ) always not the address of an
547c478bd9Sstevel@tonic-gate  * element *****.
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #define	MASKVAL	(POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)
587c478bd9Sstevel@tonic-gate #define	POLLFD_EXTEND		64
597c478bd9Sstevel@tonic-gate #define	POLLFD_SHRINK		(2 * POLLFD_EXTEND)
607c478bd9Sstevel@tonic-gate #define	POLLFD_SET(x, y)	{ \
617c478bd9Sstevel@tonic-gate 					(y)[(x)].fd = (x); \
627c478bd9Sstevel@tonic-gate 					(y)[(x)].events = MASKVAL; \
637c478bd9Sstevel@tonic-gate 				}
647c478bd9Sstevel@tonic-gate #define	POLLFD_CLR(x, y)	{ \
657c478bd9Sstevel@tonic-gate 					(y)[(x)].fd = -1; \
667c478bd9Sstevel@tonic-gate 					(y)[(x)].events = 0; \
677c478bd9Sstevel@tonic-gate 					(y)[(x)].revents = 0; \
687c478bd9Sstevel@tonic-gate 				}
697c478bd9Sstevel@tonic-gate #define	POLLFD_ISSET(x, y)	((y)[(x)].fd >= 0)
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate extern int __rpc_use_pollfd_done;
737c478bd9Sstevel@tonic-gate extern int __rpc_rlim_max(void);
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /* Following functions create and manipulates the dgfd lock object */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate extern void *rpc_fd_init(void);
787c478bd9Sstevel@tonic-gate extern int rpc_fd_lock(const void *handle, int fd);
797c478bd9Sstevel@tonic-gate extern void rpc_fd_unlock(const void *handle, int fd);
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate #define	RPC_FD_NOTIN_FDSET(x)	(!__rpc_use_pollfd_done && (x) >= FD_SETSIZE)
827c478bd9Sstevel@tonic-gate #define	FD_INCREMENT FD_SETSIZE
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * External functions without prototypes.  This is somewhat crufty, but
867c478bd9Sstevel@tonic-gate  * there is no other header file for this directory.  One should probably
877c478bd9Sstevel@tonic-gate  * be created and this stuff moved there if there turns out to be no better
887c478bd9Sstevel@tonic-gate  * way to avoid the warnings.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate 
91*004388ebScasper #define	RPC_MINFD	3
92*004388ebScasper 
93*004388ebScasper #define	RPC_RAISEFD(fd)		if (fd < RPC_MINFD) \
94*004388ebScasper 					fd = __rpc_raise_fd(fd)
95*004388ebScasper 
967c478bd9Sstevel@tonic-gate extern int	__getpublickey_cached(char *, char *, int *);
977c478bd9Sstevel@tonic-gate extern void	__getpublickey_flush(const char *);
987c478bd9Sstevel@tonic-gate extern int	__can_use_af(sa_family_t);
997c478bd9Sstevel@tonic-gate extern int	__rpc_raise_fd(int);
10045916cd2Sjpk extern void	__rpc_set_mac_options(int, const struct netconfig *,
10145916cd2Sjpk 	rpcprog_t);
1027c478bd9Sstevel@tonic-gate extern void	__tli_sys_strerror(char *, size_t, int, int);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1057c478bd9Sstevel@tonic-gate }
1067c478bd9Sstevel@tonic-gate #endif
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate #endif	/* !_RPC_MT_H */
109