aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ltests.c b/ltests.c
index 6a638d05..1517aa88 100644
--- a/ltests.c
+++ b/ltests.c
@@ -2106,6 +2106,25 @@ static int coresume (lua_State *L) {
2106 } 2106 }
2107} 2107}
2108 2108
2109#if !defined(LUA_USE_POSIX)
2110
2111#define nonblock NULL
2112
2113#else
2114
2115#include <unistd.h>
2116#include <fcntl.h>
2117
2118static int nonblock (lua_State *L) {
2119 FILE *f = cast(luaL_Stream*, luaL_checkudata(L, 1, LUA_FILEHANDLE))->f;
2120 int fd = fileno(f);
2121 int flags = fcntl(fd, F_GETFL, 0);
2122 flags |= O_NONBLOCK;
2123 fcntl(fd, F_SETFL, flags);
2124 return 0;
2125}
2126#endif
2127
2109/* }====================================================== */ 2128/* }====================================================== */
2110 2129
2111 2130
@@ -2159,6 +2178,7 @@ static const struct luaL_Reg tests_funcs[] = {
2159 {"upvalue", upvalue}, 2178 {"upvalue", upvalue},
2160 {"externKstr", externKstr}, 2179 {"externKstr", externKstr},
2161 {"externstr", externstr}, 2180 {"externstr", externstr},
2181 {"nonblock", nonblock},
2162 {NULL, NULL} 2182 {NULL, NULL}
2163}; 2183};
2164 2184