Imported Upstream version 4.5.10
[platform/upstream/findutils.git] / lib / arg-max.h
1 /* arg-max.h -- ARG_MAX and _SC_ARG_MAX checks and manipulations
2
3    Copyright (C) 2010 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18    Written by James Youngman.
19 */
20 #ifndef INC_ARG_MAX_H
21 #define INC_ARG_MAX_H 1
22
23 #include <unistd.h>             /* for sysconf() */
24
25 #ifdef __INTERIX
26 /* On Interix, _SC_ARG_MAX yields a value that (according to
27  * http://lists.gnu.org/archive/html/bug-findutils/2010-10/msg00047.html)
28  * actually does not work (i.e. it is larger than the real limit).
29  * The value of ARG_MAX is reportedly smaller than the real limit.
30  *
31  * I considered a configure test for this which allocates an argument
32  * list longer than ARG_MAX but shorter than _SC_ARG_MAX and then
33  * tries to exec something, but this will not work for us when
34  * cross-compiling if the target is Interix.
35  *
36  * Although buildcmd has heuristics for dealing with the possibility
37  * that execve fails due to length limits in the implementation, it
38  * assumed that changes are only necessary if execve fails with errno
39  * set to E2BIG.  On Interix, this failure mode of execve appears to
40  * set errno to ENOMEM.
41  *
42  * Since we may undefine _SC_ARG_MAX, we must include this header after
43  * unistd.h.
44  */
45 # undef _SC_ARG_MAX
46 # define BC_SC_ARG_MAX_IS_UNRELIABLE 1
47 #endif
48
49 #endif