Add perror()

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5061 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-08-28 19:01:14 +00:00
parent 1ebb6bd95a
commit 17007aee76
2 changed files with 30 additions and 4 deletions

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
<p>Last Updated: August 7, 2012</p>
<p>Last Updated: August 28, 2012</p>
</td>
</tr>
</table>
@ -2284,8 +2284,9 @@ nsh>
<tr>
<td valign="top"><b><code>CONFIG_NSH_STRERROR</code></b></td>
<td>
strerror(errno) makes more readable output but strerror() is
very large and will not be used unless this setting is <i>y</i>
<code>strerror(errno)</code> makes more readable output but <code>strerror()</code> is
very large and will not be used unless this setting is <i>y</i>.
This setting depends upon the <code>strerror()</code> having been enabled with <code>CONFIG_LIBC_STRERROR</code>.
</td>
</tr>
<tr>

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
<p>Last Updated: July 8, 2012</p>
<p>Last Updated: August 28, 2012</p>
</td>
</tr>
</table>
@ -4350,6 +4350,31 @@ build
<code>CONFIG_LIBC_FLOATINGPOINT</code>: By default, floating point
support in <code>printf</code>, <code>sscanf</code>, etc. is disabled.
</li>
<li>
<code>CONFIG_LIBC_STRERROR</code>:
<code>strerror()</code> is useful because it decodes <code>errno</code> values into a human readable strings.
But it can also require a lot of memory to store the strings.
If this option is selected, <code>strerror()</code> will still exist in the build but it will not decode error values.
This option should be used by other logic to decide if it should use <code>strerror()</code> or not.
For example, the NSH application will not use <code>strerror()</code> if this option is not selected;
<code>perror(</code>) will not use strerror() is this option is not selected (see also <code>CONFIG_NSH_STRERROR</code>).
</li>
<li>
<code>CONFIG_LIBC_STRERROR_SHORT</code>:
If this option is selected, then <code>strerror()</code> will use a shortened string when it decodes the error.
Specifically, <code>strerror()</code> is simply use the string that is the common name for the error.
For example, the <code>errno</code> value of 2 will produce the string &quot;No such file or directory&quot; is <code>CONFIG_LIBC_STRERROR_SHORT</code> is not defined but the string &quot;ENOENT&quot; is <code>CONFIG_LIBC_STRERROR_SHORT</code> is defined.
</li>
<li>
<code>CONFIG_LIBC_PERROR_STDOUT</code>:
POSIX requires that <code>perror()</code> provide its output on <code>stderr</code>.
This option may be defined, however, to provide <code>perror()</code> output that is serialized with other <code>stdout</code> messages.
</li>
<li>
<code>CONFIG_LIBC_PERROR_DEVNAME</code>:
Another non-standard option is to provide <code>perror()</code> output to a logging device or file.
<code>CONFIG_LIBC_PERROR_DEVNAME<code> may be defined to be any write-able, character device (or file).
</li>
</ul>
<h2>Allow for architecture optimized implementations</h2>