lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Reuben Thomas wrote:
> On 11 May 2011 23:07, Mike Pall <mikelu-1105@mike.de> wrote:
> > I'd rather add io.fdopen() and fp:fileno(), because these are
> > useful for the FFI, too. Ok, so you'll need to fetch io.fdopen
> > once at the start and put it into an upvalue. Not sure if you're
> > happy with that.
> 
> I'd be delighted, but for a library I would prefer it be standard [and
> documented!]. Team?

Umm, you want this added to plain Lua? I don't think this will
happen, because it's not ANSI C. fdopen/fileno is only in POSIX.

> Is there any need for LuaJIT to
> implement fileno? The current luaposix implementation is:
> 
> static int Pfileno(lua_State *L)	/** fileno(filehandle) */
> {
> 	FILE *f = *(FILE**) luaL_checkudata(L, 1, LUA_FILEHANDLE);
> 	return pushresult(L, fileno(f), NULL);
> }
> 
> which works fine in LuaJIT 2.0.0-beta7:

Yes, the FILE * is the first field in the userdata payload in
LuaJIT, too. I have no plans to break the compatibility here.

--Mike