Changeset 1964 for cpio/vendor/current/gnu/getdtablesize.c
- Timestamp:
- Feb 3, 2017, 2:02:34 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified cpio/vendor/current/gnu/getdtablesize.c ¶
r118 r1964 1 /* -*- buffer-read-only: t -*- vi: set ro: */2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */3 1 /* getdtablesize() function for platforms that don't have it. 4 Copyright (C) 2008-201 0Free Software Foundation, Inc.2 Copyright (C) 2008-2015 Free Software Foundation, Inc. 5 3 Written by Bruno Haible <bruno@clisp.org>, 2008. 6 4 … … 25 23 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 26 24 27 # include <stdio.h>25 # include <stdio.h> 28 26 29 /* Cache for the previous getdtablesize () result. */ 27 # include "msvc-inval.h" 28 29 # if HAVE_MSVC_INVALID_PARAMETER_HANDLER 30 static int 31 _setmaxstdio_nothrow (int newmax) 32 { 33 int result; 34 35 TRY_MSVC_INVAL 36 { 37 result = _setmaxstdio (newmax); 38 } 39 CATCH_MSVC_INVAL 40 { 41 result = -1; 42 } 43 DONE_MSVC_INVAL; 44 45 return result; 46 } 47 # define _setmaxstdio _setmaxstdio_nothrow 48 # endif 49 50 /* Cache for the previous getdtablesize () result. Safe to cache because 51 Windows also lacks setrlimit. */ 30 52 static int dtablesize; 31 53 … … 63 85 } 64 86 87 #else 88 89 # include <limits.h> 90 # include <sys/resource.h> 91 92 # ifndef RLIM_SAVED_CUR 93 # define RLIM_SAVED_CUR RLIM_INFINITY 94 # endif 95 # ifndef RLIM_SAVED_MAX 96 # define RLIM_SAVED_MAX RLIM_INFINITY 97 # endif 98 99 # ifdef __CYGWIN__ 100 /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it 101 hits the compile-time constant hard limit of 3200. We might as 102 well just report the hard limit. */ 103 # define rlim_cur rlim_max 104 # endif 105 106 int 107 getdtablesize (void) 108 { 109 struct rlimit lim; 110 111 if (getrlimit (RLIMIT_NOFILE, &lim) == 0 112 && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX 113 && lim.rlim_cur != RLIM_INFINITY 114 && lim.rlim_cur != RLIM_SAVED_CUR 115 && lim.rlim_cur != RLIM_SAVED_MAX) 116 return lim.rlim_cur; 117 118 return INT_MAX; 119 } 120 65 121 #endif
Note:
See TracChangeset
for help on using the changeset viewer.