[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Sleep
- From: Daniel Aquino <mr.danielaquino@...>
- Date: Thu, 14 Oct 2010 16:23:08 -0400
Well I already provided the source and I have it also at this url for now: http://fly.thruhere.net/projects/net_proxy/lua/lib/sleep/
I included everything bellow but I don't have a Mac so I can't help you there.
==sleep.c==
// unix bindings for sleep(seconds), usleep(microseconds), msleep(milliseconds).
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <unistd.h>
static int l_usleep(lua_State *L)
{
usleep( luaL_checkint(L,-1) );
return 0;
}
static int l_msleep(lua_State *L)
{
usleep( luaL_checkint(L,-1) * 1000 );
return 0;
}
static int l_sleep(lua_State *L)
{
sleep( luaL_checkint(L,-1) );
return 0;
}
int luaopen_sleep(lua_State *L)
{
lua_register( L, "usleep", l_usleep );
lua_register( L, "msleep", l_msleep );
lua_register( L, "sleep", l_sleep );
return 1;
}
==Makefile==
SO=sleep.so
CC=gcc
SRC+= $(wildcard *.c)
OBJ+= $(patsubst %.c,%.o,$(SRC))
HEADERS+= $(wildcard *.h)
FLAGS+=-pipe -g -fstack-protector-all -shared -Wl,-soname,$(SO).1
CFLAGS+=-Wall -Wextra -D_FORTIFY_SOURCE=2 -I. -I/usr/include/lua
all: $(SO)
$(SO): $(OBJ)
$(CC) $(FLAGS) -o $(SO) $(OBJ) $(LIBS)
$(OBJ): $(HEADERS) $(SRC)
clean:
$(RM) $(OBJ) $(SO) $(TAGS)
.PHONY: all clean
==sleep.lua==
require 'sleep'
while true do
print(".")
sleep(1)
end
On Thu, Oct 14, 2010 at 10:04 AM, Henning Diedrich
<hd2010@eonblast.com> wrote:
I guess plain Mac + gentoo was what I was
looking for :-) !
On 10/14/10 11:42 AM, Daniel Aquino wrote:
The example I gave is very easy to support on winapi.
I could throw one together including makefile and visual studios
project if someone wants.
Should be easy to support sdl as well.
On 10/14/10, steve donovan <steve.j.donovan@gmail.com> wrote:
On Wed, Oct 13, 2010 at 11:28 PM, Javier Guerra Giraldez
<javier@guerrag.com> wrote:
i guess there are good reasons against it, but wouldn't it be easier
if there was a non-ANSI sleep surrounded by #ifdef's ? after all,
there's the GNU-only readline....
Yes, admirable consistency, but it would be _convenient_ to have
os.sleep() around ;)
It isn't so easy to find one out there, without bringing in the whole
of LuaSocket, which feels inelegant.
steve d.
PS. another solution is to use Alien to bring in Sleep (on Windows) or
usleep (on POSIX)
- References:
- Sleep, Henning Diedrich
- Re: Sleep, Gabriel Duarte
- Re: Sleep, Daniel Aquino
- Re: Sleep, Steven Johnson
- Re: Sleep, Henning Diedrich
- Re: Sleep, Luiz Henrique de Figueiredo
- Re: Sleep, Javier Guerra Giraldez
- Re: Sleep, steve donovan
- Re: Sleep, Daniel Aquino
- Re: Sleep, Henning Diedrich