2 * Copyright (c) 1990 The Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * and/or other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 <<perror>>---print an error message on standard error
29 void perror(char *<[prefix]>);
31 void _perror_r(struct _reent *<[reent]>, char *<[prefix]>);
34 Use <<perror>> to print (on standard error) an error message
35 corresponding to the current value of the global variable <<errno>>.
36 Unless you use <<NULL>> as the value of the argument <[prefix]>, the
37 error message will begin with the string at <[prefix]>, followed by a
38 colon and a space (<<: >>). The remainder of the error message is one
39 of the strings described for <<strerror>>.
41 The alternate function <<_perror_r>> is a reentrant version. The
42 extra argument <[reent]> is a pointer to a reentrancy structure.
45 <<perror>> returns no result.
48 ANSI C requires <<perror>>, but the strings issued vary from one
49 implementation to another.
51 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
52 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
61 #define WRITE_STR(str) \
63 const char *p = (str); \
64 size_t len = strlen (p); \
67 ssize_t len1 = _write_r (ptr, fileno (fp), p, len); \
76 _perror_r (struct _reent
*ptr
,
81 FILE *fp
= _stderr_r (ptr
);
85 _newlib_flockfile_start(fp
);
87 if (s
!= NULL
&& *s
!= '\0')
93 if ((error
= _strerror_r (ptr
, _REENT_ERRNO(ptr
), 1, &dummy
)) != NULL
)
97 WRITE_STR ((fp
->_flags
& __SCLE
) ? "\r\n" : "\n");
101 fp
->_flags
&= ~__SOFF
;
102 _newlib_flockfile_end(fp
);
108 perror (const char *s
)
110 _perror_r (_REENT
, s
);