summaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-02-16 19:57:14 +0000
committerRoland McGrath <roland@gnu.org>2005-02-16 19:57:14 +0000
commit7cd274587760436effbfce65cfdbd51f761acd67 (patch)
tree8620654b8197c81aded8a206680e53b4294baccf /posix
parentaa29d418cf3ee21f906247b6ab49e8aab6fd19dc (diff)
Updated to fedora-glibc-2_3-20050216T1256
Diffstat (limited to 'posix')
-rw-r--r--posix/Makefile11
-rw-r--r--posix/bug-regex19.c20
-rw-r--r--posix/execl.c48
-rw-r--r--posix/execle.c51
-rw-r--r--posix/execlp.c48
-rw-r--r--posix/execvp.c96
-rw-r--r--posix/getconf.c2
-rw-r--r--posix/regcomp.c22
-rw-r--r--posix/regex_internal.h7
-rw-r--r--posix/rxspencer/tests9
-rw-r--r--posix/tst-rxspencer.c18
-rw-r--r--posix/unistd.h16
12 files changed, 213 insertions, 135 deletions
diff --git a/posix/Makefile b/posix/Makefile
index 149283c65d..2a6f737165 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -140,16 +140,27 @@ CFLAGS-waitid.c = -fexceptions
CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-getopt.c = -fexceptions
CFLAGS-wordexp.c = -fexceptions
+CFLAGS-wordexp.os = -fomit-frame-pointer
CFLAGS-sysconf.c = -fexceptions -DGETCONF_DIR='"$(libexecdir)/getconf"'
CFLAGS-pathconf.c = -fexceptions
CFLAGS-fpathconf.c = -fexceptions
CFLAGS-spawn.c = -fexceptions
+CFLAGS-spawn.os = -fomit-frame-pointer
CFLAGS-spawnp.c = -fexceptions
+CFLAGS-spawnp.os = -fomit-frame-pointer
CFLAGS-spawni.c = -fexceptions
+CFLAGS-spawni.os = -fomit-frame-pointer
CFLAGS-pause.c = -fexceptions
CFLAGS-glob.c = $(uses-callbacks) -fexceptions
CFLAGS-glob64.c = $(uses-callbacks) -fexceptions
CFLAGS-getconf.c = -DGETCONF_DIR='"$(libexecdir)/getconf"'
+CFLAGS-execve.os = -fomit-frame-pointer
+CFLAGS-fexecve.os = -fomit-frame-pointer
+CFLAGS-execv.os = -fomit-frame-pointer
+CFLAGS-execle.os = -fomit-frame-pointer
+CFLAGS-execl.os = -fomit-frame-pointer
+CFLAGS-execvp.os = -fomit-frame-pointer
+CFLAGS-execlp.os = -fomit-frame-pointer
tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
--none random --col --color --colour
diff --git a/posix/bug-regex19.c b/posix/bug-regex19.c
index 4000b19b4d..3a6391cb01 100644
--- a/posix/bug-regex19.c
+++ b/posix/bug-regex19.c
@@ -170,22 +170,22 @@ static struct test_s
{ERE, "[^k]\\B[^k]", "kBk", 0, -1},
{ERE, "[^C]\\B[^C]", "CCCABA", 0, 3},
{ERE, "[^C]\\B[^C]", "CBC", 0, -1},
- {ERE, ".(\\b|\\B).", "=~AB", 0, 1},
+ {ERE, ".(\\b|\\B).", "=~AB", 0, 0},
{ERE, ".(\\b|\\B).", "A=C", 0, 0},
{ERE, ".(\\b|\\B).", "ABC", 0, 0},
- {ERE, ".(\\b|\\B).", "=~\\!", 0, -1},
- {ERE, "[^k](\\b|\\B)[^k]", "=~AB", 0, 1},
+ {ERE, ".(\\b|\\B).", "=~\\!", 0, 0},
+ {ERE, "[^k](\\b|\\B)[^k]", "=~AB", 0, 0},
{ERE, "[^k](\\b|\\B)[^k]", "A=C", 0, 0},
{ERE, "[^k](\\b|\\B)[^k]", "ABC", 0, 0},
- {ERE, "[^k](\\b|\\B)[^k]", "=~kBD", 0, 3},
- {ERE, "[^k](\\b|\\B)[^k]", "=~\\!", 0, -1},
- {ERE, "[^k](\\b|\\B)[^k]", "=~kB", 0, -1},
- {ERE, "[^C](\\b|\\B)[^C]", "=~AB", 0, 1},
+ {ERE, "[^k](\\b|\\B)[^k]", "=~kBD", 0, 0},
+ {ERE, "[^k](\\b|\\B)[^k]", "=~\\!", 0, 0},
+ {ERE, "[^k](\\b|\\B)[^k]", "=~kB", 0, 0},
+ {ERE, "[^C](\\b|\\B)[^C]", "=~AB", 0, 0},
{ERE, "[^C](\\b|\\B)[^C]", "A=C", 0, 0},
{ERE, "[^C](\\b|\\B)[^C]", "ABC", 0, 0},
- {ERE, "[^C](\\b|\\B)[^C]", "=~CBD", 0, 3},
- {ERE, "[^C](\\b|\\B)[^C]", "=~\\!", 0, -1},
- {ERE, "[^C](\\b|\\B)[^C]", "=~CB", 0, -1},
+ {ERE, "[^C](\\b|\\B)[^C]", "=~CBD", 0, 0},
+ {ERE, "[^C](\\b|\\B)[^C]", "=~\\!", 0, 0},
+ {ERE, "[^C](\\b|\\B)[^C]", "=~CB", 0, 0},
{ERE, "\\b([A]|[!]|.B)", "A=AC", 0, 0},
{ERE, "\\b([A]|[!]|.B)", "=AC", 0, 1},
{ERE, "\\b([A]|[!]|.B)", "!AC", 0, 1},
diff --git a/posix/execl.c b/posix/execl.c
index 62fd45db58..cffd714258 100644
--- a/posix/execl.c
+++ b/posix/execl.c
@@ -16,10 +16,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <alloca.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
#include <stackinfo.h>
@@ -33,46 +33,44 @@
int
execl (const char *path, const char *arg, ...)
{
- size_t argv_max = 1024;
- const char **argv = alloca (argv_max * sizeof (const char *));
- unsigned int i;
+#define INITIAL_ARGV_MAX 1024
+ size_t argv_max = INITIAL_ARGV_MAX;
+ const char *initial_argv[INITIAL_ARGV_MAX];
+ const char **argv = initial_argv;
va_list args;
argv[0] = arg;
va_start (args, arg);
- i = 0;
+ unsigned int i = 0;
while (argv[i++] != NULL)
{
if (i == argv_max)
{
- const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *));
-
-#ifndef _STACK_GROWS_UP
- if ((char *) nptr + argv_max == (char *) argv)
+ argv_max *= 2;
+ const char **nptr = realloc (argv == initial_argv ? NULL : argv,
+ argv_max * sizeof (const char *));
+ if (nptr == NULL)
{
- /* Stack grows down. */
- argv = (const char **) memcpy (nptr, argv,
- i * sizeof (const char *));
- argv_max += i;
+ if (argv != initial_argv)
+ free (argv);
+ return -1;
}
- else
-#endif
-#ifndef _STACK_GROWS_DOWN
- if ((char *) argv + i == (char *) nptr)
- /* Stack grows up. */
- argv_max += i;
- else
-#endif
- /* We have a hole in the stack. */
- argv = (const char **) memcpy (nptr, argv,
- i * sizeof (const char *));
+ if (argv == initial_argv)
+ /* We have to copy the already filled-in data ourselves. */
+ memcpy (nptr, argv, i * sizeof (const char *));
+
+ argv = nptr;
}
argv[i] = va_arg (args, const char *);
}
va_end (args);
- return __execve (path, (char *const *) argv, __environ);
+ int ret = __execve (path, (char *const *) argv, __environ);
+ if (argv != initial_argv)
+ free (argv);
+
+ return ret;
}
libc_hidden_def (execl)
diff --git a/posix/execle.c b/posix/execle.c
index 2199ebeb74..e956bb63cd 100644
--- a/posix/execle.c
+++ b/posix/execle.c
@@ -16,10 +16,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <alloca.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
#include <stackinfo.h>
@@ -29,48 +29,45 @@
int
execle (const char *path, const char *arg, ...)
{
- size_t argv_max = 1024;
- const char **argv = alloca (argv_max * sizeof (const char *));
- const char *const *envp;
- unsigned int i;
+#define INITIAL_ARGV_MAX 1024
+ size_t argv_max = INITIAL_ARGV_MAX;
+ const char *initial_argv[INITIAL_ARGV_MAX];
+ const char **argv = initial_argv;
va_list args;
argv[0] = arg;
va_start (args, arg);
- i = 0;
+ unsigned int i = 0;
while (argv[i++] != NULL)
{
if (i == argv_max)
{
- const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *));
-
-#ifndef _STACK_GROWS_UP
- if ((char *) nptr + argv_max == (char *) argv)
+ argv_max *= 2;
+ const char **nptr = realloc (argv == initial_argv ? NULL : argv,
+ argv_max * sizeof (const char *));
+ if (nptr == NULL)
{
- /* Stack grows down. */
- argv = (const char **) memcpy (nptr, argv,
- i * sizeof (const char *));
- argv_max += i;
+ if (argv != initial_argv)
+ free (argv);
+ return -1;
}
- else
-#endif
-#ifndef _STACK_GROWS_DOWN
- if ((char *) argv + i == (char *) nptr)
- /* Stack grows up. */
- argv_max += i;
- else
-#endif
- /* We have a hole in the stack. */
- argv = (const char **) memcpy (nptr, argv,
- i * sizeof (const char *));
+ if (argv == initial_argv)
+ /* We have to copy the already filled-in data ourselves. */
+ memcpy (nptr, argv, i * sizeof (const char *));
+
+ argv = nptr;
}
argv[i] = va_arg (args, const char *);
}
- envp = va_arg (args, const char *const *);
+ const char *const *envp = va_arg (args, const char *const *);
va_end (args);
- return __execve (path, (char *const *) argv, (char *const *) envp);
+ int ret = __execve (path, (char *const *) argv, (char *const *) envp);
+ if (argv != initial_argv)
+ free (argv);
+
+ return ret;
}
libc_hidden_def (execle)
diff --git a/posix/execlp.c b/posix/execlp.c
index ba8fc74c90..c530397aa0 100644
--- a/posix/execlp.c
+++ b/posix/execlp.c
@@ -16,10 +16,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <alloca.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
#include <stackinfo.h>
@@ -30,46 +30,44 @@
int
execlp (const char *file, const char *arg, ...)
{
- size_t argv_max = 1024;
- const char **argv = alloca (argv_max * sizeof (const char *));
- unsigned int i;
+#define INITIAL_ARGV_MAX 1024
+ size_t argv_max = INITIAL_ARGV_MAX;
+ const char *initial_argv[INITIAL_ARGV_MAX];
+ const char **argv = initial_argv;
va_list args;
argv[0] = arg;
va_start (args, arg);
- i = 0;
+ unsigned int i = 0;
while (argv[i++] != NULL)
{
if (i == argv_max)
{
- const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *));
-
-#ifndef _STACK_GROWS_UP
- if ((char *) nptr + argv_max == (char *) argv)
+ argv_max *= 2;
+ const char **nptr = realloc (argv == initial_argv ? NULL : argv,
+ argv_max * sizeof (const char *));
+ if (nptr == NULL)
{
- /* Stack grows down. */
- argv = (const char **) memcpy (nptr, argv,
- i * sizeof (const char *));
- argv_max += i;
+ if (argv != initial_argv)
+ free (argv);
+ return -1;
}
- else
-#endif
-#ifndef _STACK_GROWS_DOWN
- if ((char *) argv + i == (char *) nptr)
- /* Stack grows up. */
- argv_max += i;
- else
-#endif
- /* We have a hole in the stack. */
- argv = (const char **) memcpy (nptr, argv,
- i * sizeof (const char *));
+ if (argv == initial_argv)
+ /* We have to copy the already filled-in data ourselves. */
+ memcpy (nptr, argv, i * sizeof (const char *));
+
+ argv = nptr;
}
argv[i] = va_arg (args, const char *);
}
va_end (args);
- return execvp (file, (char *const *) argv);
+ int ret = execvp (file, (char *const *) argv);
+ if (argv != initial_argv)
+ free (argv);
+
+ return ret;
}
libc_hidden_def (execlp)
diff --git a/posix/execvp.c b/posix/execvp.c
index d6f60c02e7..a79d4a89c5 100644
--- a/posix/execvp.c
+++ b/posix/execvp.c
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -26,9 +27,9 @@
/* The file is accessible but it is not an executable file. Invoke
the shell to interpret it as a script. */
-static void
+static char **
internal_function
-script_execute (const char *file, char *const argv[])
+allocate_scripts_argv (const char *file, char *const argv[])
{
/* Count the arguments. */
int argc = 0;
@@ -36,19 +37,19 @@ script_execute (const char *file, char *const argv[])
;
/* Construct an argument list for the shell. */
- {
- char *new_argv[argc + 1];
- new_argv[0] = (char *) _PATH_BSHELL;
- new_argv[1] = (char *) file;
- while (argc > 1)
- {
- new_argv[argc] = argv[argc - 1];
- --argc;
- }
-
- /* Execute the shell. */
- __execve (new_argv[0], new_argv, __environ);
- }
+ char **new_argv = (char **) malloc ((argc + 1) * sizeof (char *));
+ if (new_argv != NULL)
+ {
+ new_argv[0] = (char *) _PATH_BSHELL;
+ new_argv[1] = (char *) file;
+ while (argc > 1)
+ {
+ new_argv[argc] = argv[argc - 1];
+ --argc;
+ }
+ }
+
+ return new_argv;
}
@@ -66,42 +67,58 @@ execvp (file, argv)
return -1;
}
+ char **script_argv = NULL;
+
if (strchr (file, '/') != NULL)
{
/* Don't search when it contains a slash. */
__execve (file, argv, __environ);
if (errno == ENOEXEC)
- script_execute (file, argv);
+ {
+ script_argv = allocate_scripts_argv (file, argv);
+ if (script_argv != NULL)
+ {
+ __execve (script_argv[0], script_argv, __environ);
+
+ free (script_argv);
+ }
+ }
}
else
{
- int got_eacces = 0;
- char *path, *p, *name;
- size_t len;
- size_t pathlen;
-
- path = getenv ("PATH");
+ char *path = getenv ("PATH");
+ bool path_malloc = false;
if (path == NULL)
{
/* There is no `PATH' in the environment.
The default search path is the current directory
followed by the path `confstr' returns for `_CS_PATH'. */
- len = confstr (_CS_PATH, (char *) NULL, 0);
- path = (char *) __alloca (1 + len);
+ size_t len = confstr (_CS_PATH, (char *) NULL, 0);
+ path = (char *) malloc (1 + len);
+ if (path == NULL)
+ return -1;
path[0] = ':';
(void) confstr (_CS_PATH, path + 1, len);
+ path_malloc = true;
}
- len = strlen (file) + 1;
- pathlen = strlen (path);
- name = __alloca (pathlen + len + 1);
+ size_t len = strlen (file) + 1;
+ size_t pathlen = strlen (path);
+ char *name = malloc (pathlen + len + 1);
+ if (name == NULL)
+ {
+ if (path_malloc)
+ free (path);
+ return -1;
+ }
/* Copy the file name at the top. */
name = (char *) memcpy (name + pathlen + 1, file, len);
/* And add the slash. */
*--name = '/';
- p = path;
+ bool got_eacces = false;
+ char *p = path;
do
{
char *startp;
@@ -120,7 +137,21 @@ execvp (file, argv)
__execve (startp, argv, __environ);
if (errno == ENOEXEC)
- script_execute (startp, argv);
+ {
+ if (script_argv == NULL)
+ {
+ script_argv = allocate_scripts_argv (file, argv);
+ if (script_argv == NULL)
+ {
+ /* A possible EACCES error is not as important as
+ the ENOMEM. */
+ got_eacces = false;
+ break;
+ }
+ }
+
+ __execve (script_argv[0], script_argv, __environ);
+ }
switch (errno)
{
@@ -128,7 +159,7 @@ execvp (file, argv)
/* Record the we got a `Permission denied' error. If we end
up finding no executable we can use, we want to diagnose
that we did find one but were denied access. */
- got_eacces = 1;
+ got_eacces = true;
case ENOENT:
case ESTALE:
case ENOTDIR:
@@ -156,6 +187,11 @@ execvp (file, argv)
/* At least one failure was due to permissions, so report that
error. */
__set_errno (EACCES);
+
+ free (script_argv);
+ free (name);
+ if (path_malloc)
+ free (path);
}
/* Return the error from the last attempt (probably ENOENT). */
diff --git a/posix/getconf.c b/posix/getconf.c
index 4ce4f8e413..e21e3f5a72 100644
--- a/posix/getconf.c
+++ b/posix/getconf.c
@@ -964,7 +964,7 @@ main (int argc, char *argv[])
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-"), "2004");
+"), "2005");
fprintf (stderr, gettext ("Written by %s.\n"), "Roland McGrath");
return 0;
}
diff --git a/posix/regcomp.c b/posix/regcomp.c
index 5de5bf725a..72bf187b14 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -1859,7 +1859,7 @@ peek_token (token, input, syntax)
if (!(syntax & RE_NO_GNU_OPS))
{
token->type = ANCHOR;
- token->opr.ctx_type = INSIDE_WORD;
+ token->opr.ctx_type = NOT_WORD_DELIM;
}
break;
case 'w':
@@ -2349,15 +2349,25 @@ parse_expression (regexp, preg, token, syntax, nest, err)
break;
case ANCHOR:
if ((token->opr.ctx_type
- & (WORD_DELIM | INSIDE_WORD | WORD_FIRST | WORD_LAST))
+ & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
&& dfa->word_ops_used == 0)
init_word_char (dfa);
- if (token->opr.ctx_type == WORD_DELIM)
+ if (token->opr.ctx_type == WORD_DELIM
+ || token->opr.ctx_type == NOT_WORD_DELIM)
{
bin_tree_t *tree_first, *tree_last;
- token->opr.ctx_type = WORD_FIRST;
- tree_first = re_dfa_add_tree_node (dfa, NULL, NULL, token);
- token->opr.ctx_type = WORD_LAST;
+ if (token->opr.ctx_type == WORD_DELIM)
+ {
+ token->opr.ctx_type = WORD_FIRST;
+ tree_first = re_dfa_add_tree_node (dfa, NULL, NULL, token);
+ token->opr.ctx_type = WORD_LAST;
+ }
+ else
+ {
+ token->opr.ctx_type = INSIDE_WORD;
+ tree_first = re_dfa_add_tree_node (dfa, NULL, NULL, token);
+ token->opr.ctx_type = INSIDE_NOTWORD;
+ }
tree_last = re_dfa_add_tree_node (dfa, NULL, NULL, token);
token->type = OP_ALT;
tree = re_dfa_add_tree_node (dfa, tree_first, tree_last, token);
diff --git a/posix/regex_internal.h b/posix/regex_internal.h
index 0ccd8d3665..18865a7266 100644
--- a/posix/regex_internal.h
+++ b/posix/regex_internal.h
@@ -143,18 +143,21 @@ static inline void bitset_mask (bitset dest, const bitset src);
#define NEXT_NEWLINE_CONSTRAINT 0x0020
#define PREV_BEGBUF_CONSTRAINT 0x0040
#define NEXT_ENDBUF_CONSTRAINT 0x0080
-#define DUMMY_CONSTRAINT 0x0100
+#define WORD_DELIM_CONSTRAINT 0x0100
+#define NOT_WORD_DELIM_CONSTRAINT 0x0200
typedef enum
{
INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT,
WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
+ INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT,
LINE_FIRST = PREV_NEWLINE_CONSTRAINT,
LINE_LAST = NEXT_NEWLINE_CONSTRAINT,
BUF_FIRST = PREV_BEGBUF_CONSTRAINT,
BUF_LAST = NEXT_ENDBUF_CONSTRAINT,
- WORD_DELIM = DUMMY_CONSTRAINT
+ WORD_DELIM = WORD_DELIM_CONSTRAINT,
+ NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT
} re_context_type;
typedef struct
diff --git a/posix/rxspencer/tests b/posix/rxspencer/tests
index a724252d8c..a8b6e4baa8 100644
--- a/posix/rxspencer/tests
+++ b/posix/rxspencer/tests
@@ -526,3 +526,12 @@ a((b+|((c)*)))+d - abcd abcd c,c,c,c
(((\b))){0} - x @x -,-,-
a(((.*)))b((\2)){0}c - abc abc @bc,@bc,@bc,-,-
a(((.*)))b((\1)){0}c - axbc axbc x,x,x,-,-
+
+\b & SaT @aT
+\b & aT @aT
+a.*\b & abT ab
+\b & STSS
+\B & abc @bc
+\B & aSbTc
+\B & SaT @SaT
+\B & aSTSb @TSb
diff --git a/posix/tst-rxspencer.c b/posix/tst-rxspencer.c
index cb40421797..3febc01cb2 100644
--- a/posix/tst-rxspencer.c
+++ b/posix/tst-rxspencer.c
@@ -127,14 +127,15 @@ mb_frob_string (const char *str, const char *letters)
}
/* Like mb_frob_string, but don't replace anything between
- [: and :], [. and .] or [= and =]. */
+ [: and :], [. and .] or [= and =] or characters escaped
+ with a backslash. */
static char *
mb_frob_pattern (const char *str, const char *letters)
{
char *ret, *dst;
const char *src;
- int in_class = 0;
+ int in_class = 0, escaped = 0;
if (str == NULL)
return NULL;
@@ -144,7 +145,18 @@ mb_frob_pattern (const char *str, const char *letters)
return NULL;
for (src = str, dst = ret; *src; ++src)
- if (!in_class && strchr (letters, *src))
+ if (*src == '\\')
+ {
+ escaped ^= 1;
+ *dst++ = *src;
+ }
+ else if (escaped)
+ {
+ escaped = 0;
+ *dst++ = *src;
+ continue;
+ }
+ else if (!in_class && strchr (letters, *src))
dst = mb_replace (dst, *src);
else
{
diff --git a/posix/unistd.h b/posix/unistd.h
index 5d42169e82..bf66f7543a 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -884,6 +884,11 @@ extern void sync (void) __THROW;
extern int getpagesize (void) __THROW __attribute__ ((__const__));
+/* Return the maximum number of file descriptors
+ the current process could possibly have. */
+extern int getdtablesize (void) __THROW;
+
+
/* Truncate FILE to LENGTH bytes. */
# ifndef __USE_FILE_OFFSET64
extern int truncate (__const char *__file, __off_t __length)
@@ -902,6 +907,10 @@ extern int truncate64 (__const char *__file, __off64_t __length)
__THROW __nonnull ((1));
# endif
+#endif /* Use BSD || X/Open Unix. */
+
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
+
/* Truncate the file FD is open on to LENGTH bytes. */
# ifndef __USE_FILE_OFFSET64
extern int ftruncate (int __fd, __off_t __length) __THROW;
@@ -917,12 +926,7 @@ extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length),
extern int ftruncate64 (int __fd, __off64_t __length) __THROW;
# endif
-
-/* Return the maximum number of file descriptors
- the current process could possibly have. */
-extern int getdtablesize (void) __THROW;
-
-#endif /* Use BSD || X/Open Unix. */
+#endif /* Use BSD || X/Open Unix || POSIX 2003. */
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED