diff options
author | Mike Pall <mike> | 2011-11-26 16:54:52 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-11-26 16:56:09 +0100 |
commit | e3c7476533c892ab1ac24dea45efb4204b15c577 (patch) | |
tree | 6b8518de918dab2662e9f4edb75aae0f40a319f3 | |
parent | 1a42c038071d31a0ba8a300e59bb6b2b1d8d5fb1 (diff) | |
download | luajit-e3c7476533c892ab1ac24dea45efb4204b15c577.tar.gz luajit-e3c7476533c892ab1ac24dea45efb4204b15c577.tar.bz2 luajit-e3c7476533c892ab1ac24dea45efb4204b15c577.zip |
FFI: Record ffi.errno().
-rw-r--r-- | doc/ext_ffi_semantics.html | 2 | ||||
-rw-r--r-- | src/lib_ffi.c | 2 | ||||
-rw-r--r-- | src/lj_crecord.c | 8 | ||||
-rw-r--r-- | src/lj_crecord.h | 2 | ||||
-rw-r--r-- | src/lj_ircall.h | 1 | ||||
-rw-r--r-- | src/lj_vm.h | 3 | ||||
-rw-r--r-- | src/lj_vmmath.c | 8 |
7 files changed, 24 insertions, 2 deletions
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html index f3be0799..b111ed5d 100644 --- a/doc/ext_ffi_semantics.html +++ b/doc/ext_ffi_semantics.html | |||
@@ -1119,7 +1119,7 @@ value.</li> | |||
1119 | <li>Calls to the following <a href="ext_ffi_api.html">ffi.* API</a> | 1119 | <li>Calls to the following <a href="ext_ffi_api.html">ffi.* API</a> |
1120 | functions: <tt>cdef</tt>, <tt>load</tt>, <tt>typeof</tt>, | 1120 | functions: <tt>cdef</tt>, <tt>load</tt>, <tt>typeof</tt>, |
1121 | <tt>metatype</tt>, <tt>gc</tt>, <tt>sizeof</tt>, <tt>alignof</tt>, | 1121 | <tt>metatype</tt>, <tt>gc</tt>, <tt>sizeof</tt>, <tt>alignof</tt>, |
1122 | <tt>offsetof</tt>, <tt>errno</tt>.</li> | 1122 | <tt>offsetof</tt>.</li> |
1123 | </ul> | 1123 | </ul> |
1124 | <p> | 1124 | <p> |
1125 | Other missing features: | 1125 | Other missing features: |
diff --git a/src/lib_ffi.c b/src/lib_ffi.c index 850805e6..0a8a7282 100644 --- a/src/lib_ffi.c +++ b/src/lib_ffi.c | |||
@@ -603,7 +603,7 @@ LJLIB_CF(ffi_offsetof) | |||
603 | return 0; | 603 | return 0; |
604 | } | 604 | } |
605 | 605 | ||
606 | LJLIB_CF(ffi_errno) | 606 | LJLIB_CF(ffi_errno) LJLIB_REC(.) |
607 | { | 607 | { |
608 | int err = errno; | 608 | int err = errno; |
609 | if (L->top > L->base) | 609 | if (L->top > L->base) |
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 313bee81..4cdad9ef 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -1205,6 +1205,14 @@ void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd) | |||
1205 | crec_alloc(J, rd, argv2ctype(J, J->base[0], &rd->argv[0])); | 1205 | crec_alloc(J, rd, argv2ctype(J, J->base[0], &rd->argv[0])); |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd) | ||
1209 | { | ||
1210 | UNUSED(rd); | ||
1211 | if (J->base[0]) | ||
1212 | lj_trace_err(J, LJ_TRERR_NYICALL); | ||
1213 | J->base[0] = lj_ir_call(J, IRCALL_lj_vm_errno); | ||
1214 | } | ||
1215 | |||
1208 | void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd) | 1216 | void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd) |
1209 | { | 1217 | { |
1210 | CTState *cts = ctype_ctsG(J2G(J)); | 1218 | CTState *cts = ctype_ctsG(J2G(J)); |
diff --git a/src/lj_crecord.h b/src/lj_crecord.h index fce45afe..fb042c56 100644 --- a/src/lj_crecord.h +++ b/src/lj_crecord.h | |||
@@ -16,6 +16,7 @@ LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); | |||
16 | LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); | 16 | LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); |
17 | LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); | 17 | LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); |
18 | LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); | 18 | LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); |
19 | LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); | ||
19 | LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); | 20 | LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); |
20 | LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); | 21 | LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); |
21 | LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); | 22 | LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); |
@@ -28,6 +29,7 @@ LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); | |||
28 | #define recff_cdata_arith recff_nyi | 29 | #define recff_cdata_arith recff_nyi |
29 | #define recff_clib_index recff_nyi | 30 | #define recff_clib_index recff_nyi |
30 | #define recff_ffi_new recff_nyi | 31 | #define recff_ffi_new recff_nyi |
32 | #define recff_ffi_errno recff_nyi | ||
31 | #define recff_ffi_string recff_nyi | 33 | #define recff_ffi_string recff_nyi |
32 | #define recff_ffi_copy recff_nyi | 34 | #define recff_ffi_copy recff_nyi |
33 | #define recff_ffi_fill recff_nyi | 35 | #define recff_ffi_fill recff_nyi |
diff --git a/src/lj_ircall.h b/src/lj_ircall.h index 8ccc852e..5397046e 100644 --- a/src/lj_ircall.h +++ b/src/lj_ircall.h | |||
@@ -171,6 +171,7 @@ typedef struct CCallInfo { | |||
171 | _(FFI, strlen, 1, N, INTP, 0) \ | 171 | _(FFI, strlen, 1, N, INTP, 0) \ |
172 | _(FFI, memcpy, 3, S, PTR, 0) \ | 172 | _(FFI, memcpy, 3, S, PTR, 0) \ |
173 | _(FFI, memset, 3, S, PTR, 0) \ | 173 | _(FFI, memset, 3, S, PTR, 0) \ |
174 | _(FFI, lj_vm_errno, 0, S, INT, CCI_NOFPRCLOBBER) \ | ||
174 | _(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) | 175 | _(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) |
175 | \ | 176 | \ |
176 | /* End of list. */ | 177 | /* End of list. */ |
diff --git a/src/lj_vm.h b/src/lj_vm.h index 9ce14acc..da940b9f 100644 --- a/src/lj_vm.h +++ b/src/lj_vm.h | |||
@@ -78,6 +78,9 @@ LJ_ASMF double lj_vm_exp2(double); | |||
78 | #endif | 78 | #endif |
79 | #endif | 79 | #endif |
80 | LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); | 80 | LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t); |
81 | #if LJ_HASFFI | ||
82 | LJ_ASMF int lj_vm_errno(void); | ||
83 | #endif | ||
81 | #endif | 84 | #endif |
82 | 85 | ||
83 | /* Continuations for metamethods. */ | 86 | /* Continuations for metamethods. */ |
diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c index ec3d98af..8b177207 100644 --- a/src/lj_vmmath.c +++ b/src/lj_vmmath.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #define lj_vmmath_c | 6 | #define lj_vmmath_c |
7 | #define LUA_CORE | 7 | #define LUA_CORE |
8 | 8 | ||
9 | #include <errno.h> | ||
9 | #include <math.h> | 10 | #include <math.h> |
10 | 11 | ||
11 | #include "lj_obj.h" | 12 | #include "lj_obj.h" |
@@ -108,4 +109,11 @@ double lj_vm_foldfpm(double x, int fpm) | |||
108 | } | 109 | } |
109 | #endif | 110 | #endif |
110 | 111 | ||
112 | #if LJ_HASFFI | ||
113 | int lj_vm_errno(void) | ||
114 | { | ||
115 | return errno; | ||
116 | } | ||
117 | #endif | ||
118 | |||
111 | #endif | 119 | #endif |