util-src/poll.c
changeset 9321 3429006518bf
parent 9320 d8496858c809
child 9440 b202aa1e2d7b
equal deleted inserted replaced
9320:d8496858c809 9321:3429006518bf
    30 
    30 
    31 #ifdef USE_EPOLL
    31 #ifdef USE_EPOLL
    32 #define STATE_MT "util.poll.epoll"
    32 #define STATE_MT "util.poll.epoll"
    33 #else
    33 #else
    34 #define STATE_MT "util.poll.select"
    34 #define STATE_MT "util.poll.select"
       
    35 #endif
       
    36 
       
    37 #if (LUA_VERSION_NUM == 501)
       
    38 #define luaL_setmetatable(L, tname) luaL_getmetatable(L, tname); lua_setmetatable(L, -2)
    35 #endif
    39 #endif
    36 
    40 
    37 /*
    41 /*
    38  * Structure to keep state for each type of API
    42  * Structure to keep state for each type of API
    39  */
    43  */
   378 
   382 
   379 /*
   383 /*
   380  * Open library
   384  * Open library
   381  */
   385  */
   382 int luaopen_util_poll(lua_State *L) {
   386 int luaopen_util_poll(lua_State *L) {
       
   387 #if (LUA_VERSION_NUM > 501)
   383 	luaL_checkversion(L);
   388 	luaL_checkversion(L);
       
   389 #endif
   384 
   390 
   385 	luaL_newmetatable(L, STATE_MT);
   391 	luaL_newmetatable(L, STATE_MT);
   386 	{
   392 	{
   387 
   393 
   388 		lua_pushliteral(L, STATE_MT);
   394 		lua_pushliteral(L, STATE_MT);