rpc_dtablesize.c revision 1.14.70.2 1 1.14.70.2 yamt /* $NetBSD: rpc_dtablesize.c,v 1.14.70.2 2014/05/22 11:36:53 yamt Exp $ */
2 1.3 cgd
3 1.1 cgd /*
4 1.14.70.2 yamt * Copyright (c) 2010, Oracle America, Inc.
5 1.14.70.2 yamt *
6 1.14.70.2 yamt * Redistribution and use in source and binary forms, with or without
7 1.14.70.2 yamt * modification, are permitted provided that the following conditions are
8 1.14.70.2 yamt * met:
9 1.14.70.2 yamt *
10 1.14.70.2 yamt * * Redistributions of source code must retain the above copyright
11 1.14.70.2 yamt * notice, this list of conditions and the following disclaimer.
12 1.14.70.2 yamt * * Redistributions in binary form must reproduce the above
13 1.14.70.2 yamt * copyright notice, this list of conditions and the following
14 1.14.70.2 yamt * disclaimer in the documentation and/or other materials
15 1.14.70.2 yamt * provided with the distribution.
16 1.14.70.2 yamt * * Neither the name of the "Oracle America, Inc." nor the names of its
17 1.14.70.2 yamt * contributors may be used to endorse or promote products derived
18 1.14.70.2 yamt * from this software without specific prior written permission.
19 1.14.70.2 yamt *
20 1.14.70.2 yamt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 1.14.70.2 yamt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 1.14.70.2 yamt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 1.14.70.2 yamt * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 1.14.70.2 yamt * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 1.14.70.2 yamt * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.14.70.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 1.14.70.2 yamt * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.14.70.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 1.14.70.2 yamt * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 1.14.70.2 yamt * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 1.14.70.2 yamt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 cgd */
33 1.1 cgd
34 1.9 christos #include <sys/cdefs.h>
35 1.1 cgd #if defined(LIBC_SCCS) && !defined(lint)
36 1.9 christos #if 0
37 1.9 christos static char *sccsid = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
38 1.9 christos static char *sccsid = "@(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC";
39 1.9 christos #else
40 1.14.70.2 yamt __RCSID("$NetBSD: rpc_dtablesize.c,v 1.14.70.2 2014/05/22 11:36:53 yamt Exp $");
41 1.9 christos #endif
42 1.1 cgd #endif
43 1.1 cgd
44 1.10 jtc #include "namespace.h"
45 1.13 lukem
46 1.8 cgd #include <unistd.h>
47 1.9 christos
48 1.14.70.1 yamt int _rpc_dtablesize(void); /* XXX */
49 1.2 andrew
50 1.1 cgd /*
51 1.7 mrg * Cache the result of sysconf(_SC_OPEN_MAX), so we don't have to do an
52 1.1 cgd * expensive system call every time.
53 1.1 cgd */
54 1.4 jtc int
55 1.14.70.1 yamt _rpc_dtablesize(void)
56 1.1 cgd {
57 1.1 cgd static int size;
58 1.7 mrg if (size == 0)
59 1.14 christos size = (int)sysconf(_SC_OPEN_MAX);
60 1.1 cgd return (size);
61 1.1 cgd }
62