/* * Copyright (C) 2000-2006 Erik Andersen * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #include #include #include #include /* XXX: _BSD || _XOPEN_SOURCE >= 500 */ #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED #define __LOCAL_OPEN_MAX 256 /* Return the maximum number of file descriptors the current process could possibly have. */ int getdtablesize (void) { struct rlimit ru; /* This should even work if `getrlimit' is not implemented. POSIX.1 does not define this function but we will generate a stub which returns -1. */ return getrlimit (RLIMIT_NOFILE, &ru) < 0 ? __LOCAL_OPEN_MAX : ru.rlim_cur; } libc_hidden_def(getdtablesize) #endif