mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
FFI: Allow setting errno with ffi.errno(), too.
This commit is contained in:
parent
868ecad32b
commit
d9c1f771a7
@ -336,14 +336,16 @@ objects.
|
|||||||
|
|
||||||
<h2 id="util">Utility Functions</h2>
|
<h2 id="util">Utility Functions</h2>
|
||||||
|
|
||||||
<h3 id="ffi_errno"><tt>err = ffi.errno()</tt></h3>
|
<h3 id="ffi_errno"><tt>err = ffi.errno([newerr])</tt></h3>
|
||||||
<p>
|
<p>
|
||||||
Returns the error number set by the last C function call which
|
Returns the error number set by the last C function call which
|
||||||
indicated an error condition.
|
indicated an error condition. If the optional <tt>newerr</tt> argument
|
||||||
|
is present, the error number is set to the new value and the previous
|
||||||
|
value is returned.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
This function offers a portable and OS-independent way to get the error
|
This function offers a portable and OS-independent way to get and set the
|
||||||
number. Note that only <em>some</em> C functions set the error
|
error number. Note that only <em>some</em> C functions set the error
|
||||||
number. And it's only significant if the function actually indicated an
|
number. And it's only significant if the function actually indicated an
|
||||||
error condition (e.g. with a return value of <tt>-1</tt> or
|
error condition (e.g. with a return value of <tt>-1</tt> or
|
||||||
<tt>NULL</tt>). Otherwise, it may or may not contain any previously set
|
<tt>NULL</tt>). Otherwise, it may or may not contain any previously set
|
||||||
|
@ -545,7 +545,10 @@ LJLIB_CF(ffi_offsetof)
|
|||||||
|
|
||||||
LJLIB_CF(ffi_errno)
|
LJLIB_CF(ffi_errno)
|
||||||
{
|
{
|
||||||
setintV(L->top++, errno);
|
int err = errno;
|
||||||
|
if (L->top > L->base)
|
||||||
|
errno = ffi_checkint(L, 1);
|
||||||
|
setintV(L->top++, err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user