fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / string / strerror_r.c
blob956a1f48557f3cc9c5da0a8d91571082e2f4b4bb
1 /*
2 FUNCTION
3 <<strerror_r>>---convert error number to string and copy to buffer
5 INDEX
6 strerror_r
8 ANSI_SYNOPSIS
9 #include <string.h>
10 char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>);
12 TRAD_SYNOPSIS
13 #include <string.h>
14 char *strerror_r(<[errnum]>, <[buffer]>, <[n]>)
15 int <[errnum]>;
16 char *<[buffer]>;
17 size_t <[n]>;
19 DESCRIPTION
20 <<strerror_r>> converts the error number <[errnum]> into a
21 string and copies the result into the supplied <[buffer]> for
22 a length up to <[n]>, including the NUL terminator. The value of
23 <[errnum]> is usually a copy of <<errno>>. If <<errnum>> is not a known
24 error number, the result is the empty string.
26 See <<strerror>> for how strings are mapped to <<errnum>>.
28 RETURNS
29 This function returns a pointer to a string. Your application must
30 not modify that string.
32 PORTABILITY
33 <<strerror_r>> is a gnu extension.
35 <<strerror_r>> requires no supporting OS subroutines.
39 #undef __STRICT_ANSI__
40 #include <errno.h>
41 #include <string.h>
43 char *
44 _DEFUN (strerror_r, (errnum, buffer, n),
45 int errnum _AND
46 char *buffer _AND
47 size_t n)
49 char *error;
50 error = strerror (errnum);
52 return strncpy (buffer, (const char *)error, n);