OSDN Git Service

lseek: Correct order of offset arguments
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / getdtablesize.c
1 /*
2  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3  *
4  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5  */
6
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <sys/resource.h>
10 #include <limits.h>
11
12 /* XXX: _BSD || _XOPEN_SOURCE >= 500 */
13 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
14
15
16 #define __LOCAL_OPEN_MAX            256
17
18 /* Return the maximum number of file descriptors
19    the current process could possibly have.  */
20 int getdtablesize (void)
21 {
22   struct rlimit ru;
23
24   /* This should even work if `getrlimit' is not implemented.  POSIX.1
25      does not define this function but we will generate a stub which
26      returns -1.  */
27   return getrlimit (RLIMIT_NOFILE, &ru) < 0 ? __LOCAL_OPEN_MAX : ru.rlim_cur;
28 }
29 libc_hidden_def(getdtablesize)
30 #endif